Source Code Cross Referenced for XMLContentSpec.java in  » XML » xerces-2_9_1 » org » apache » xerces » impl » dtd » 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.dtd 
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.dtd;
019:
020:        /**
021:         * ContentSpec really exists to aid the parser classes in implementing
022:         * access to the grammar.
023:         * <p>
024:         * This class is used by the DTD scanner and the validator classes,
025:         * allowing them to be used separately or together.  This "struct"
026:         * class is used to build content models for validation, where it
027:         * is more efficient to fetch all of the information for each of
028:         * these content model "fragments" than to fetch each field one at
029:         * a time.  Since configurations are allowed to have validators
030:         * without a DTD scanner (i.e. a schema validator) and a DTD scanner
031:         * without a validator (non-validating processor), this class can be
032:         * used by each without requiring the presence of the other.
033:         * <p>
034:         * When processing element declarations, the DTD scanner will build
035:         * up a representation of the content model using the node types that
036:         * are defined here.  Since a non-validating processor only needs to
037:         * remember the type of content model declared (i.e. ANY, EMPTY, MIXED,
038:         * or CHILDREN), it is free to discard the specific details of the
039:         * MIXED and CHILDREN content models described using this class.
040:         * <p>
041:         * In the typical case of a validating processor reading the grammar
042:         * of the document from a DTD, the information about the content model
043:         * declared will be preserved and later "compiled" into an efficient
044:         * form for use during element validation.  Each content spec node
045:         * that is saved is assigned a unique index that is used as a handle
046:         * for the "value" or "otherValue" fields of other content spec nodes.
047:         * A leaf node has a "value" that is either an index in the string
048:         * pool of the element type of that leaf, or a value of -1 to indicate
049:         * the special "#PCDATA" leaf type used in a mixed content model.
050:         * <p>
051:         * For a mixed content model, the content spec will be made up of
052:         * leaf and choice content spec nodes, with an optional "zero or more"
053:         * node.  For example, the mixed content declaration "(#PCDATA)" would
054:         * contain a single leaf node with a node value of -1.  A mixed content
055:         * declaration of "(#PCDATA|foo)*" would have a content spec consisting
056:         * of two leaf nodes, for the "#PCDATA" and "foo" choices, a choice node
057:         * with the "value" set to the index of the "#PCDATA" leaf node and the
058:         * "otherValue" set to the index of the "foo" leaf node, and a "zero or
059:         * more" node with the "value" set to the index of the choice node.  If
060:         * the content model has more choices, for example "(#PCDATA|a|b)*", then
061:         * there will be more corresponding choice and leaf nodes, the choice
062:         * nodes will be chained together through the "value" field with each
063:         * leaf node referenced by the "otherValue" field.
064:         * <p>
065:         * For element content models, there are sequence nodes and also "zero or
066:         * one" and "one or more" nodes.  The leaf nodes would always have a valid
067:         * string pool index, as the "#PCDATA" leaf is not used in the declarations
068:         * for element content models.
069:         * 
070:         * @xerces.internal
071:         *
072:         * @version $Id: XMLContentSpec.java 446755 2006-09-15 21:56:27Z mrglavas $
073:         */
074:        public class XMLContentSpec {
075:
076:            //
077:            // Constants
078:            //
079:
080:            /** 
081:             * Name or #PCDATA. Leaf nodes that represent parsed character
082:             * data (#PCDATA) have values of -1.
083:             */
084:            public static final short CONTENTSPECNODE_LEAF = 0;
085:
086:            /** Represents a zero or one occurence count, '?'. */
087:            public static final short CONTENTSPECNODE_ZERO_OR_ONE = 1;
088:
089:            /** Represents a zero or more occurence count, '*'. */
090:            public static final short CONTENTSPECNODE_ZERO_OR_MORE = 2;
091:
092:            /** Represents a one or more occurence count, '+'. */
093:            public static final short CONTENTSPECNODE_ONE_OR_MORE = 3;
094:
095:            /** Represents choice, '|'. */
096:            public static final short CONTENTSPECNODE_CHOICE = 4;
097:
098:            /** Represents sequence, ','. */
099:            public static final short CONTENTSPECNODE_SEQ = 5;
100:
101:            /** 
102:             * Represents any namespace specified namespace. When the element
103:             * found in the document must belong to a specific namespace, 
104:             * <code>otherValue</code> will contain the name of the namespace.
105:             * If <code>otherValue</code> is <code>-1</code> then the element
106:             * can be from any namespace.
107:             * <p>
108:             * Lists of valid namespaces are created from choice content spec
109:             * nodes that have any content spec nodes as children.
110:             */
111:            public static final short CONTENTSPECNODE_ANY = 6;
112:
113:            /** 
114:             * Represents any other namespace (XML Schema: ##other). 
115:             * <p>
116:             * When the content spec node type is set to CONTENTSPECNODE_ANY_OTHER, 
117:             * <code>value</code> will contain the namespace that <em>cannot</em>
118:             * occur.
119:             */
120:            public static final short CONTENTSPECNODE_ANY_OTHER = 7;
121:
122:            /** Represents any local element (XML Schema: ##local). */
123:            public static final short CONTENTSPECNODE_ANY_LOCAL = 8;
124:
125:            /** prcessContent is 'lax' **/
126:            public static final short CONTENTSPECNODE_ANY_LAX = 22;
127:
128:            public static final short CONTENTSPECNODE_ANY_OTHER_LAX = 23;
129:
130:            public static final short CONTENTSPECNODE_ANY_LOCAL_LAX = 24;
131:
132:            /** processContent is 'skip' **/
133:
134:            public static final short CONTENTSPECNODE_ANY_SKIP = 38;
135:
136:            public static final short CONTENTSPECNODE_ANY_OTHER_SKIP = 39;
137:
138:            public static final short CONTENTSPECNODE_ANY_LOCAL_SKIP = 40;
139:            //
140:            // Data
141:            //
142:
143:            /** 
144:             * The content spec node type. 
145:             *
146:             * @see #CONTENTSPECNODE_LEAF
147:             * @see #CONTENTSPECNODE_ZERO_OR_ONE
148:             * @see #CONTENTSPECNODE_ZERO_OR_MORE
149:             * @see #CONTENTSPECNODE_ONE_OR_MORE
150:             * @see #CONTENTSPECNODE_CHOICE
151:             * @see #CONTENTSPECNODE_SEQ
152:             */
153:            public short type;
154:
155:            /**
156:             * The "left hand" value object of the content spec node.
157:             * leaf name.localpart, single child for unary ops, left child for binary ops.
158:             */
159:            public Object value;
160:
161:            /**
162:             * The "right hand" value of the content spec node.
163:             *  leaf name.uri, right child for binary ops
164:             */
165:            public Object otherValue;
166:
167:            //
168:            // Constructors
169:            //
170:
171:            /** Default constructor. */
172:            public XMLContentSpec() {
173:                clear();
174:            }
175:
176:            /** Constructs a content spec with the specified values. */
177:            public XMLContentSpec(short type, Object value, Object otherValue) {
178:                setValues(type, value, otherValue);
179:            }
180:
181:            /** 
182:             * Constructs a content spec from the values in the specified content spec.
183:             */
184:            public XMLContentSpec(XMLContentSpec contentSpec) {
185:                setValues(contentSpec);
186:            }
187:
188:            /**
189:             * Constructs a content spec from the values specified by the given
190:             * content spec provider and identifier.
191:             */
192:            public XMLContentSpec(XMLContentSpec.Provider provider,
193:                    int contentSpecIndex) {
194:                setValues(provider, contentSpecIndex);
195:            }
196:
197:            //
198:            // Public methods
199:            //
200:
201:            /** Clears the values. */
202:            public void clear() {
203:                type = -1;
204:                value = null;
205:                otherValue = null;
206:            }
207:
208:            /** Sets the values. */
209:            public void setValues(short type, Object value, Object otherValue) {
210:                this .type = type;
211:                this .value = value;
212:                this .otherValue = otherValue;
213:            }
214:
215:            /** Sets the values of the specified content spec. */
216:            public void setValues(XMLContentSpec contentSpec) {
217:                type = contentSpec.type;
218:                value = contentSpec.value;
219:                otherValue = contentSpec.otherValue;
220:            }
221:
222:            /**
223:             * Sets the values from the values specified by the given content spec
224:             * provider and identifier. If the specified content spec cannot be
225:             * provided, the values of this content spec are cleared.
226:             */
227:            public void setValues(XMLContentSpec.Provider provider,
228:                    int contentSpecIndex) {
229:                if (!provider.getContentSpec(contentSpecIndex, this )) {
230:                    clear();
231:                }
232:            }
233:
234:            //
235:            // Object methods
236:            //
237:
238:            /** Returns a hash code for this node. */
239:            public int hashCode() {
240:                return type << 16 | value.hashCode() << 8
241:                        | otherValue.hashCode();
242:            }
243:
244:            /** Returns true if the two objects are equal. */
245:            public boolean equals(Object object) {
246:                if (object != null && object instanceof  XMLContentSpec) {
247:                    XMLContentSpec contentSpec = (XMLContentSpec) object;
248:                    return type == contentSpec.type
249:                            && value == contentSpec.value
250:                            && otherValue == contentSpec.otherValue;
251:                }
252:                return false;
253:            }
254:
255:            //
256:            // Interfaces
257:            //
258:
259:            /**
260:             * Provides a means for walking the structure built out of 
261:             * content spec "nodes". The user of this provider interface is
262:             * responsible for knowing what the content spec node values
263:             * "mean". If those values refer to content spec identifiers,
264:             * then the user can call back into the provider to get the
265:             * next content spec node in the structure.
266:             * 
267:             * @xerces.internal
268:             */
269:            public interface Provider {
270:
271:                //
272:                // XMLContentSpec.Provider methods
273:                //
274:
275:                /**
276:                 * Fills in the provided content spec structure with content spec
277:                 * information for a unique identifier.
278:                 *
279:                 * @param contentSpecIndex The content spec identifier. All content
280:                 *                         spec "nodes" have a unique identifier.
281:                 * @param contentSpec      The content spec struct to fill in with
282:                 *                         the information.
283:                 *
284:                 * @return Returns true if the contentSpecIndex was found.
285:                 */
286:                public boolean getContentSpec(int contentSpecIndex,
287:                        XMLContentSpec contentSpec);
288:
289:            } // interface Provider
290:
291:        } // class XMLContentSpec
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.