Source Code Cross Referenced for XSDDescription.java in  » XML » xerces-2_9_1 » org » apache » xerces » impl » xs » 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 » XML » xerces 2_9_1 » org.apache.xerces.impl.xs 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        package org.apache.xerces.impl.xs;
019:
020:        import org.apache.xerces.util.XMLResourceIdentifierImpl;
021:        import org.apache.xerces.xni.QName;
022:        import org.apache.xerces.xni.XMLAttributes;
023:        import org.apache.xerces.xni.grammars.XMLGrammarDescription;
024:        import org.apache.xerces.xni.grammars.XMLSchemaDescription;
025:
026:        /**
027:         * All information specific to XML Schema grammars.
028:         *
029:         * @xerces.internal 
030:         *
031:         * @author Neil Graham, IBM
032:         * @author Neeraj Bajaj, SUN Microsystems.
033:         *
034:         * @version $Id: XSDDescription.java 446734 2006-09-15 20:51:23Z mrglavas $
035:         */
036:        public class XSDDescription extends XMLResourceIdentifierImpl implements 
037:                XMLSchemaDescription {
038:            // used to indicate what triggered the call
039:            /**
040:             * Indicate that this description was just initialized. 
041:             */
042:            public final static short CONTEXT_INITIALIZE = -1;
043:            /**
044:             * Indicate that the current schema document is <include>d by another
045:             * schema document.
046:             */
047:            public final static short CONTEXT_INCLUDE = 0;
048:            /**
049:             * Indicate that the current schema document is <redefine>d by another
050:             * schema document.
051:             */
052:            public final static short CONTEXT_REDEFINE = 1;
053:            /**
054:             * Indicate that the current schema document is <import>ed by another
055:             * schema document.
056:             */
057:            public final static short CONTEXT_IMPORT = 2;
058:            /**
059:             * Indicate that the current schema document is being preparsed.
060:             */
061:            public final static short CONTEXT_PREPARSE = 3;
062:            /**
063:             * Indicate that the parse of the current schema document is triggered
064:             * by xsi:schemaLocation/noNamespaceSchemaLocation attribute(s) in the
065:             * instance document. This value is only used if we don't defer the loading
066:             * of schema documents.
067:             */
068:            public final static short CONTEXT_INSTANCE = 4;
069:            /**
070:             * Indicate that the parse of the current schema document is triggered by
071:             * the occurrence of an element whose namespace is the target namespace
072:             * of this schema document. This value is only used if we do defer the
073:             * loading of schema documents until a component from that namespace is
074:             * referenced from the instance.
075:             */
076:            public final static short CONTEXT_ELEMENT = 5;
077:            /**
078:             * Indicate that the parse of the current schema document is triggered by
079:             * the occurrence of an attribute whose namespace is the target namespace
080:             * of this schema document. This value is only used if we do defer the
081:             * loading of schema documents until a component from that namespace is
082:             * referenced from the instance.
083:             */
084:            public final static short CONTEXT_ATTRIBUTE = 6;
085:            /**
086:             * Indicate that the parse of the current schema document is triggered by
087:             * the occurrence of an "xsi:type" attribute, whose value (a QName) has
088:             * the target namespace of this schema document as its namespace.
089:             * This value is only used if we do defer the loading of schema documents
090:             * until a component from that namespace is referenced from the instance.
091:             */
092:            public final static short CONTEXT_XSITYPE = 7;
093:
094:            // REVISIT: write description of these fields	
095:            protected short fContextType;
096:            protected String[] fLocationHints;
097:            protected QName fTriggeringComponent;
098:            protected QName fEnclosedElementName;
099:            protected XMLAttributes fAttributes;
100:
101:            /**
102:             * the type of the grammar (e.g., DTD or XSD);
103:             *  
104:             * @see org.apache.xerces.xni.grammars.Grammar
105:             */
106:            public String getGrammarType() {
107:                return XMLGrammarDescription.XML_SCHEMA;
108:            }
109:
110:            /**
111:             * Get the context. The returned value is one of the pre-defined
112:             * CONTEXT_xxx constants.
113:             * 
114:             * @return  the value indicating the context
115:             */
116:            public short getContextType() {
117:                return fContextType;
118:            }
119:
120:            /**
121:             * If the context is "include" or "redefine", then return the target
122:             * namespace of the enclosing schema document; otherwise, the expected
123:             * target namespace of this document.
124:             * 
125:             * @return  the expected/enclosing target namespace
126:             */
127:            public String getTargetNamespace() {
128:                return fNamespace;
129:            }
130:
131:            /**
132:             * For import and references from the instance document, it's possible to
133:             * have multiple hints for one namespace. So this method returns an array,
134:             * which contains all location hints.
135:             * 
136:             * @return  an array of all location hints associated to the expected
137:             *          target namespace
138:             */
139:            public String[] getLocationHints() {
140:                return fLocationHints;
141:            }
142:
143:            /**
144:             * If a call is triggered by an element/attribute/xsi:type in the instance,
145:             * this call returns the name of such triggering component: the name of
146:             * the element/attribute, or the value of the xsi:type.
147:             * 
148:             * @return  the name of the triggering component
149:             */
150:            public QName getTriggeringComponent() {
151:                return fTriggeringComponent;
152:            }
153:
154:            /**
155:             * If a call is triggered by an attribute or xsi:type, then this mehtod
156:             * returns the enclosing element of such element.
157:             * 
158:             * @return  the name of the enclosing element
159:             */
160:            public QName getEnclosingElementName() {
161:                return fEnclosedElementName;
162:            }
163:
164:            /**
165:             * If a call is triggered by an element/attribute/xsi:type in the instance,
166:             * this call returns all attribute of such element (or enclosing element).
167:             * 
168:             * @return  all attributes of the tiggering/enclosing element
169:             */
170:            public XMLAttributes getAttributes() {
171:                return fAttributes;
172:            }
173:
174:            public boolean fromInstance() {
175:                return fContextType == CONTEXT_ATTRIBUTE
176:                        || fContextType == CONTEXT_ELEMENT
177:                        || fContextType == CONTEXT_INSTANCE
178:                        || fContextType == CONTEXT_XSITYPE;
179:            }
180:
181:            /**
182:             * Compares this grammar with the given grammar. Currently, we compare 
183:             * the target namespaces.
184:             * 
185:             * @param descObj The description of the grammar to be compared with
186:             * @return        True if they are equal, else false
187:             */
188:            public boolean equals(Object descObj) {
189:                if (!(descObj instanceof  XMLSchemaDescription))
190:                    return false;
191:                XMLSchemaDescription desc = (XMLSchemaDescription) descObj;
192:                if (fNamespace != null)
193:                    return fNamespace.equals(desc.getTargetNamespace());
194:                else
195:                    // fNamespace == null
196:                    return desc.getTargetNamespace() == null;
197:            }
198:
199:            /**
200:             * Returns the hash code of this grammar
201:             * 
202:             * @return The hash code
203:             */
204:            public int hashCode() {
205:                return (fNamespace == null) ? 0 : fNamespace.hashCode();
206:            }
207:
208:            public void setContextType(short contextType) {
209:                fContextType = contextType;
210:            }
211:
212:            public void setTargetNamespace(String targetNamespace) {
213:                fNamespace = targetNamespace;
214:            }
215:
216:            public void setLocationHints(String[] locationHints) {
217:                int length = locationHints.length;
218:                fLocationHints = new String[length];
219:                System.arraycopy(locationHints, 0, fLocationHints, 0, length);
220:                //fLocationHints = locationHints ;
221:            }
222:
223:            public void setTriggeringComponent(QName triggeringComponent) {
224:                fTriggeringComponent = triggeringComponent;
225:            }
226:
227:            public void setEnclosingElementName(QName enclosedElementName) {
228:                fEnclosedElementName = enclosedElementName;
229:            }
230:
231:            public void setAttributes(XMLAttributes attributes) {
232:                fAttributes = attributes;
233:            }
234:
235:            /**
236:             *  resets all the fields
237:             */
238:            public void reset() {
239:                super .clear();
240:                fContextType = CONTEXT_INITIALIZE;
241:                fLocationHints = null;
242:                fTriggeringComponent = null;
243:                fEnclosedElementName = null;
244:                fAttributes = null;
245:            }
246:
247:            public XSDDescription makeClone() {
248:                XSDDescription desc = new XSDDescription();
249:                desc.fAttributes = this .fAttributes;
250:                desc.fBaseSystemId = this .fBaseSystemId;
251:                desc.fContextType = this .fContextType;
252:                desc.fEnclosedElementName = this .fEnclosedElementName;
253:                desc.fExpandedSystemId = this .fExpandedSystemId;
254:                desc.fLiteralSystemId = this .fLiteralSystemId;
255:                desc.fLocationHints = this .fLocationHints;
256:                desc.fPublicId = this .fPublicId;
257:                desc.fNamespace = this .fNamespace;
258:                desc.fTriggeringComponent = this .fTriggeringComponent;
259:                return desc;
260:            }
261:
262:        } // XSDDescription
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.