Source Code Cross Referenced for XSComplexTypeDecl.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.impl.dv.XSSimpleType;
021:        import org.apache.xerces.xs.*;
022:        import org.apache.xerces.impl.xs.models.XSCMValidator;
023:        import org.apache.xerces.impl.xs.models.CMBuilder;
024:        import org.apache.xerces.impl.xs.util.XSObjectListImpl;
025:        import org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl;
026:        import org.w3c.dom.TypeInfo;
027:
028:        /**
029:         * The XML representation for a complexType
030:         * schema component is a <complexType> element information item
031:         *
032:         * @xerces.internal 
033:         *
034:         * @author Elena Litani, IBM
035:         * @author Sandy Gao, IBM
036:         * @version $Id: XSComplexTypeDecl.java 573322 2007-09-06 16:48:47Z peterjm $
037:         */
038:        public class XSComplexTypeDecl implements  XSComplexTypeDefinition,
039:                TypeInfo {
040:
041:            // name of the complexType
042:            String fName = null;
043:
044:            // target namespace of the complexType
045:            String fTargetNamespace = null;
046:
047:            // base type of the complexType
048:            XSTypeDefinition fBaseType = null;
049:
050:            // derivation method of the complexType
051:            short fDerivedBy = XSConstants.DERIVATION_RESTRICTION;
052:
053:            // final set of the complexType
054:            short fFinal = XSConstants.DERIVATION_NONE;
055:
056:            // block set (prohibited substitution) of the complexType
057:            short fBlock = XSConstants.DERIVATION_NONE;
058:
059:            // flags: whether is abstract; whether contains ID type;
060:            //        whether it's an anonymous tpye
061:            short fMiscFlags = 0;
062:
063:            // the attribute group that holds the attribute uses and attribute wildcard
064:            XSAttributeGroupDecl fAttrGrp = null;
065:
066:            // the content type of the complexType
067:            short fContentType = CONTENTTYPE_EMPTY;
068:
069:            // if the content type is simple, then the corresponding simpleType
070:            XSSimpleType fXSSimpleType = null;
071:
072:            // if the content type is element or mixed, the particle
073:            XSParticleDecl fParticle = null;
074:
075:            // if there is a particle, the content model corresponding to that particle
076:            XSCMValidator fCMValidator = null;
077:
078:            // the content model that's sufficient for computing UPA
079:            XSCMValidator fUPACMValidator = null;
080:
081:            // list of annotations affiliated with this type
082:            XSObjectListImpl fAnnotations = null;
083:
084:            // DOM Level 3 TypeInfo Derivation Method constants
085:            static final int DERIVATION_ANY = 0;
086:            static final int DERIVATION_RESTRICTION = 1;
087:            static final int DERIVATION_EXTENSION = 2;
088:            static final int DERIVATION_UNION = 4;
089:            static final int DERIVATION_LIST = 8;
090:
091:            public XSComplexTypeDecl() {
092:                // do-nothing constructor for now.
093:            }
094:
095:            public void setValues(String name, String targetNamespace,
096:                    XSTypeDefinition baseType, short derivedBy,
097:                    short schemaFinal, short block, short contentType,
098:                    boolean isAbstract, XSAttributeGroupDecl attrGrp,
099:                    XSSimpleType simpleType, XSParticleDecl particle,
100:                    XSObjectListImpl annotations) {
101:                fTargetNamespace = targetNamespace;
102:                fBaseType = baseType;
103:                fDerivedBy = derivedBy;
104:                fFinal = schemaFinal;
105:                fBlock = block;
106:                fContentType = contentType;
107:                if (isAbstract)
108:                    fMiscFlags |= CT_IS_ABSTRACT;
109:                fAttrGrp = attrGrp;
110:                fXSSimpleType = simpleType;
111:                fParticle = particle;
112:                fAnnotations = annotations;
113:            }
114:
115:            public void setName(String name) {
116:                fName = name;
117:            }
118:
119:            public short getTypeCategory() {
120:                return COMPLEX_TYPE;
121:            }
122:
123:            public String getTypeName() {
124:                return fName;
125:            }
126:
127:            public short getFinalSet() {
128:                return fFinal;
129:            }
130:
131:            public String getTargetNamespace() {
132:                return fTargetNamespace;
133:            }
134:
135:            // flags for the misc flag
136:            private static final short CT_IS_ABSTRACT = 1;
137:            private static final short CT_HAS_TYPE_ID = 2;
138:            private static final short CT_IS_ANONYMOUS = 4;
139:
140:            // methods to get/set misc flag
141:
142:            public boolean containsTypeID() {
143:                return ((fMiscFlags & CT_HAS_TYPE_ID) != 0);
144:            }
145:
146:            public void setIsAbstractType() {
147:                fMiscFlags |= CT_IS_ABSTRACT;
148:            }
149:
150:            public void setContainsTypeID() {
151:                fMiscFlags |= CT_HAS_TYPE_ID;
152:            }
153:
154:            public void setIsAnonymous() {
155:                fMiscFlags |= CT_IS_ANONYMOUS;
156:            }
157:
158:            public XSCMValidator getContentModel(CMBuilder cmBuilder) {
159:                return getContentModel(cmBuilder, false);
160:            }
161:
162:            public synchronized XSCMValidator getContentModel(
163:                    CMBuilder cmBuilder, boolean forUPA) {
164:                if (fCMValidator == null) {
165:                    if (forUPA) {
166:                        if (fUPACMValidator == null) {
167:                            fUPACMValidator = cmBuilder.getContentModel(this ,
168:                                    true);
169:
170:                            if (fUPACMValidator != null
171:                                    && !fUPACMValidator.isCompactedForUPA()) {
172:                                fCMValidator = fUPACMValidator;
173:                            }
174:                        }
175:                        return fUPACMValidator;
176:                    } else {
177:                        fCMValidator = cmBuilder.getContentModel(this , false);
178:                    }
179:                }
180:
181:                return fCMValidator;
182:            }
183:
184:            // some utility methods:
185:
186:            // return the attribute group for this complex type
187:            public XSAttributeGroupDecl getAttrGrp() {
188:                return fAttrGrp;
189:            }
190:
191:            public String toString() {
192:                StringBuffer str = new StringBuffer();
193:                appendTypeInfo(str);
194:                return str.toString();
195:            }
196:
197:            void appendTypeInfo(StringBuffer str) {
198:                String contentType[] = { "EMPTY", "SIMPLE", "ELEMENT", "MIXED" };
199:                String derivedBy[] = { "EMPTY", "EXTENSION", "RESTRICTION" };
200:
201:                str.append("Complex type name='").append(fTargetNamespace)
202:                        .append(",").append(getTypeName()).append("', ");
203:                if (fBaseType != null) {
204:                    str.append(" base type name='").append(fBaseType.getName())
205:                            .append("', ");
206:                }
207:                str.append(" content type='").append(contentType[fContentType])
208:                        .append("', ");
209:                str.append(" isAbstract='").append(getAbstract()).append("', ");
210:                str.append(" hasTypeId='").append(containsTypeID()).append(
211:                        "', ");
212:                str.append(" final='").append(fFinal).append("', ");
213:                str.append(" block='").append(fBlock).append("', ");
214:                if (fParticle != null) {
215:                    str.append(" particle='").append(fParticle.toString())
216:                            .append("', ");
217:                }
218:                str.append(" derivedBy='").append(derivedBy[fDerivedBy])
219:                        .append("'. ");
220:
221:            }
222:
223:            public boolean derivedFromType(XSTypeDefinition ancestor,
224:                    short derivationMethod) {
225:                // ancestor is null, retur false
226:                if (ancestor == null)
227:                    return false;
228:                // ancestor is anyType, return true
229:                if (ancestor == SchemaGrammar.fAnyType)
230:                    return true;
231:                // recursively get base, and compare it with ancestor
232:                XSTypeDefinition type = this ;
233:                while (type != ancestor && // compare with ancestor
234:                        type != SchemaGrammar.fAnySimpleType && // reached anySimpleType
235:                        type != SchemaGrammar.fAnyType) { // reached anyType
236:                    type = type.getBaseType();
237:                }
238:
239:                return type == ancestor;
240:            }
241:
242:            public boolean derivedFrom(String ancestorNS, String ancestorName,
243:                    short derivationMethod) {
244:                // ancestor is null, retur false
245:                if (ancestorName == null)
246:                    return false;
247:                // ancestor is anyType, return true
248:                if (ancestorNS != null
249:                        && ancestorNS.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)
250:                        && ancestorName.equals(SchemaSymbols.ATTVAL_ANYTYPE)) {
251:                    return true;
252:                }
253:
254:                // recursively get base, and compare it with ancestor
255:                XSTypeDefinition type = this ;
256:                while (!(ancestorName.equals(type.getName()) && ((ancestorNS == null && type
257:                        .getNamespace() == null) || (ancestorNS != null && ancestorNS
258:                        .equals(type.getNamespace()))))
259:                        && // compare with ancestor
260:                        type != SchemaGrammar.fAnySimpleType && // reached anySimpleType
261:                        type != SchemaGrammar.fAnyType) { // reached anyType
262:                    type = (XSTypeDefinition) type.getBaseType();
263:                }
264:
265:                return type != SchemaGrammar.fAnySimpleType
266:                        && type != SchemaGrammar.fAnyType;
267:            }
268:
269:            /**
270:             * Checks if a type is derived from another given the the name, namespace
271:             * and derivation method. See:
272:             * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
273:             * 
274:             * @param ancestorNS
275:             *            The namspace of the ancestor type declaration
276:             * @param ancestorName
277:             *            The name of the ancestor type declaration
278:             * @param derivationMethod
279:             *            The derivation method
280:             * 
281:             * @return boolean True if the ancestor type is derived from the reference
282:             *         type by the specifiied derivation method.
283:             */
284:            public boolean isDOMDerivedFrom(String ancestorNS,
285:                    String ancestorName, int derivationMethod) {
286:                // ancestor is null, retur false
287:                if (ancestorName == null)
288:                    return false;
289:
290:                // ancestor is anyType, return true
291:                if (ancestorNS != null
292:                        && ancestorNS.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)
293:                        && ancestorName.equals(SchemaSymbols.ATTVAL_ANYTYPE)
294:                        && (derivationMethod == DERIVATION_RESTRICTION && derivationMethod == DERIVATION_EXTENSION)) {
295:                    return true;
296:                }
297:
298:                // restriction
299:                if ((derivationMethod & DERIVATION_RESTRICTION) != 0) {
300:                    if (isDerivedByRestriction(ancestorNS, ancestorName,
301:                            derivationMethod, this )) {
302:                        return true;
303:                    }
304:                }
305:
306:                // extension
307:                if ((derivationMethod & DERIVATION_EXTENSION) != 0) {
308:                    if (isDerivedByExtension(ancestorNS, ancestorName,
309:                            derivationMethod, this )) {
310:                        return true;
311:                    }
312:                }
313:
314:                // list or union
315:                if ((((derivationMethod & DERIVATION_LIST) != 0) || ((derivationMethod & DERIVATION_UNION) != 0))
316:                        && ((derivationMethod & DERIVATION_RESTRICTION) == 0)
317:                        && ((derivationMethod & DERIVATION_EXTENSION) == 0)) {
318:
319:                    if (ancestorNS.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)
320:                            && ancestorName
321:                                    .equals(SchemaSymbols.ATTVAL_ANYTYPE)) {
322:                        ancestorName = SchemaSymbols.ATTVAL_ANYSIMPLETYPE;
323:                    }
324:
325:                    if (!(fName.equals(SchemaSymbols.ATTVAL_ANYTYPE) && fTargetNamespace
326:                            .equals(SchemaSymbols.URI_SCHEMAFORSCHEMA))) {
327:                        if (fBaseType != null
328:                                && fBaseType instanceof  XSSimpleTypeDecl) {
329:
330:                            return ((XSSimpleTypeDecl) fBaseType)
331:                                    .isDOMDerivedFrom(ancestorNS, ancestorName,
332:                                            derivationMethod);
333:                        } else if (fBaseType != null
334:                                && fBaseType instanceof  XSComplexTypeDecl) {
335:                            return ((XSComplexTypeDecl) fBaseType)
336:                                    .isDOMDerivedFrom(ancestorNS, ancestorName,
337:                                            derivationMethod);
338:                        }
339:                    }
340:                }
341:
342:                // If the value of the parameter is 0 i.e. no bit (corresponding to
343:                // restriction, list, extension or union) is set to 1 for the 
344:                // derivationMethod parameter.   
345:                if (((derivationMethod & DERIVATION_EXTENSION) == 0)
346:                        && (((derivationMethod & DERIVATION_RESTRICTION) == 0)
347:                                && ((derivationMethod & DERIVATION_LIST) == 0) && ((derivationMethod & DERIVATION_UNION) == 0))) {
348:                    return isDerivedByAny(ancestorNS, ancestorName,
349:                            derivationMethod, this );
350:                }
351:
352:                return false;
353:            }
354:
355:            /**
356:             * Checks if a type is derived from another by any combination of
357:             * restriction, list ir union. See:
358:             * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
359:             * 
360:             * @param ancestorNS
361:             *            The namspace of the ancestor type declaration
362:             * @param ancestorName
363:             *            The name of the ancestor type declaration
364:             * @param derivationMethod
365:             *            A short indication the method of derivation
366:             * @param type
367:             *            The reference type definition
368:             * 
369:             * @return boolean True if the type is derived by any method for the
370:             *         reference type
371:             */
372:            private boolean isDerivedByAny(String ancestorNS,
373:                    String ancestorName, int derivationMethod,
374:                    XSTypeDefinition type) {
375:                XSTypeDefinition oldType = null;
376:                boolean derivedFrom = false;
377:                while (type != null && type != oldType) {
378:
379:                    // If the ancestor type is reached or is the same as this type.
380:                    if ((ancestorName.equals(type.getName()))
381:                            && ((ancestorNS == null && type.getNamespace() == null) || (ancestorNS != null && ancestorNS
382:                                    .equals(type.getNamespace())))) {
383:                        derivedFrom = true;
384:                        break;
385:                    }
386:
387:                    // Check if this type is derived from the base by restriction or
388:                    // extension
389:                    if (isDerivedByRestriction(ancestorNS, ancestorName,
390:                            derivationMethod, type)) {
391:                        return true;
392:                    } else if (!isDerivedByExtension(ancestorNS, ancestorName,
393:                            derivationMethod, type)) {
394:                        return true;
395:                    }
396:                    oldType = type;
397:                    type = type.getBaseType();
398:                }
399:
400:                return derivedFrom;
401:            }
402:
403:            /**
404:             * Checks if a type is derived from another by restriction. See:
405:             * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
406:             * 
407:             * @param ancestorNS
408:             *            The namspace of the ancestor type declaration
409:             * @param ancestorName
410:             *            The name of the ancestor type declaration
411:             * @param derivationMethod
412:             *            A short indication the method of derivation *
413:             * @param type
414:             *            The reference type definition
415:             * 
416:             * @return boolean True if the type is derived by restriciton for the
417:             *         reference type
418:             */
419:            private boolean isDerivedByRestriction(String ancestorNS,
420:                    String ancestorName, int derivationMethod,
421:                    XSTypeDefinition type) {
422:
423:                XSTypeDefinition oldType = null;
424:                while (type != null && type != oldType) {
425:
426:                    // ancestor is anySimpleType, return false
427:                    if (ancestorNS != null
428:                            && ancestorNS
429:                                    .equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)
430:                            && ancestorName
431:                                    .equals(SchemaSymbols.ATTVAL_ANYSIMPLETYPE)) {
432:                        return false;
433:                    }
434:
435:                    // if the name and namespace of this type is the same as the
436:                    // ancestor return true
437:                    if ((ancestorName.equals(type.getName()))
438:                            && (ancestorNS != null && ancestorNS.equals(type
439:                                    .getNamespace()))
440:                            || ((type.getNamespace() == null && ancestorNS == null))) {
441:
442:                        return true;
443:                    }
444:
445:                    // If the base type is a complexType with simpleContent
446:                    if (type instanceof  XSSimpleTypeDecl) {
447:                        if (ancestorNS
448:                                .equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)
449:                                && ancestorName
450:                                        .equals(SchemaSymbols.ATTVAL_ANYTYPE)) {
451:                            ancestorName = SchemaSymbols.ATTVAL_ANYSIMPLETYPE;
452:                        }
453:                        return ((XSSimpleTypeDecl) type).isDOMDerivedFrom(
454:                                ancestorNS, ancestorName, derivationMethod);
455:                    } else {
456:                        // If the base type is a complex type
457:                        // Every derivation step till the base type should be
458:                        // restriction. If not return false
459:                        if (((XSComplexTypeDecl) type).getDerivationMethod() != XSConstants.DERIVATION_RESTRICTION) {
460:                            return false;
461:                        }
462:                    }
463:                    oldType = type;
464:                    type = type.getBaseType();
465:
466:                }
467:
468:                return false;
469:            }
470:
471:            /**
472:             * Checks if a type is derived from another by extension. See:
473:             * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
474:             * 
475:             * @param ancestorNS
476:             *            The namspace of the ancestor type declaration
477:             * @param ancestorName
478:             *            The name of the ancestor type declaration
479:             * @param derivationMethod
480:             *            A short indication the method of derivation
481:             * @param type
482:             *            The reference type definition
483:             * 
484:             * @return boolean True if the type is derived by extension for the
485:             *         reference type
486:             */
487:            private boolean isDerivedByExtension(String ancestorNS,
488:                    String ancestorName, int derivationMethod,
489:                    XSTypeDefinition type) {
490:
491:                boolean extension = false;
492:                XSTypeDefinition oldType = null;
493:                while (type != null && type != oldType) {
494:                    // If ancestor is anySimpleType return false.
495:                    if (ancestorNS != null
496:                            && ancestorNS
497:                                    .equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)
498:                            && ancestorName
499:                                    .equals(SchemaSymbols.ATTVAL_ANYSIMPLETYPE)
500:                            && SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(type
501:                                    .getNamespace())
502:                            && SchemaSymbols.ATTVAL_ANYTYPE.equals(type
503:                                    .getName())) {
504:                        break;
505:                    }
506:
507:                    if ((ancestorName.equals(type.getName()))
508:                            && ((ancestorNS == null && type.getNamespace() == null) || (ancestorNS != null && ancestorNS
509:                                    .equals(type.getNamespace())))) {
510:                        // returns true if atleast one derivation step was extension
511:                        return extension;
512:                    }
513:
514:                    // If the base type is a complexType with simpleContent
515:                    if (type instanceof  XSSimpleTypeDecl) {
516:                        if (ancestorNS
517:                                .equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)
518:                                && ancestorName
519:                                        .equals(SchemaSymbols.ATTVAL_ANYTYPE)) {
520:                            ancestorName = SchemaSymbols.ATTVAL_ANYSIMPLETYPE;
521:                        }
522:
523:                        // derivationMethod extension will always return false for a
524:                        // simpleType,
525:                        // we treat it like a restriction
526:                        if ((derivationMethod & DERIVATION_EXTENSION) != 0) {
527:                            return extension
528:                                    & ((XSSimpleTypeDecl) type)
529:                                            .isDOMDerivedFrom(
530:                                                    ancestorNS,
531:                                                    ancestorName,
532:                                                    (derivationMethod & DERIVATION_RESTRICTION));
533:                        } else {
534:                            return extension
535:                                    & ((XSSimpleTypeDecl) type)
536:                                            .isDOMDerivedFrom(ancestorNS,
537:                                                    ancestorName,
538:                                                    derivationMethod);
539:                        }
540:
541:                    } else {
542:                        // If the base type is a complex type
543:                        // At least one derivation step upto the ancestor type should be
544:                        // extension.
545:                        if (((XSComplexTypeDecl) type).getDerivationMethod() == XSConstants.DERIVATION_EXTENSION) {
546:                            extension = extension | true;
547:                        }
548:                    }
549:                    oldType = type;
550:                    type = type.getBaseType();
551:                }
552:
553:                return false;
554:            }
555:
556:            public void reset() {
557:                fName = null;
558:                fTargetNamespace = null;
559:                fBaseType = null;
560:                fDerivedBy = XSConstants.DERIVATION_RESTRICTION;
561:                fFinal = XSConstants.DERIVATION_NONE;
562:                fBlock = XSConstants.DERIVATION_NONE;
563:
564:                fMiscFlags = 0;
565:
566:                // reset attribute group
567:                fAttrGrp.reset();
568:                fContentType = CONTENTTYPE_EMPTY;
569:                fXSSimpleType = null;
570:                fParticle = null;
571:                fCMValidator = null;
572:                fUPACMValidator = null;
573:                if (fAnnotations != null) {
574:                    // help out the garbage collector
575:                    fAnnotations.clear();
576:                }
577:                fAnnotations = null;
578:            }
579:
580:            /**
581:             * Get the type of the object, i.e ELEMENT_DECLARATION.
582:             */
583:            public short getType() {
584:                return XSConstants.TYPE_DEFINITION;
585:            }
586:
587:            /**
588:             * The <code>name</code> of this <code>XSObject</code> depending on the
589:             * <code>XSObject</code> type.
590:             */
591:            public String getName() {
592:                return getAnonymous() ? null : fName;
593:            }
594:
595:            /**
596:             * A boolean that specifies if the type definition is anonymous.
597:             * Convenience attribute. This is a field is not part of
598:             * XML Schema component model.
599:             */
600:            public boolean getAnonymous() {
601:                return ((fMiscFlags & CT_IS_ANONYMOUS) != 0);
602:            }
603:
604:            /**
605:             * The namespace URI of this node, or <code>null</code> if it is
606:             * unspecified.  defines how a namespace URI is attached to schema
607:             * components.
608:             */
609:            public String getNamespace() {
610:                return fTargetNamespace;
611:            }
612:
613:            /**
614:             * {base type definition} Either a simple type definition or a complex
615:             * type definition.
616:             */
617:            public XSTypeDefinition getBaseType() {
618:                return fBaseType;
619:            }
620:
621:            /**
622:             * {derivation method} Either extension or restriction. The valid constant
623:             * value for this <code>XSConstants</code> EXTENTION, RESTRICTION.
624:             */
625:            public short getDerivationMethod() {
626:                return fDerivedBy;
627:            }
628:
629:            /**
630:             * {final} For complex type definition it is a subset of {extension,
631:             * restriction}. For simple type definition it is a subset of
632:             * {extension, list, restriction, union}.
633:             * @param derivation  Extension, restriction, list, union constants
634:             *   (defined in <code>XSConstants</code>).
635:             * @return True if derivation is in the final set, otherwise false.
636:             */
637:            public boolean isFinal(short derivation) {
638:                return (fFinal & derivation) != 0;
639:            }
640:
641:            /**
642:             * {final} For complex type definition it is a subset of {extension, restriction}.
643:             *
644:             * @return A bit flag that represents:
645:             *         {extension, restriction) or none for complexTypes;
646:             *         {extension, list, restriction, union} or none for simpleTypes;
647:             */
648:            public short getFinal() {
649:                return fFinal;
650:            }
651:
652:            /**
653:             * {abstract} A boolean. Complex types for which {abstract} is true must
654:             * not be used as the {type definition} for the validation of element
655:             * information items.
656:             */
657:            public boolean getAbstract() {
658:                return ((fMiscFlags & CT_IS_ABSTRACT) != 0);
659:            }
660:
661:            /**
662:             *  {attribute uses} A set of attribute uses.
663:             */
664:            public XSObjectList getAttributeUses() {
665:                return fAttrGrp.getAttributeUses();
666:            }
667:
668:            /**
669:             * {attribute wildcard} Optional. A wildcard.
670:             */
671:            public XSWildcard getAttributeWildcard() {
672:                return fAttrGrp.getAttributeWildcard();
673:            }
674:
675:            /**
676:             * {content type} One of empty, a simple type definition (see
677:             * <code>simpleType</code>, or mixed, element-only (see
678:             * <code>cmParticle</code>).
679:             */
680:            public short getContentType() {
681:                return fContentType;
682:            }
683:
684:            /**
685:             * A simple type definition corresponding to simple content model,
686:             * otherwise <code>null</code>
687:             */
688:            public XSSimpleTypeDefinition getSimpleType() {
689:                return fXSSimpleType;
690:            }
691:
692:            /**
693:             * A particle for mixed or element-only content model, otherwise
694:             * <code>null</code>
695:             */
696:            public XSParticle getParticle() {
697:                return fParticle;
698:            }
699:
700:            /**
701:             * {prohibited substitutions} A subset of {extension, restriction}.
702:             * @param prohibited  extention or restriction constants (defined in
703:             *   <code>XSConstants</code>).
704:             * @return True if prohibited is a prohibited substitution, otherwise
705:             *   false.
706:             */
707:            public boolean isProhibitedSubstitution(short prohibited) {
708:                return (fBlock & prohibited) != 0;
709:            }
710:
711:            /**
712:             * {prohibited substitutions}
713:             *
714:             * @return A bit flag corresponding to prohibited substitutions
715:             */
716:            public short getProhibitedSubstitutions() {
717:                return fBlock;
718:            }
719:
720:            /**
721:             * Optional. Annotation.
722:             */
723:            public XSObjectList getAnnotations() {
724:                return (fAnnotations != null) ? fAnnotations
725:                        : XSObjectListImpl.EMPTY_LIST;
726:            }
727:
728:            /**
729:             * @see org.apache.xerces.xs.XSObject#getNamespaceItem()
730:             */
731:            public XSNamespaceItem getNamespaceItem() {
732:                // REVISIT: implement
733:                return null;
734:            }
735:
736:            /* (non-Javadoc)
737:             * @see org.apache.xerces.xs.XSComplexTypeDefinition#getAttributeUse(java.lang.String, java.lang.String)
738:             */
739:            public XSAttributeUse getAttributeUse(String namespace, String name) {
740:                return fAttrGrp.getAttributeUse(namespace, name);
741:            }
742:
743:            public String getTypeNamespace() {
744:                return getNamespace();
745:            }
746:
747:            public boolean isDerivedFrom(String typeNamespaceArg,
748:                    String typeNameArg, int derivationMethod) {
749:                return isDOMDerivedFrom(typeNamespaceArg, typeNameArg,
750:                        derivationMethod);
751:            }
752:
753:        } // class XSComplexTypeDecl
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.