Source Code Cross Referenced for IdentifiableObject.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » metaobj » shared » model » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » sakai » org.sakaiproject.metaobj.shared.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/metaobj/tags/sakai_2-4-1/metaobj-api/api/src/java/org/sakaiproject/metaobj/shared/model/IdentifiableObject.java $
003:         * $Id: IdentifiableObject.java 17619 2006-10-31 00:55:55Z john.ellis@rsmart.com $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
007:         * 
008:         * Licensed under the Educational Community License, Version 1.0 (the "License"); 
009:         * you may not use this file except in compliance with the License. 
010:         * You may obtain a copy of the License at
011:         * 
012:         *      http://www.opensource.org/licenses/ecl1.php
013:         * 
014:         * Unless required by applicable law or agreed to in writing, software 
015:         * distributed under the License is distributed on an "AS IS" BASIS, 
016:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
017:         * See the License for the specific language governing permissions and 
018:         * limitations under the License.
019:         *
020:         **********************************************************************************/package org.sakaiproject.metaobj.shared.model;
021:
022:        import org.apache.commons.logging.Log;
023:        import org.apache.commons.logging.LogFactory;
024:
025:        /**
026:         * any derived class should use the generator in the hibernate xml definitian:
027:         *     org.sakaiproject.metaobj.shared.IdentifiableIdGenerator
028:         * This way the newId field will be supported when creating 
029:         * new objects with predetermined ids.
030:         * 
031:         * User: jbush
032:         * Date: May 15, 2004
033:         * Time: 1:55:47 PM
034:         * To change this template use File | Settings | File Templates.
035:         */
036:        abstract public class IdentifiableObject {
037:            private Id id;
038:            private Id newId;
039:            protected final Log logger = LogFactory.getLog(this .getClass());
040:
041:            public boolean equals(Object in) {
042:                if (this  == in) {
043:                    return true;
044:                }
045:                if (in == null && this  == null) {
046:                    return true;
047:                }
048:                if (in == null && this  != null) {
049:                    return false;
050:                }
051:                if (this  == null && in != null) {
052:                    return false;
053:                }
054:                if (!this .getClass().isAssignableFrom(in.getClass())) {
055:                    return false;
056:                }
057:                if (this .getId() == null
058:                        && ((IdentifiableObject) in).getId() == null) {
059:                    return true;
060:                }
061:                if (this .getId() == null
062:                        || ((IdentifiableObject) in).getId() == null) {
063:                    return false;
064:                }
065:                return this .getId().equals(((IdentifiableObject) in).getId());
066:            }
067:
068:            public int hashCode() {
069:                return (id != null ? id.hashCode() : 0);
070:            }
071:
072:            /**
073:             * returns the id of the object stored in the database.  if the object is new and hasn't
074:             * been saved to the database then it may have an id...  check getNewId.
075:             * @return Id
076:             */
077:            public Id getId() {
078:                return id;
079:            }
080:
081:            /**
082:             * sets the id of the object.  If the object is new then this parameter will be ignored
083:             * and a new id will be generated.  Use setNewId to set the id of a new object.
084:             * 
085:             * @param id
086:             */
087:            public void setId(Id id) {
088:                this .id = id;
089:            }
090:
091:            /**
092:             * If this object is new and we want it to have a specific id then this is set before
093:             * the object is saved.
094:             * @return Id
095:             */
096:            public Id getNewId() {
097:                return newId;
098:            }
099:
100:            /**
101:             * if create an identifiable object with a specific id, then this is what you set.
102:             * The id generator won't create a new id but will use this field as the id
103:             * @param newId
104:             */
105:            public void setNewId(Id newId) {
106:                this .newId = newId;
107:            }
108:
109:            /**
110:             * this returns the effective id.  First it checks for the real id,
111:             * then if it's not good then it returns the newId.
112:             * @return Id
113:             */
114:            public Id getVirtualId() {
115:                if (id != null && id.getValue() != null
116:                        && id.getValue().length() > 0)
117:                    return id;
118:                return newId;
119:            }
120:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.