Java Code Examples for com.sun.org.apache.xerces.internal.xs.XSTypeDefinition#COMPLEX_TYPE
The following examples show how to use
com.sun.org.apache.xerces.internal.xs.XSTypeDefinition#COMPLEX_TYPE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XSConstraints.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * check whether simple type derived is valid derived from base, * given a subset of {restriction, extension}. */ public static boolean checkSimpleDerivationOk(XSSimpleType derived, XSTypeDefinition base, short block) { // if derived is anySimpleType, then it's valid only if the base // is ur-type if (derived == SchemaGrammar.fAnySimpleType) { return (base == SchemaGrammar.fAnyType || base == SchemaGrammar.fAnySimpleType); } // if base is complex type if (base.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { // if base is anyType, change base to anySimpleType, // otherwise, not valid if (base == SchemaGrammar.fAnyType) base = SchemaGrammar.fAnySimpleType; else return false; } return checkSimpleDerivation((XSSimpleType)derived, (XSSimpleType)base, block); }
Example 2
Source File: XSConstraints.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * check whether simple type derived is valid derived from base, * given a subset of {restriction, extension}. */ public static boolean checkSimpleDerivationOk(XSSimpleType derived, XSTypeDefinition base, short block) { // if derived is anySimpleType, then it's valid only if the base // is ur-type if (derived == SchemaGrammar.fAnySimpleType) { return (base == SchemaGrammar.fAnyType || base == SchemaGrammar.fAnySimpleType); } // if base is complex type if (base.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { // if base is anyType, change base to anySimpleType, // otherwise, not valid if (base == SchemaGrammar.fAnyType) base = SchemaGrammar.fAnySimpleType; else return false; } return checkSimpleDerivation((XSSimpleType)derived, (XSSimpleType)base, block); }
Example 3
Source File: XSConstraints.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * check whether simple type derived is valid derived from base, * given a subset of {restriction, extension}. */ public static boolean checkSimpleDerivationOk(XSSimpleType derived, XSTypeDefinition base, short block) { // if derived is anySimpleType, then it's valid only if the base // is ur-type if (derived == SchemaGrammar.fAnySimpleType) { return (base == SchemaGrammar.fAnyType || base == SchemaGrammar.fAnySimpleType); } // if base is complex type if (base.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { // if base is anyType, change base to anySimpleType, // otherwise, not valid if (base == SchemaGrammar.fAnyType) base = SchemaGrammar.fAnySimpleType; else return false; } return checkSimpleDerivation(derived, (XSSimpleType)base, block); }
Example 4
Source File: XSConstraints.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * check whether derived is valid derived from base, given a subset * of {restriction, extension}.B */ public static boolean checkTypeDerivationOk(XSTypeDefinition derived, XSTypeDefinition base, short block) { // if derived is anyType, then it's valid only if base is anyType too if (derived == SchemaGrammar.fAnyType) return derived == base; // if derived is anySimpleType, then it's valid only if the base // is ur-type if (derived == SchemaGrammar.fAnySimpleType) { return (base == SchemaGrammar.fAnyType || base == SchemaGrammar.fAnySimpleType); } // if derived is simple type if (derived.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) { // if base is complex type if (base.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { // if base is anyType, change base to anySimpleType, // otherwise, not valid if (base == SchemaGrammar.fAnyType) base = SchemaGrammar.fAnySimpleType; else return false; } return checkSimpleDerivation((XSSimpleType)derived, (XSSimpleType)base, block); } else { return checkComplexDerivation((XSComplexTypeDecl)derived, base, block); } }
Example 5
Source File: XSConstraints.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * check whether derived is valid derived from base, given a subset * of {restriction, extension}.B */ public static boolean checkTypeDerivationOk(XSTypeDefinition derived, XSTypeDefinition base, short block) { // if derived is anyType, then it's valid only if base is anyType too if (derived == SchemaGrammar.fAnyType) return derived == base; // if derived is anySimpleType, then it's valid only if the base // is ur-type if (derived == SchemaGrammar.fAnySimpleType) { return (base == SchemaGrammar.fAnyType || base == SchemaGrammar.fAnySimpleType); } // if derived is simple type if (derived.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) { // if base is complex type if (base.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { // if base is anyType, change base to anySimpleType, // otherwise, not valid if (base == SchemaGrammar.fAnyType) base = SchemaGrammar.fAnySimpleType; else return false; } return checkSimpleDerivation((XSSimpleType)derived, (XSSimpleType)base, block); } else { return checkComplexDerivation((XSComplexTypeDecl)derived, base, block); } }
Example 6
Source File: XMLSchemaValidator.java From JDKSourceCode1.8 with MIT License | 5 votes |
public boolean characterData(String data, Augmentations augs) { fSawText = fSawText || data.length() > 0; // REVISIT: this methods basically duplicates implementation of // handleCharacters(). We should be able to reuse some code // if whitespace == -1 skip normalization, because it is a complexType // or a union type. if (fNormalizeData && fWhiteSpace != -1 && fWhiteSpace != XSSimpleType.WS_PRESERVE) { // normalize data normalizeWhitespace(data, fWhiteSpace == XSSimpleType.WS_COLLAPSE); fBuffer.append(fNormalizedStr.ch, fNormalizedStr.offset, fNormalizedStr.length); } else { if (fAppendBuffer) fBuffer.append(data); } // When it's a complex type with element-only content, we need to // find out whether the content contains any non-whitespace character. boolean allWhiteSpace = true; if (fCurrentType != null && fCurrentType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { XSComplexTypeDecl ctype = (XSComplexTypeDecl) fCurrentType; if (ctype.fContentType == XSComplexTypeDecl.CONTENTTYPE_ELEMENT) { // data outside of element content for (int i = 0; i < data.length(); i++) { if (!XMLChar.isSpace(data.charAt(i))) { allWhiteSpace = false; fSawCharacters = true; break; } } } } return allWhiteSpace; }
Example 7
Source File: XSConstraints.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * check whether derived is valid derived from base, given a subset * of {restriction, extension}.B */ public static boolean checkTypeDerivationOk(XSTypeDefinition derived, XSTypeDefinition base, short block) { // if derived is anyType, then it's valid only if base is anyType too if (derived == SchemaGrammar.fAnyType) return derived == base; // if derived is anySimpleType, then it's valid only if the base // is ur-type if (derived == SchemaGrammar.fAnySimpleType) { return (base == SchemaGrammar.fAnyType || base == SchemaGrammar.fAnySimpleType); } // if derived is simple type if (derived.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) { // if base is complex type if (base.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { // if base is anyType, change base to anySimpleType, // otherwise, not valid if (base == SchemaGrammar.fAnyType) base = SchemaGrammar.fAnySimpleType; else return false; } return checkSimpleDerivation((XSSimpleType)derived, (XSSimpleType)base, block); } else { return checkComplexDerivation((XSComplexTypeDecl)derived, base, block); } }
Example 8
Source File: Field.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
protected void handleContent(XSTypeDefinition type, boolean nillable, Object actualValue, short valueType, ShortList itemValueType) { if (type == null || type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE && ((XSComplexTypeDefinition) type).getContentType() != XSComplexTypeDefinition.CONTENTTYPE_SIMPLE) { // the content must be simpleType content fStore.reportError( "cvc-id.3", new Object[] { fIdentityConstraint.getName(), fIdentityConstraint.getElementName()}); } fMatchedString = actualValue; matched(fMatchedString, valueType, itemValueType, nillable); }
Example 9
Source File: Field.java From JDKSourceCode1.8 with MIT License | 5 votes |
protected void handleContent(XSTypeDefinition type, boolean nillable, Object actualValue, short valueType, ShortList itemValueType) { if (type == null || type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE && ((XSComplexTypeDefinition) type).getContentType() != XSComplexTypeDefinition.CONTENTTYPE_SIMPLE) { // the content must be simpleType content fStore.reportError( "cvc-id.3", new Object[] { fIdentityConstraint.getName(), fIdentityConstraint.getElementName()}); } fMatchedString = actualValue; matched(fMatchedString, valueType, itemValueType, nillable); }
Example 10
Source File: SubstitutionGroupHandler.java From Bytecoder with Apache License 2.0 | 4 votes |
private boolean typeDerivationOK(XSTypeDefinition derived, XSTypeDefinition base, short blockingConstraint) { short devMethod = 0, blockConstraint = blockingConstraint; // "derived" should be derived from "base" // add derivation methods of derived types to devMethod; // add block of base types to blockConstraint. XSTypeDefinition type = derived; while (type != base && type != SchemaGrammar.fAnyType) { if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { devMethod |= ((XSComplexTypeDecl)type).fDerivedBy; } else { devMethod |= XSConstants.DERIVATION_RESTRICTION; } type = type.getBaseType(); // type == null means the current type is anySimpleType, // whose base type should be anyType if (type == null) { type = SchemaGrammar.fAnyType; } if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { blockConstraint |= ((XSComplexTypeDecl)type).fBlock; } } if (type != base) { // If the base is a union, check if "derived" is allowed through any of the member types. if (base.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) { XSSimpleTypeDefinition st = (XSSimpleTypeDefinition) base; if (st.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION) { XSObjectList memberTypes = st.getMemberTypes(); final int length = memberTypes.getLength(); for (int i = 0; i < length; ++i) { if (typeDerivationOK(derived, (XSTypeDefinition) memberTypes.item(i), blockingConstraint)) { return true; } } } } return false; } if ((devMethod & blockConstraint) != 0) { return false; } return true; }
Example 11
Source File: SchemaGrammar.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * [schema components]: a list of top-level components, i.e. element * declarations, attribute declarations, etc. * @param objectType The type of the declaration, i.e. * <code>ELEMENT_DECLARATION</code>. Note that * <code>XSTypeDefinition.SIMPLE_TYPE</code> and * <code>XSTypeDefinition.COMPLEX_TYPE</code> can also be used as the * <code>objectType</code> to retrieve only complex types or simple * types, instead of all types. * @return A list of top-level definition of the specified type in * <code>objectType</code> or an empty <code>XSNamedMap</code> if no * such definitions exist. */ public synchronized XSNamedMap getComponents(short objectType) { if (objectType <= 0 || objectType > MAX_COMP_IDX || !GLOBAL_COMP[objectType]) { return XSNamedMapImpl.EMPTY_MAP; } if (fComponents == null) fComponents = new XSNamedMap[MAX_COMP_IDX+1]; // get the hashtable for this type of components if (fComponents[objectType] == null) { SymbolHash table = null; switch (objectType) { case XSConstants.TYPE_DEFINITION: case XSTypeDefinition.COMPLEX_TYPE: case XSTypeDefinition.SIMPLE_TYPE: table = fGlobalTypeDecls; break; case XSConstants.ATTRIBUTE_DECLARATION: table = fGlobalAttrDecls; break; case XSConstants.ELEMENT_DECLARATION: table = fGlobalElemDecls; break; case XSConstants.ATTRIBUTE_GROUP: table = fGlobalAttrGrpDecls; break; case XSConstants.MODEL_GROUP_DEFINITION: table = fGlobalGroupDecls; break; case XSConstants.NOTATION_DECLARATION: table = fGlobalNotationDecls; break; } // for complex/simple types, create a special implementation, // which take specific types out of the hash table if (objectType == XSTypeDefinition.COMPLEX_TYPE || objectType == XSTypeDefinition.SIMPLE_TYPE) { fComponents[objectType] = new XSNamedMap4Types(fTargetNamespace, table, objectType); } else { fComponents[objectType] = new XSNamedMapImpl(fTargetNamespace, table); } } return fComponents[objectType]; }
Example 12
Source File: SchemaGrammar.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * [schema components]: a list of top-level components, i.e. element * declarations, attribute declarations, etc. * @param objectType The type of the declaration, i.e. * <code>ELEMENT_DECLARATION</code>. Note that * <code>XSTypeDefinition.SIMPLE_TYPE</code> and * <code>XSTypeDefinition.COMPLEX_TYPE</code> can also be used as the * <code>objectType</code> to retrieve only complex types or simple * types, instead of all types. * @return A list of top-level definition of the specified type in * <code>objectType</code> or an empty <code>XSNamedMap</code> if no * such definitions exist. */ public synchronized XSNamedMap getComponents(short objectType) { if (objectType <= 0 || objectType > MAX_COMP_IDX || !GLOBAL_COMP[objectType]) { return XSNamedMapImpl.EMPTY_MAP; } if (fComponents == null) fComponents = new XSNamedMap[MAX_COMP_IDX+1]; // get the hashtable for this type of components if (fComponents[objectType] == null) { SymbolHash table = null; switch (objectType) { case XSConstants.TYPE_DEFINITION: case XSTypeDefinition.COMPLEX_TYPE: case XSTypeDefinition.SIMPLE_TYPE: table = fGlobalTypeDecls; break; case XSConstants.ATTRIBUTE_DECLARATION: table = fGlobalAttrDecls; break; case XSConstants.ELEMENT_DECLARATION: table = fGlobalElemDecls; break; case XSConstants.ATTRIBUTE_GROUP: table = fGlobalAttrGrpDecls; break; case XSConstants.MODEL_GROUP_DEFINITION: table = fGlobalGroupDecls; break; case XSConstants.NOTATION_DECLARATION: table = fGlobalNotationDecls; break; } // for complex/simple types, create a special implementation, // which take specific types out of the hash table if (objectType == XSTypeDefinition.COMPLEX_TYPE || objectType == XSTypeDefinition.SIMPLE_TYPE) { fComponents[objectType] = new XSNamedMap4Types(fTargetNamespace, table, objectType); } else { fComponents[objectType] = new XSNamedMapImpl(fTargetNamespace, table); } } return fComponents[objectType]; }
Example 13
Source File: XSModelImpl.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * Convenience method. Returns a list of top-level component declarations * that are defined within the specified namespace, i.e. element * declarations, attribute declarations, etc. * @param objectType The type of the declaration, i.e. * <code>ELEMENT_DECLARATION</code>. * @param namespace The namespace to which the declaration belongs or * <code>null</code> (for components with no target namespace). * @return A list of top-level definitions of the specified type in * <code>objectType</code> and defined in the specified * <code>namespace</code> or an empty <code>XSNamedMap</code>. */ public synchronized XSNamedMap getComponentsByNamespace(short objectType, String namespace) { if (objectType <= 0 || objectType > MAX_COMP_IDX || !GLOBAL_COMP[objectType]) { return XSNamedMapImpl.EMPTY_MAP; } // try to find the grammar int i = 0; if (namespace != null) { for (; i < fGrammarCount; ++i) { if (namespace.equals(fNamespaces[i])) { break; } } } else { for (; i < fGrammarCount; ++i) { if (fNamespaces[i] == null) { break; } } } if (i == fGrammarCount) { return XSNamedMapImpl.EMPTY_MAP; } // get the hashtable for this type of components if (fNSComponents[i][objectType] == null) { SymbolHash table = null; switch (objectType) { case XSConstants.TYPE_DEFINITION: case XSTypeDefinition.COMPLEX_TYPE: case XSTypeDefinition.SIMPLE_TYPE: table = fGrammarList[i].fGlobalTypeDecls; break; case XSConstants.ATTRIBUTE_DECLARATION: table = fGrammarList[i].fGlobalAttrDecls; break; case XSConstants.ELEMENT_DECLARATION: table = fGrammarList[i].fGlobalElemDecls; break; case XSConstants.ATTRIBUTE_GROUP: table = fGrammarList[i].fGlobalAttrGrpDecls; break; case XSConstants.MODEL_GROUP_DEFINITION: table = fGrammarList[i].fGlobalGroupDecls; break; case XSConstants.NOTATION_DECLARATION: table = fGrammarList[i].fGlobalNotationDecls; break; } // for complex/simple types, create a special implementation, // which take specific types out of the hash table if (objectType == XSTypeDefinition.COMPLEX_TYPE || objectType == XSTypeDefinition.SIMPLE_TYPE) { fNSComponents[i][objectType] = new XSNamedMap4Types(namespace, table, objectType); } else { fNSComponents[i][objectType] = new XSNamedMapImpl(namespace, table); } } return fNSComponents[i][objectType]; }
Example 14
Source File: XSConstraints.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * Note: this will be a private method, and it assumes that derived is not * anyType. Another method will be introduced for public use, * which will call this method. */ private static boolean checkComplexDerivation(XSComplexTypeDecl derived, XSTypeDefinition base, short block) { // 2.1 B and D must be the same type definition. if (derived == base) return true; // 1 If B and D are not the same type definition, then the {derivation method} of D must not be in the subset. if ((derived.fDerivedBy & block) != 0) return false; // 2 One of the following must be true: XSTypeDefinition directBase = derived.fBaseType; // 2.2 B must be D's {base type definition}. if (directBase == base) return true; // 2.3 All of the following must be true: // 2.3.1 D's {base type definition} must not be the ur-type definition. if (directBase == SchemaGrammar.fAnyType || directBase == SchemaGrammar.fAnySimpleType) { return false; } // 2.3.2 The appropriate case among the following must be true: // 2.3.2.1 If D's {base type definition} is complex, then it must be validly derived from B given the subset as defined by this constraint. if (directBase.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) return checkComplexDerivation((XSComplexTypeDecl)directBase, base, block); // 2.3.2.2 If D's {base type definition} is simple, then it must be validly derived from B given the subset as defined in Type Derivation OK (Simple) (3.14.6). if (directBase.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) { // if base is complex type if (base.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { // if base is anyType, change base to anySimpleType, // otherwise, not valid if (base == SchemaGrammar.fAnyType) base = SchemaGrammar.fAnySimpleType; else return false; } return checkSimpleDerivation((XSSimpleType)directBase, (XSSimpleType)base, block); } return false; }
Example 15
Source File: SchemaGrammar.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * [schema components]: a list of top-level components, i.e. element * declarations, attribute declarations, etc. * @param objectType The type of the declaration, i.e. * <code>ELEMENT_DECLARATION</code>. Note that * <code>XSTypeDefinition.SIMPLE_TYPE</code> and * <code>XSTypeDefinition.COMPLEX_TYPE</code> can also be used as the * <code>objectType</code> to retrieve only complex types or simple * types, instead of all types. * @return A list of top-level definition of the specified type in * <code>objectType</code> or an empty <code>XSNamedMap</code> if no * such definitions exist. */ public synchronized XSNamedMap getComponents(short objectType) { if (objectType <= 0 || objectType > MAX_COMP_IDX || !GLOBAL_COMP[objectType]) { return XSNamedMapImpl.EMPTY_MAP; } if (fComponents == null) fComponents = new XSNamedMap[MAX_COMP_IDX+1]; // get the hashtable for this type of components if (fComponents[objectType] == null) { SymbolHash table = null; switch (objectType) { case XSConstants.TYPE_DEFINITION: case XSTypeDefinition.COMPLEX_TYPE: case XSTypeDefinition.SIMPLE_TYPE: table = fGlobalTypeDecls; break; case XSConstants.ATTRIBUTE_DECLARATION: table = fGlobalAttrDecls; break; case XSConstants.ELEMENT_DECLARATION: table = fGlobalElemDecls; break; case XSConstants.ATTRIBUTE_GROUP: table = fGlobalAttrGrpDecls; break; case XSConstants.MODEL_GROUP_DEFINITION: table = fGlobalGroupDecls; break; case XSConstants.NOTATION_DECLARATION: table = fGlobalNotationDecls; break; case XSConstants.IDENTITY_CONSTRAINT: table = this.fGlobalIDConstraintDecls; break; } // for complex/simple types, create a special implementation, // which take specific types out of the hash table if (objectType == XSTypeDefinition.COMPLEX_TYPE || objectType == XSTypeDefinition.SIMPLE_TYPE) { fComponents[objectType] = new XSNamedMap4Types(fTargetNamespace, table, objectType); } else { fComponents[objectType] = new XSNamedMapImpl(fTargetNamespace, table); } } return fComponents[objectType]; }
Example 16
Source File: XSModelImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Returns a list of top-level components, i.e. element declarations, * attribute declarations, etc. * @param objectType The type of the declaration, i.e. * <code>ELEMENT_DECLARATION</code>. Note that * <code>XSTypeDefinition.SIMPLE_TYPE</code> and * <code>XSTypeDefinition.COMPLEX_TYPE</code> can also be used as the * <code>objectType</code> to retrieve only complex types or simple * types, instead of all types. * @return A list of top-level definitions of the specified type in * <code>objectType</code> or an empty <code>XSNamedMap</code> if no * such definitions exist. */ public synchronized XSNamedMap getComponents(short objectType) { if (objectType <= 0 || objectType > MAX_COMP_IDX || !GLOBAL_COMP[objectType]) { return XSNamedMapImpl.EMPTY_MAP; } SymbolHash[] tables = new SymbolHash[fGrammarCount]; // get all hashtables from all namespaces for this type of components if (fGlobalComponents[objectType] == null) { for (int i = 0; i < fGrammarCount; i++) { switch (objectType) { case XSConstants.TYPE_DEFINITION: case XSTypeDefinition.COMPLEX_TYPE: case XSTypeDefinition.SIMPLE_TYPE: tables[i] = fGrammarList[i].fGlobalTypeDecls; break; case XSConstants.ATTRIBUTE_DECLARATION: tables[i] = fGrammarList[i].fGlobalAttrDecls; break; case XSConstants.ELEMENT_DECLARATION: tables[i] = fGrammarList[i].fGlobalElemDecls; break; case XSConstants.ATTRIBUTE_GROUP: tables[i] = fGrammarList[i].fGlobalAttrGrpDecls; break; case XSConstants.MODEL_GROUP_DEFINITION: tables[i] = fGrammarList[i].fGlobalGroupDecls; break; case XSConstants.NOTATION_DECLARATION: tables[i] = fGrammarList[i].fGlobalNotationDecls; break; case XSConstants.IDENTITY_CONSTRAINT: tables[i] = fGrammarList[i].fGlobalIDConstraintDecls; break; } } // for complex/simple types, create a special implementation, // which take specific types out of the hash table if (objectType == XSTypeDefinition.COMPLEX_TYPE || objectType == XSTypeDefinition.SIMPLE_TYPE) { fGlobalComponents[objectType] = new XSNamedMap4Types(fNamespaces, tables, fGrammarCount, objectType); } else { fGlobalComponents[objectType] = new XSNamedMapImpl(fNamespaces, tables, fGrammarCount); } } return fGlobalComponents[objectType]; }
Example 17
Source File: SchemaGrammar.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * [schema components]: a list of top-level components, i.e. element * declarations, attribute declarations, etc. * @param objectType The type of the declaration, i.e. * <code>ELEMENT_DECLARATION</code>. Note that * <code>XSTypeDefinition.SIMPLE_TYPE</code> and * <code>XSTypeDefinition.COMPLEX_TYPE</code> can also be used as the * <code>objectType</code> to retrieve only complex types or simple * types, instead of all types. * @return A list of top-level definition of the specified type in * <code>objectType</code> or an empty <code>XSNamedMap</code> if no * such definitions exist. */ public synchronized XSNamedMap getComponents(short objectType) { if (objectType <= 0 || objectType > MAX_COMP_IDX || !GLOBAL_COMP[objectType]) { return XSNamedMapImpl.EMPTY_MAP; } if (fComponents == null) fComponents = new XSNamedMap[MAX_COMP_IDX+1]; // get the hashtable for this type of components if (fComponents[objectType] == null) { SymbolHash table = null; switch (objectType) { case XSConstants.TYPE_DEFINITION: case XSTypeDefinition.COMPLEX_TYPE: case XSTypeDefinition.SIMPLE_TYPE: table = fGlobalTypeDecls; break; case XSConstants.ATTRIBUTE_DECLARATION: table = fGlobalAttrDecls; break; case XSConstants.ELEMENT_DECLARATION: table = fGlobalElemDecls; break; case XSConstants.ATTRIBUTE_GROUP: table = fGlobalAttrGrpDecls; break; case XSConstants.MODEL_GROUP_DEFINITION: table = fGlobalGroupDecls; break; case XSConstants.NOTATION_DECLARATION: table = fGlobalNotationDecls; break; } // for complex/simple types, create a special implementation, // which take specific types out of the hash table if (objectType == XSTypeDefinition.COMPLEX_TYPE || objectType == XSTypeDefinition.SIMPLE_TYPE) { fComponents[objectType] = new XSNamedMap4Types(fTargetNamespace, table, objectType); } else { fComponents[objectType] = new XSNamedMapImpl(fTargetNamespace, table); } } return fComponents[objectType]; }
Example 18
Source File: SubstitutionGroupHandler.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
private boolean typeDerivationOK(XSTypeDefinition derived, XSTypeDefinition base, short blockingConstraint) { short devMethod = 0, blockConstraint = blockingConstraint; // "derived" should be derived from "base" // add derivation methods of derived types to devMethod; // add block of base types to blockConstraint. XSTypeDefinition type = derived; while (type != base && type != SchemaGrammar.fAnyType) { if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { devMethod |= ((XSComplexTypeDecl)type).fDerivedBy; } else { devMethod |= XSConstants.DERIVATION_RESTRICTION; } type = type.getBaseType(); // type == null means the current type is anySimpleType, // whose base type should be anyType if (type == null) { type = SchemaGrammar.fAnyType; } if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { blockConstraint |= ((XSComplexTypeDecl)type).fBlock; } } if (type != base) { // If the base is a union, check if "derived" is allowed through any of the member types. if (base.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) { XSSimpleTypeDefinition st = (XSSimpleTypeDefinition) base; if (st.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION) { XSObjectList memberTypes = st.getMemberTypes(); final int length = memberTypes.getLength(); for (int i = 0; i < length; ++i) { if (typeDerivationOK(derived, (XSTypeDefinition) memberTypes.item(i), blockingConstraint)) { return true; } } } } return false; } if ((devMethod & blockConstraint) != 0) { return false; } return true; }
Example 19
Source File: SubstitutionGroupHandler.java From JDKSourceCode1.8 with MIT License | 4 votes |
private boolean typeDerivationOK(XSTypeDefinition derived, XSTypeDefinition base, short blockingConstraint) { short devMethod = 0, blockConstraint = blockingConstraint; // "derived" should be derived from "base" // add derivation methods of derived types to devMethod; // add block of base types to blockConstraint. XSTypeDefinition type = derived; while (type != base && type != SchemaGrammar.fAnyType) { if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { devMethod |= ((XSComplexTypeDecl)type).fDerivedBy; } else { devMethod |= XSConstants.DERIVATION_RESTRICTION; } type = type.getBaseType(); // type == null means the current type is anySimpleType, // whose base type should be anyType if (type == null) { type = SchemaGrammar.fAnyType; } if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { blockConstraint |= ((XSComplexTypeDecl)type).fBlock; } } if (type != base) { // If the base is a union, check if "derived" is allowed through any of the member types. if (base.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) { XSSimpleTypeDefinition st = (XSSimpleTypeDefinition) base; if (st.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION) { XSObjectList memberTypes = st.getMemberTypes(); final int length = memberTypes.getLength(); for (int i = 0; i < length; ++i) { if (typeDerivationOK(derived, (XSTypeDefinition) memberTypes.item(i), blockingConstraint)) { return true; } } } } return false; } if ((devMethod & blockConstraint) != 0) { return false; } return true; }
Example 20
Source File: SchemaGrammar.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * [schema components]: a list of top-level components, i.e. element * declarations, attribute declarations, etc. * @param objectType The type of the declaration, i.e. * <code>ELEMENT_DECLARATION</code>. Note that * <code>XSTypeDefinition.SIMPLE_TYPE</code> and * <code>XSTypeDefinition.COMPLEX_TYPE</code> can also be used as the * <code>objectType</code> to retrieve only complex types or simple * types, instead of all types. * @return A list of top-level definition of the specified type in * <code>objectType</code> or an empty <code>XSNamedMap</code> if no * such definitions exist. */ public synchronized XSNamedMap getComponents(short objectType) { if (objectType <= 0 || objectType > MAX_COMP_IDX || !GLOBAL_COMP[objectType]) { return XSNamedMapImpl.EMPTY_MAP; } if (fComponents == null) fComponents = new XSNamedMap[MAX_COMP_IDX+1]; // get the hashtable for this type of components if (fComponents[objectType] == null) { SymbolHash table = null; switch (objectType) { case XSConstants.TYPE_DEFINITION: case XSTypeDefinition.COMPLEX_TYPE: case XSTypeDefinition.SIMPLE_TYPE: table = fGlobalTypeDecls; break; case XSConstants.ATTRIBUTE_DECLARATION: table = fGlobalAttrDecls; break; case XSConstants.ELEMENT_DECLARATION: table = fGlobalElemDecls; break; case XSConstants.ATTRIBUTE_GROUP: table = fGlobalAttrGrpDecls; break; case XSConstants.MODEL_GROUP_DEFINITION: table = fGlobalGroupDecls; break; case XSConstants.NOTATION_DECLARATION: table = fGlobalNotationDecls; break; } // for complex/simple types, create a special implementation, // which take specific types out of the hash table if (objectType == XSTypeDefinition.COMPLEX_TYPE || objectType == XSTypeDefinition.SIMPLE_TYPE) { fComponents[objectType] = new XSNamedMap4Types(fTargetNamespace, table, objectType); } else { fComponents[objectType] = new XSNamedMapImpl(fTargetNamespace, table); } } return fComponents[objectType]; }