Source Code Cross Referenced for DSOField.java in  » Net » Terracotta » com » tc » admin » dso » 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 » Net » Terracotta » com.tc.admin.dso 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice.  All rights reserved.
003:         */
004:        package com.tc.admin.dso;
005:
006:        import com.tc.admin.AdminClient;
007:        import com.tc.admin.ConnectionContext;
008:        import com.tc.object.LiteralValues;
009:        import com.tc.object.ObjectID;
010:        import com.tc.object.dna.impl.EnumInstance;
011:        import com.tc.objectserver.mgmt.ManagedObjectFacade;
012:
013:        import java.beans.PropertyChangeEvent;
014:
015:        public class DSOField extends DSOObject {
016:            private String m_name;
017:            private boolean m_isPrimitive;
018:            private boolean m_isMap;
019:            private boolean m_isList;
020:            private boolean m_isSet;
021:            private boolean m_isArray;
022:            private String m_type;
023:            private Object m_value;
024:            private String[] m_fieldNames;
025:            private DSOObject[] m_fields;
026:            private String m_label;
027:            private boolean m_isCycle;
028:            private DSOObject m_cycleRoot;
029:            private boolean m_isLiteral;
030:
031:            private final static LiteralValues m_literals = new LiteralValues();
032:
033:            public DSOField(ConnectionContext cc, String name,
034:                    boolean isPrimitive, String type, Object value,
035:                    DSOObject parent) {
036:                super (cc, parent);
037:
038:                if (type != null
039:                        && (type.equals("java.util.Date") || type
040:                                .equals("java.sql.Timestamp"))) {
041:                    isPrimitive = true;
042:                    ManagedObjectFacade mof = (ManagedObjectFacade) value;
043:                    value = mof.getFieldValue("date");
044:                }
045:
046:                m_name = name;
047:                m_isPrimitive = isPrimitive;
048:                m_type = type;
049:                m_value = value;
050:                m_isLiteral = isLiteral();
051:
052:                initFields();
053:                updateLabel();
054:            }
055:
056:            private boolean isLiteral() {
057:                if (m_value != null) {
058:                    Class c = m_value.getClass();
059:                    return !c.isArray() && m_literals.isLiteral(c.getName());
060:                }
061:                return false;
062:            }
063:
064:            public Object getFacade() {
065:                return m_value instanceof  ManagedObjectFacade ? (ManagedObjectFacade) m_value
066:                        : null;
067:            }
068:
069:            protected void updateLabel() {
070:                String prefix = m_name;
071:
072:                if (m_type != null) {
073:                    prefix += " (" + m_type + ")";
074:                }
075:
076:                m_label = prefix;
077:
078:                if (m_isLiteral) {
079:                    if (m_value instanceof  EnumInstance) {
080:                        EnumInstance enumInstance = (EnumInstance) m_value;
081:                        String enumType = enumInstance.getClassInstance()
082:                                .getName().asString();
083:                        m_label = getName() + " (" + enumType + ")" + "="
084:                                + enumInstance;
085:                    } else {
086:                        m_label = prefix + "=" + m_value;
087:                    }
088:                } else if (isCollection()) {
089:                    ManagedObjectFacade mof = (ManagedObjectFacade) m_value;
090:                    m_label += " [" + mof.getFacadeSize() + "/"
091:                            + mof.getTrueObjectSize() + "]";
092:                } else if (isPrimitive() || m_value == null
093:                        || m_value instanceof  String) {
094:                    m_label = prefix + "=" + m_value;
095:                }
096:
097:            }
098:
099:            public void initFields() {
100:                if (!m_isPrimitive) {
101:                    if (m_value != null
102:                            && m_value instanceof  ManagedObjectFacade) {
103:                        ManagedObjectFacade mof = (ManagedObjectFacade) m_value;
104:
105:                        m_isMap = mof.isMap();
106:                        m_isList = mof.isList();
107:                        m_isSet = mof.isSet();
108:                        m_isArray = mof.isArray();
109:                        m_isCycle = isCycle(mof);
110:                    }
111:
112:                    m_fields = new DSOObject[getFieldCount()];
113:                }
114:            }
115:
116:            public String getName() {
117:                return m_name;
118:            }
119:
120:            public boolean isPrimitive() {
121:                return m_isPrimitive;
122:            }
123:
124:            public boolean isArray() {
125:                return m_isArray;
126:            }
127:
128:            public boolean isCollection() {
129:                return isMap() || isList() || isSet();
130:            }
131:
132:            public boolean isMap() {
133:                return m_isMap;
134:            }
135:
136:            public boolean isList() {
137:                return m_isList;
138:            }
139:
140:            public boolean isCycle() {
141:                return m_isCycle;
142:            }
143:
144:            public DSOObject getCycleRoot() {
145:                return m_cycleRoot;
146:            }
147:
148:            public boolean isSet() {
149:                return m_isSet;
150:            }
151:
152:            public String getType() {
153:                return m_type;
154:            }
155:
156:            public Object getValue() {
157:                return m_value;
158:            }
159:
160:            public String[] getFieldNames() {
161:                if (m_fieldNames == null) {
162:                    if (m_value != null
163:                            && m_value instanceof  ManagedObjectFacade) {
164:                        ManagedObjectFacade facade = (ManagedObjectFacade) m_value;
165:                        m_fieldNames = RootsHelper.getHelper().trimFields(
166:                                facade.getFields());
167:                    } else {
168:                        m_fieldNames = new String[] {};
169:                    }
170:                }
171:
172:                return m_fieldNames;
173:            }
174:
175:            public String getFieldName(int index) {
176:                String[] names = getFieldNames();
177:                return names != null ? names[index] : null;
178:            }
179:
180:            public DSOObject getField(int index) {
181:                DSOObject result = null;
182:
183:                if (m_fields == null) {
184:                    m_fields = new DSOObject[getFieldCount()];
185:                }
186:
187:                if (m_fields[index] == null) {
188:                    ManagedObjectFacade mof = (ManagedObjectFacade) getValue();
189:                    String field = getFieldName(index);
190:
191:                    try {
192:                        result = createField(field, mof.getFieldValue(field),
193:                                mof.getFieldType(field));
194:                    } catch (Throwable t) {
195:                        //t.printStackTrace();
196:                    }
197:                }
198:
199:                m_fields[index] = result;
200:
201:                return result;
202:            }
203:
204:            public int getFieldCount() {
205:                return m_isCycle ? 0 : getFieldNames().length;
206:            }
207:
208:            public String toString() {
209:                return m_label;
210:            }
211:
212:            public boolean isValid() {
213:                boolean result = true;
214:
215:                if (m_value != null && m_value instanceof  ManagedObjectFacade) {
216:                    ManagedObjectFacade mof = (ManagedObjectFacade) m_value;
217:                    ObjectID id = mof.getObjectId();
218:
219:                    try {
220:                        m_value = DSOHelper.getHelper().lookupFacade(m_cc, id,
221:                                m_batchSize);
222:                        result = (m_value != null);
223:                    } catch (Exception e) {
224:                        result = false;
225:                    }
226:                }
227:
228:                return result;
229:            }
230:
231:            protected void updateFacade() throws Exception {
232:                if (m_value != null && m_value instanceof  ManagedObjectFacade) {
233:                    ManagedObjectFacade mof = (ManagedObjectFacade) m_value;
234:                    ObjectID id = mof.getObjectId();
235:
236:                    m_value = DSOHelper.getHelper().lookupFacade(m_cc, id,
237:                            m_batchSize);
238:                }
239:            }
240:
241:            public boolean isCycle(ManagedObjectFacade mof) {
242:                ObjectID oid = mof.getObjectId();
243:                DSOObject parent = getParent();
244:
245:                while (parent != null) {
246:                    Object facade = parent.getFacade();
247:
248:                    if (facade instanceof  ManagedObjectFacade) {
249:                        ObjectID parentOID = ((ManagedObjectFacade) facade)
250:                                .getObjectId();
251:
252:                        if (oid.equals(parentOID)) {
253:                            m_cycleRoot = parent;
254:                            return true;
255:                        }
256:                    }
257:                    parent = parent.getParent();
258:                }
259:
260:                return false;
261:            }
262:
263:            public void refresh() {
264:                try {
265:                    updateFacade();
266:                    updateLabel();
267:                    m_fieldNames = null;
268:                    m_fields = null;
269:
270:                    m_changeHelper.firePropertyChange(new PropertyChangeEvent(
271:                            this , null, null, null));
272:                } catch (Exception e) {
273:                    AdminClient.getContext().log(e);
274:                }
275:            }
276:
277:            public void accept(DSOObjectVisitor visitor) {
278:                visitor.visitDSOField(this);
279:            }
280:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.