Source Code Cross Referenced for ElementEntry.java in  » GIS » geonetwork » org » fao » geonet » kernel » schema » 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 » GIS » geonetwork » org.fao.geonet.kernel.schema 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //==============================================================================
002:        //===
003:        //===   ElementEntry
004:        //===
005:        //==============================================================================
006:        //===	Copyright (C) 2001-2005 Food and Agriculture Organization of the
007:        //===	United Nations (FAO-UN), United Nations World Food Programme (WFP)
008:        //===	and United Nations Environment Programme (UNEP)
009:        //===
010:        //===	This program is free software; you can redistribute it and/or modify
011:        //===	it under the terms of the GNU General Public License as published by
012:        //===	the Free Software Foundation; either version 2 of the License, or (at
013:        //===	your option) any later version.
014:        //===
015:        //===	This program is distributed in the hope that it will be useful, but
016:        //===	WITHOUT ANY WARRANTY; without even the implied warranty of
017:        //===	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
018:        //===	General Public License for more details.
019:        //===
020:        //===	You should have received a copy of the GNU General Public License
021:        //===	along with this program; if not, write to the Free Software
022:        //===	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
023:        //===
024:        //===	Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2,
025:        //===	Rome - Italy. email: geonetwork@osgeo.org
026:        //==============================================================================
027:
028:        package org.fao.geonet.kernel.schema;
029:
030:        import java.util.ArrayList;
031:        import java.util.List;
032:        import java.util.StringTokenizer;
033:
034:        import org.jdom.Attribute;
035:        import org.jdom.Element;
036:
037:        //==============================================================================
038:
039:        class ElementEntry {
040:            public String name;
041:            public String ns;
042:            public String type;
043:            public int min = 1;
044:            public int max = 1;
045:            public String substGroup;
046:            public String substGroupNS;
047:            public String ref;
048:            public boolean abstrElem;
049:            public boolean choiceElem;
050:            public boolean groupElem;
051:            public boolean sequenceElem;
052:            public ArrayList alContainerElems = new ArrayList();
053:
054:            public ComplexTypeEntry complexType;
055:            public SimpleTypeEntry simpleType;
056:
057:            //---------------------------------------------------------------------------
058:            //---
059:            //--- Constructor - this class handles both <element> and <choice> entries 
060:            //---
061:            //---------------------------------------------------------------------------
062:
063:            private ElementEntry() {
064:            }
065:
066:            //---------------------------------------------------------------------------
067:
068:            public ElementEntry(Element el, String file, String targetNS,
069:                    String targetNSPrefix) {
070:                this (new ElementInfo(el, file, targetNS, targetNSPrefix));
071:            }
072:
073:            //---------------------------------------------------------------------------
074:
075:            public ElementEntry(ElementInfo ei) {
076:                ns = ei.targetNS;
077:                handleAttribs(ei);
078:                if (choiceElem)
079:                    handleContainerChildren(ei, alContainerElems);
080:                else if (groupElem)
081:                    ; // no need to do anything - read elements from group later
082:                else if (sequenceElem)
083:                    handleContainerChildren(ei, alContainerElems);
084:                else
085:                    handleChildren(ei);
086:            }
087:
088:            //---------------------------------------------------------------------------
089:            //---
090:            //--- API methods
091:            //---
092:            //---------------------------------------------------------------------------
093:
094:            public ElementEntry copy() {
095:                ElementEntry ee = new ElementEntry();
096:
097:                ee.name = name;
098:                ee.ns = ns;
099:                ee.type = type;
100:                ee.min = min;
101:                ee.max = max;
102:                ee.substGroup = substGroup;
103:                ee.substGroupNS = substGroupNS;
104:                ee.ref = ref;
105:                ee.abstrElem = abstrElem;
106:
107:                ee.complexType = complexType;
108:                ee.simpleType = simpleType;
109:                ee.choiceElem = choiceElem;
110:                ee.groupElem = groupElem;
111:                ee.sequenceElem = sequenceElem;
112:                ee.alContainerElems = alContainerElems;
113:
114:                return ee;
115:            }
116:
117:            public String toString() {
118:                return new String("ElementEntry name: " + name + " ref: " + ref
119:                        + " type: " + type + " abstract: " + abstrElem
120:                        + " choice: " + choiceElem + " group: " + groupElem
121:                        + " sequence: " + sequenceElem);
122:            }
123:
124:            //---------------------------------------------------------------------------
125:            //---
126:            //--- Private methods
127:            //---
128:            //---------------------------------------------------------------------------
129:
130:            private void handleAttribs(ElementInfo ei) {
131:                if (ei.element.getName().equals("choice"))
132:                    choiceElem = true;
133:                else if (ei.element.getName().equals("group"))
134:                    groupElem = true;
135:                else if (ei.element.getName().equals("sequence"))
136:                    sequenceElem = true;
137:
138:                List attrs = ei.element.getAttributes();
139:
140:                for (int i = 0; i < attrs.size(); i++) {
141:                    Attribute at = (Attribute) attrs.get(i);
142:
143:                    String attrName = at.getName();
144:                    String value = at.getValue();
145:
146:                    if (attrName.equals("name")) {
147:                        name = at.getValue();
148:                        if ((name.indexOf(":") == -1)
149:                                && (ei.targetNSPrefix != null))
150:                            name = ei.targetNSPrefix + ":" + at.getValue();
151:                        // System.out.println("Doing Element "+name);
152:                    } else if (attrName.equals("type")) {
153:                        type = value;
154:                    }
155:
156:                    else if (attrName.equals("ref"))
157:                        ref = value;
158:
159:                    else if (attrName.equals("substitutionGroup"))
160:                        substGroup = value;
161:
162:                    else if (attrName.equals("abstract")) {
163:                        abstrElem = "true".equals(value);
164:                    } else if (attrName.equals("minOccurs"))
165:                        min = Integer.parseInt(value);
166:
167:                    else if (attrName.equals("maxOccurs")) {
168:                        if (value.equals("unbounded"))
169:                            max = 10000;
170:                        else
171:                            max = Integer.parseInt(value);
172:                    }
173:
174:                    else {
175:                        if (choiceElem)
176:                            Logger.log("Unknown attribute '" + attrName
177:                                    + "'in <choice> element", ei);
178:                        else if (groupElem)
179:                            Logger.log("Unknown attribute '" + attrName
180:                                    + "'in <group> element", ei);
181:                        else if (sequenceElem)
182:                            Logger.log("Unknown attribute '" + attrName
183:                                    + "'in <sequence> element", ei);
184:                        else
185:                            Logger.log("Unknown attribute '" + attrName
186:                                    + "'in <element> element", ei);
187:
188:                    }
189:                }
190:            }
191:
192:            //---------------------------------------------------------------------------
193:
194:            private void handleChildren(ElementInfo ei) {
195:                List children = ei.element.getChildren();
196:
197:                for (int i = 0; i < children.size(); i++) {
198:                    Element elChild = (Element) children.get(i);
199:                    String elName = elChild.getName();
200:
201:                    if (elName.equals("complexType"))
202:                        complexType = new ComplexTypeEntry(elChild, ei.file,
203:                                ei.targetNS, ei.targetNSPrefix);
204:
205:                    else if (elName.equals("simpleType")) {
206:                        simpleType = new SimpleTypeEntry(elChild, ei.file,
207:                                ei.targetNS, ei.targetNSPrefix);
208:                        if (simpleType.name == null)
209:                            simpleType.name = name + "HASHS";
210:                    }
211:
212:                    else if (elName.equals("key"))
213:                        Logger
214:                                .log("Skipping 'key' child in <element> element '"
215:                                        + name + "'");
216:
217:                    else if (elName.equals("annotation"))
218:                        ;
219:
220:                    else
221:                        Logger.log("Unknown child '" + elName
222:                                + "' in <element> element", ei);
223:                }
224:            }
225:
226:            //---------------------------------------------------------------------------
227:
228:            private void handleContainerChildren(ElementInfo ei,
229:                    ArrayList elements) {
230:                List children = ei.element.getChildren();
231:
232:                for (int i = 0; i < children.size(); i++) {
233:
234:                    if (groupElem)
235:                        System.out
236:                                .println("WARNING found element children for group in element "
237:                                        + name + " " + ref);
238:                    Element elChild = (Element) children.get(i);
239:                    String elName = elChild.getName();
240:
241:                    if (elName.equals("annotation")) {
242:                        List appinfo = elChild.getChildren();
243:                        for (int j = 0; j < appinfo.size(); j++) {
244:                            Element elElem = (Element) appinfo.get(j);
245:                            if (elElem.getName().equals("appinfo")) {
246:                                name = (String) elElem.getText();
247:                            }
248:                        }
249:                    }
250:
251:                    else if (elName.equals("element")
252:                            || elName.equals("choice")
253:                            || elName.equals("sequence")
254:                            || elName.equals("group")) {
255:                        elements.add(new ElementEntry(elChild, ei.file,
256:                                ei.targetNS, ei.targetNSPrefix));
257:                    }
258:
259:                    else
260:                        Logger.log("handleContainerChildren: Unknown child '"
261:                                + elName
262:                                + "' in <choice>|<group>|<sequence> element",
263:                                ei);
264:                }
265:            }
266:        }
267:
268:        //==============================================================================
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.