Source Code Cross Referenced for Component.java in  » Database-ORM » hibernate » org » hibernate » mapping » 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 » Database ORM » hibernate » org.hibernate.mapping 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //$Id: Component.java 10119 2006-07-14 00:09:19Z steve.ebersole@jboss.com $
002:        package org.hibernate.mapping;
003:
004:        import java.util.ArrayList;
005:        import java.util.HashMap;
006:        import java.util.Iterator;
007:        import java.util.Map;
008:
009:        import org.hibernate.EntityMode;
010:        import org.hibernate.MappingException;
011:        import org.hibernate.tuple.component.ComponentMetamodel;
012:        import org.hibernate.type.ComponentType;
013:        import org.hibernate.type.EmbeddedComponentType;
014:        import org.hibernate.type.Type;
015:        import org.hibernate.util.JoinedIterator;
016:        import org.hibernate.util.ReflectHelper;
017:
018:        /**
019:         * The mapping for a component, composite element,
020:         * composite identifier, etc.
021:         * @author Gavin King
022:         */
023:        public class Component extends SimpleValue implements  MetaAttributable {
024:
025:            private ArrayList properties = new ArrayList();
026:            private String componentClassName;
027:            private boolean embedded;
028:            private String parentProperty;
029:            private PersistentClass owner;
030:            private boolean dynamic;
031:            private Map metaAttributes;
032:            private String nodeName;
033:            private boolean isKey;
034:            private String roleName;
035:
036:            private java.util.Map tuplizerImpls;
037:
038:            public Component(PersistentClass owner) throws MappingException {
039:                super (owner.getTable());
040:                this .owner = owner;
041:            }
042:
043:            public Component(Component component) throws MappingException {
044:                super (component.getTable());
045:                this .owner = component.getOwner();
046:            }
047:
048:            public Component(Join join) throws MappingException {
049:                super (join.getTable());
050:                this .owner = join.getPersistentClass();
051:            }
052:
053:            public Component(Collection collection) throws MappingException {
054:                super (collection.getCollectionTable());
055:                this .owner = collection.getOwner();
056:            }
057:
058:            public int getPropertySpan() {
059:                return properties.size();
060:            }
061:
062:            public Iterator getPropertyIterator() {
063:                return properties.iterator();
064:            }
065:
066:            public void addProperty(Property p) {
067:                properties.add(p);
068:            }
069:
070:            public void addColumn(Column column) {
071:                throw new UnsupportedOperationException(
072:                        "Cant add a column to a component");
073:            }
074:
075:            public int getColumnSpan() {
076:                int n = 0;
077:                Iterator iter = getPropertyIterator();
078:                while (iter.hasNext()) {
079:                    Property p = (Property) iter.next();
080:                    n += p.getColumnSpan();
081:                }
082:                return n;
083:            }
084:
085:            public Iterator getColumnIterator() {
086:                Iterator[] iters = new Iterator[getPropertySpan()];
087:                Iterator iter = getPropertyIterator();
088:                int i = 0;
089:                while (iter.hasNext()) {
090:                    iters[i++] = ((Property) iter.next()).getColumnIterator();
091:                }
092:                return new JoinedIterator(iters);
093:            }
094:
095:            public void setTypeByReflection(String propertyClass,
096:                    String propertyName) {
097:            }
098:
099:            public boolean isEmbedded() {
100:                return embedded;
101:            }
102:
103:            public String getComponentClassName() {
104:                return componentClassName;
105:            }
106:
107:            public Class getComponentClass() throws MappingException {
108:                try {
109:                    return ReflectHelper.classForName(componentClassName);
110:                } catch (ClassNotFoundException cnfe) {
111:                    throw new MappingException("component class not found: "
112:                            + componentClassName, cnfe);
113:                }
114:            }
115:
116:            public PersistentClass getOwner() {
117:                return owner;
118:            }
119:
120:            public String getParentProperty() {
121:                return parentProperty;
122:            }
123:
124:            public void setComponentClassName(String componentClass) {
125:                this .componentClassName = componentClass;
126:            }
127:
128:            public void setEmbedded(boolean embedded) {
129:                this .embedded = embedded;
130:            }
131:
132:            public void setOwner(PersistentClass owner) {
133:                this .owner = owner;
134:            }
135:
136:            public void setParentProperty(String parentProperty) {
137:                this .parentProperty = parentProperty;
138:            }
139:
140:            public boolean isDynamic() {
141:                return dynamic;
142:            }
143:
144:            public void setDynamic(boolean dynamic) {
145:                this .dynamic = dynamic;
146:            }
147:
148:            private Type type;
149:
150:            public Type getType() throws MappingException {
151:                // added this caching as I noticed that getType() is being called multiple times...
152:                if (type == null) {
153:                    type = buildType();
154:                }
155:                return type;
156:            }
157:
158:            private Type buildType() {
159:                // TODO : temporary initial step towards HHH-1907
160:                ComponentMetamodel metamodel = new ComponentMetamodel(this );
161:                if (isEmbedded()) {
162:                    return new EmbeddedComponentType(metamodel);
163:                } else {
164:                    return new ComponentType(metamodel);
165:                }
166:            }
167:
168:            public void setTypeUsingReflection(String className,
169:                    String propertyName) throws MappingException {
170:            }
171:
172:            public java.util.Map getMetaAttributes() {
173:                return metaAttributes;
174:            }
175:
176:            public MetaAttribute getMetaAttribute(String attributeName) {
177:                return metaAttributes == null ? null
178:                        : (MetaAttribute) metaAttributes.get(attributeName);
179:            }
180:
181:            public void setMetaAttributes(java.util.Map metas) {
182:                this .metaAttributes = metas;
183:            }
184:
185:            public Object accept(ValueVisitor visitor) {
186:                return visitor.accept(this );
187:            }
188:
189:            public boolean[] getColumnInsertability() {
190:                boolean[] result = new boolean[getColumnSpan()];
191:                Iterator iter = getPropertyIterator();
192:                int i = 0;
193:                while (iter.hasNext()) {
194:                    Property prop = (Property) iter.next();
195:                    boolean[] chunk = prop.getValue().getColumnInsertability();
196:                    if (prop.isInsertable()) {
197:                        System.arraycopy(chunk, 0, result, i, chunk.length);
198:                    }
199:                    i += chunk.length;
200:                }
201:                return result;
202:            }
203:
204:            public boolean[] getColumnUpdateability() {
205:                boolean[] result = new boolean[getColumnSpan()];
206:                Iterator iter = getPropertyIterator();
207:                int i = 0;
208:                while (iter.hasNext()) {
209:                    Property prop = (Property) iter.next();
210:                    boolean[] chunk = prop.getValue().getColumnUpdateability();
211:                    if (prop.isUpdateable()) {
212:                        System.arraycopy(chunk, 0, result, i, chunk.length);
213:                    }
214:                    i += chunk.length;
215:                }
216:                return result;
217:            }
218:
219:            public String getNodeName() {
220:                return nodeName;
221:            }
222:
223:            public void setNodeName(String nodeName) {
224:                this .nodeName = nodeName;
225:            }
226:
227:            public boolean isKey() {
228:                return isKey;
229:            }
230:
231:            public void setKey(boolean isKey) {
232:                this .isKey = isKey;
233:            }
234:
235:            public boolean hasPojoRepresentation() {
236:                return componentClassName != null;
237:            }
238:
239:            public void addTuplizer(EntityMode entityMode, String implClassName) {
240:                if (tuplizerImpls == null) {
241:                    tuplizerImpls = new HashMap();
242:                }
243:                tuplizerImpls.put(entityMode, implClassName);
244:            }
245:
246:            public String getTuplizerImplClassName(EntityMode mode) {
247:                // todo : remove this once ComponentMetamodel is complete and merged
248:                if (tuplizerImpls == null) {
249:                    return null;
250:                }
251:                return (String) tuplizerImpls.get(mode);
252:            }
253:
254:            public Map getTuplizerMap() {
255:                if (tuplizerImpls == null) {
256:                    return null;
257:                }
258:                return java.util.Collections.unmodifiableMap(tuplizerImpls);
259:            }
260:
261:            public Property getProperty(String propertyName)
262:                    throws MappingException {
263:                Iterator iter = getPropertyIterator();
264:                while (iter.hasNext()) {
265:                    Property prop = (Property) iter.next();
266:                    if (prop.getName().equals(propertyName)) {
267:                        return prop;
268:                    }
269:                }
270:                throw new MappingException("component property not found: "
271:                        + propertyName);
272:            }
273:
274:            public String getRoleName() {
275:                return roleName;
276:            }
277:
278:            public void setRoleName(String roleName) {
279:                this .roleName = roleName;
280:            }
281:
282:            public String toString() {
283:                return getClass().getName() + '(' + properties.toString() + ')';
284:            }
285:
286:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.