Source Code Cross Referenced for AnyType.java in  » XML » saxonb » net » sf » saxon » type » 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 » saxonb » net.sf.saxon.type 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sf.saxon.type;
002:
003:        import net.sf.saxon.expr.Expression;
004:        import net.sf.saxon.expr.StaticContext;
005:        import net.sf.saxon.expr.StaticProperty;
006:        import net.sf.saxon.om.NodeInfo;
007:        import net.sf.saxon.om.SequenceIterator;
008:        import net.sf.saxon.om.SingletonIterator;
009:        import net.sf.saxon.style.StandardNames;
010:        import net.sf.saxon.value.UntypedAtomicValue;
011:        import net.sf.saxon.value.Value;
012:
013:        import java.io.Serializable;
014:
015:        /**
016:         * This class has a singleton instance which represents the XML Schema built-in type xs:anyType,
017:         * also known as the urtype.
018:         */
019:
020:        public final class AnyType implements  ComplexType, Serializable {
021:
022:            private static AnyType theInstance = new AnyType();
023:
024:            /**
025:             * Private constructor
026:             */
027:            private AnyType() {
028:                super ();
029:            }
030:
031:            /**
032:             * Get the singular instance of this class
033:             * @return the singular object representing xs:anyType
034:             */
035:
036:            public static AnyType getInstance() {
037:                return theInstance;
038:            }
039:
040:            /**
041:             * Get the validation status - always valid
042:             */
043:            public int getValidationStatus() {
044:                return VALIDATED;
045:            }
046:
047:            /**
048:             * Get the base type
049:             * @return null (this is the root of the type hierarchy)
050:             */
051:
052:            public SchemaType getBaseType() {
053:                return null;
054:            }
055:
056:            /**
057:             * Returns the base type that this type inherits from. This method can be used to get the
058:             * base type of a type that is known to be valid.
059:             * If this type is a Simpletype that is a built in primitive type then null is returned.
060:             *
061:             * @return the base type.
062:             * @throws IllegalStateException if this type is not valid.
063:             */
064:
065:            public SchemaType getKnownBaseType() throws IllegalStateException {
066:                return null;
067:            }
068:
069:            /**
070:             * Gets the integer code of the derivation method used to derive this type from its
071:             * parent. Returns zero for primitive types.
072:             *
073:             * @return a numeric code representing the derivation method, for example
074:             * {@link SchemaType#DERIVATION_RESTRICTION}
075:             */
076:
077:            public int getDerivationMethod() {
078:                return 0;
079:            }
080:
081:            /**
082:             * Determines whether derivation (of a particular kind)
083:             * from this type is allowed, based on the "final" property
084:             *
085:             * @param derivation the kind of derivation, for example {@link SchemaType#DERIVATION_LIST}
086:             * @return true if this kind of derivation is allowed
087:             */
088:
089:            public boolean allowsDerivation(int derivation) {
090:                return true;
091:            }
092:
093:            /**
094:             * Test whether this ComplexType has been marked as abstract.
095:             * @return false: this class is not abstract.
096:             */
097:
098:            public boolean isAbstract() {
099:                return false;
100:            }
101:
102:            /**
103:             * Test whether this SchemaType is a complex type
104:             *
105:             * @return true if this SchemaType is a complex type
106:             */
107:
108:            public boolean isComplexType() {
109:                return true;
110:            }
111:
112:            /**
113:             * Test whether this SchemaType is a simple type
114:             * @return true if this SchemaType is a simple type
115:             */
116:
117:            public boolean isSimpleType() {
118:                return false;
119:            }
120:
121:            /**
122:             * Returns the value of the 'block' attribute for this type, as a bit-signnificant
123:             * integer with fields such as {@link SchemaType#DERIVATION_LIST} and {@link SchemaType#DERIVATION_EXTENSION}
124:             *
125:             * @return the value of the 'block' attribute for this type
126:             */
127:
128:            public int getBlock() {
129:                return 0;
130:            }
131:
132:            /**
133:             * Test whether this complex type has complex content
134:             * @return true: this complex type has complex content
135:             */
136:            public boolean isComplexContent() {
137:                return true;
138:            }
139:
140:            /**
141:             * Test whether this complex type has simple content
142:             * @return false: this complex type has complex content
143:             */
144:
145:            public boolean isSimpleContent() {
146:                return false;
147:            }
148:
149:            /**
150:             * Test whether this complex type has "all" content, that is, a content model
151:             * using an xs:all compositor
152:             * @return false: this complex type does not use an "all" compositor
153:             */
154:
155:            public boolean isAllContent() {
156:                return false;
157:            }
158:
159:            /**
160:             * For a complex type with simple content, return the simple type of the content.
161:             * Otherwise, return null.
162:             * @return null: this complex type does not have simple content
163:             */
164:
165:            public SimpleType getSimpleContentType() {
166:                return null;
167:            }
168:
169:            /**
170:             * Test whether this complex type is derived by restriction
171:             * @return false: this type is not a restriction
172:             */
173:            public boolean isRestricted() {
174:                return false;
175:            }
176:
177:            /**
178:             * Test whether the content type of this complex type is empty
179:             * @return false: the content model is not empty
180:             */
181:
182:            public boolean isEmptyContent() {
183:                return false;
184:            }
185:
186:            /**
187:             * Test whether the content model of this complexType allows empty content
188:             * @return true: the content is allowed to be empty
189:             */
190:
191:            public boolean isEmptiable() {
192:                return true;
193:            }
194:
195:            /**
196:             * Test whether this complex type allows mixed content
197:             * @return true: mixed content is allowed
198:             */
199:
200:            public boolean isMixedContent() {
201:                return true;
202:            }
203:
204:            /**
205:             * Get the fingerprint of the name of this type
206:             * @return the fingerprint.
207:             */
208:
209:            public int getFingerprint() {
210:                return StandardNames.XS_ANY_TYPE;
211:            }
212:
213:            /**
214:             * Get the namecode of the name of this type. This includes the prefix from the original
215:             * type declaration: in the case of built-in types, there may be a conventional prefix
216:             * or there may be no prefix.
217:             */
218:
219:            public int getNameCode() {
220:                return StandardNames.XS_ANY_TYPE;
221:            }
222:
223:            /**
224:             * Get a description of this type for use in diagnostics
225:             * @return the string "xs:anyType"
226:             */
227:
228:            public String getDescription() {
229:                return "xs:anyType";
230:            }
231:
232:            /**
233:             * Get the display name of the type: that is, a lexical QName with an arbitrary prefix
234:             *
235:             * @return a lexical QName identifying the type
236:             */
237:
238:            public String getDisplayName() {
239:                return "xs:anyType";
240:            }
241:
242:            /**
243:             * Test whether this is the same type as another type. They are considered to be the same type
244:             * if they are derived from the same type definition in the original XML representation (which
245:             * can happen when there are multiple includes of the same file)
246:             */
247:
248:            public boolean isSameType(SchemaType other) {
249:                return (other instanceof  AnyType);
250:            }
251:
252:            /**
253:             * Analyze an expression to see whether the expression is capable of delivering a value of this
254:             * type.
255:             *
256:             @param expression the expression that delivers the content
257:             * @param kind       the node kind whose content is being delivered: {@link net.sf.saxon.type.Type#ELEMENT},
258:             *                   {@link net.sf.saxon.type.Type#ATTRIBUTE}, or {@link net.sf.saxon.type.Type#DOCUMENT}
259:             * @param env
260:
261:             */
262:
263:            public void analyzeContentExpression(Expression expression,
264:                    int kind, StaticContext env) {
265:                return;
266:            }
267:
268:            /**
269:             * Get the typed value of a node that is annotated with this schema type
270:             * @param node the node whose typed value is required
271:             * @return an iterator returning a single untyped atomic value, equivalent to the string value of the node. This
272:             * follows the standard rules for elements with mixed content.
273:             */
274:
275:            public SequenceIterator getTypedValue(NodeInfo node) {
276:                return SingletonIterator.makeIterator(new UntypedAtomicValue(
277:                        node.getStringValue()));
278:            }
279:
280:            /**
281:             * Get the typed value of a node that is annotated with this schema type. The result of this method will always be consistent with the method
282:             * {@link #getTypedValue}. However, this method is often more convenient and may be
283:             * more efficient, especially in the common case where the value is expected to be a singleton.
284:             *
285:             * @param node the node whose typed value is required
286:             * @return the typed value.
287:             * @since 8.5
288:             */
289:
290:            public Value atomize(NodeInfo node) {
291:                return new UntypedAtomicValue(node.getStringValue());
292:            }
293:
294:            /**
295:             * Test whether this complex type subsumes another complex type. The algorithm
296:             * used is as published by Thompson and Tobin, XML Europe 2003.
297:             * @param sub the other type (the type that is derived by restriction, validly or otherwise)
298:             * @return null indicating that this type does indeed subsume the other; or a string indicating
299:             * why it doesn't.
300:             */
301:
302:            public String subsumes(ComplexType sub) {
303:                return null;
304:            }
305:
306:            /**
307:             * Check that this type is validly derived from a given type
308:             *
309:             * @param type  the type from which this type is derived
310:             * @param block the derivations that are blocked by the relevant element declaration
311:             * @throws SchemaException
312:             *          if the derivation is not allowed
313:             */
314:
315:            public void isTypeDerivationOK(SchemaType type, int block)
316:                    throws SchemaException {
317:                throw new SchemaException(
318:                        "Cannot derive xs:anyType from another type");
319:            }
320:
321:            /**
322:             * Find an element particle within this complex type definition having a given element name
323:             * (identified by fingerprint), and return the schema type associated with that element particle.
324:             * If there is no such particle, return null. If the fingerprint matches an element wildcard,
325:             * return the type of the global element declaration with the given name if one exists, or AnyType
326:             * if none exists and lax validation is permitted by the wildcard.
327:             *
328:             * @param fingerprint Identifies the name of the child element within this content model
329:             */
330:
331:            public SchemaType getElementParticleType(int fingerprint) {
332:                return this ;
333:            }
334:
335:            /**
336:             * Find an element particle within this complex type definition having a given element name
337:             * (identified by fingerprint), and return the cardinality associated with that element particle,
338:             * that is, the number of times the element can occur within this complex type. The value is one of
339:             * {@link net.sf.saxon.expr.StaticProperty#EXACTLY_ONE}, {@link net.sf.saxon.expr.StaticProperty#ALLOWS_ZERO_OR_ONE},
340:             * {@link net.sf.saxon.expr.StaticProperty#ALLOWS_ZERO_OR_MORE}, {@link net.sf.saxon.expr.StaticProperty#ALLOWS_ONE_OR_MORE},
341:             * If there is no such particle, return zero.
342:             *
343:             * @param fingerprint Identifies the name of the child element within this content model
344:             */
345:
346:            public int getElementParticleCardinality(int fingerprint) {
347:                return StaticProperty.ALLOWS_ZERO_OR_MORE;
348:            }
349:
350:            /**
351:             * Find an attribute use within this complex type definition having a given attribute name
352:             * (identified by fingerprint), and return the schema type associated with that attribute.
353:             * If there is no such attribute use, return null. If the fingerprint matches an attribute wildcard,
354:             * return the type of the global attribute declaration with the given name if one exists, or AnySimpleType
355:             * if none exists and lax validation is permitted by the wildcard.
356:             *
357:             * @param fingerprint Identifies the name of the child element within this content model
358:             */
359:
360:            public SchemaType getAttributeUseType(int fingerprint) {
361:                return AnySimpleType.getInstance();
362:            }
363:        }
364:
365:        //
366:        // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
367:        // you may not use this file except in compliance with the License. You may obtain a copy of the
368:        // License at http://www.mozilla.org/MPL/
369:        //
370:        // Software distributed under the License is distributed on an "AS IS" basis,
371:        // WITHOUT WARRANTY OF ANY KIND, either express or implied.
372:        // See the License for the specific language governing rights and limitations under the License.
373:        //
374:        // The Original Code is: all this file.
375:        //
376:        // The Initial Developer of the Original Code is Saxonica Limited
377:        //
378:        // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
379:        //
380:        // Contributor(s): none
381:        //
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.