com.sun.org.apache.xerces.internal.util.SymbolHash Java Examples

The following examples show how to use com.sun.org.apache.xerces.internal.util.SymbolHash. 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: XSModelImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private SymbolHash buildSubGroups_Org() {
    SubstitutionGroupHandler sgHandler = new SubstitutionGroupHandler(null);
    for (int i = 0 ; i < fGrammarCount; i++) {
        sgHandler.addSubstitutionGroup(fGrammarList[i].getSubstitutionGroups());
    }

    final XSNamedMap elements = getComponents(XSConstants.ELEMENT_DECLARATION);
    final int len = elements.getLength();
    final SymbolHash subGroupMap = new SymbolHash(len*2);
    XSElementDecl head;
    XSElementDeclaration[] subGroup;
    for (int i = 0; i < len; i++) {
        head = (XSElementDecl)elements.item(i);
        subGroup = sgHandler.getSubstitutionGroup(head);
        subGroupMap.put(head, subGroup.length > 0 ?
                new XSObjectListImpl(subGroup, subGroup.length) : XSObjectListImpl.EMPTY_LIST);
    }
    return subGroupMap;
}
 
Example #2
Source File: AbstractSAXParser.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Notifies of the presence of the DOCTYPE line in the document.
 *
 * @param rootElement The name of the root element.
 * @param publicId    The public identifier if an external DTD or null
 *                    if the external DTD is specified using SYSTEM.
 * @param systemId    The system identifier if an external DTD, null
 *                    otherwise.
 * @param augs     Additional information that may include infoset augmentations
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void doctypeDecl(String rootElement,
                        String publicId, String systemId, Augmentations augs)
    throws XNIException {
    fInDTD = true;

    try {
        // SAX2 extension
        if (fLexicalHandler != null) {
            fLexicalHandler.startDTD(rootElement, publicId, systemId);
        }
    }
    catch (SAXException e) {
        throw new XNIException(e);
    }

    // is there a DeclHandler?
    if(fDeclHandler != null) {
        fDeclaredAttrs = new SymbolHash();
    }

}
 
Example #3
Source File: XSConstraints.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void findElemInTable(XSComplexTypeDecl type, XSElementDecl elem,
        SymbolHash elemDeclHash)
    throws XMLSchemaException {

    // How can we avoid this concat?  LM.
    String name = elem.fName + "," + elem.fTargetNamespace;

    XSElementDecl existingElem = null;
    if ((existingElem = (XSElementDecl)(elemDeclHash.get(name))) == null) {
        // just add it in
        elemDeclHash.put(name, elem);
    }
    else {
        // If this is the same check element, we're O.K.
        if (elem == existingElem)
            return;

        if (elem.fType != existingElem.fType) {
            // Types are not the same
            throw new XMLSchemaException("cos-element-consistent",
                    new Object[] {type.fName, elem.fName});

        }
    }
}
 
Example #4
Source File: XSModelImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private XSObjectListImpl getGlobalElements() {
    final SymbolHash[] tables = new SymbolHash[fGrammarCount];
    int length = 0;

    for (int i = 0; i < fGrammarCount; i++) {
        tables[i] = fGrammarList[i].fAllGlobalElemDecls;
        length += tables[i].getLength();
    }

    if (length == 0) {
        return XSObjectListImpl.EMPTY_LIST;
    }

    final XSObject[] components = new XSObject[length];

    int start = 0;
    for (int i = 0; i < fGrammarCount; i++) {
        tables[i].getValues(components, start);
        start += tables[i].getLength();
    }

    return new XSObjectListImpl(components, length);
}
 
Example #5
Source File: XSModelImpl.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private SymbolHash buildSubGroups() {
    SubstitutionGroupHandler sgHandler = new SubstitutionGroupHandler(null);
    for (int i = 0 ; i < fGrammarCount; i++) {
        sgHandler.addSubstitutionGroup(fGrammarList[i].getSubstitutionGroups());
    }

    final XSObjectListImpl elements = getGlobalElements();
    final int len = elements.getLength();
    final SymbolHash subGroupMap = new SymbolHash(len*2);
    XSElementDecl head;
    XSElementDeclaration[] subGroup;
    for (int i = 0; i < len; i++) {
        head = (XSElementDecl)elements.item(i);
        subGroup = sgHandler.getSubstitutionGroup(head);
        subGroupMap.put(head, subGroup.length > 0 ?
                new XSObjectListImpl(subGroup, subGroup.length) : XSObjectListImpl.EMPTY_LIST);
    }
    return subGroupMap;
}
 
Example #6
Source File: XSConstraints.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public static void findElemInTable(XSComplexTypeDecl type, XSElementDecl elem,
        SymbolHash elemDeclHash)
    throws XMLSchemaException {

    // How can we avoid this concat?  LM.
    String name = elem.fName + "," + elem.fTargetNamespace;

    XSElementDecl existingElem = null;
    if ((existingElem = (XSElementDecl)(elemDeclHash.get(name))) == null) {
        // just add it in
        elemDeclHash.put(name, elem);
    }
    else {
        // If this is the same check element, we're O.K.
        if (elem == existingElem)
            return;

        if (elem.fType != existingElem.fType) {
            // Types are not the same
            throw new XMLSchemaException("cos-element-consistent",
                    new Object[] {type.fName, elem.fName});

        }
    }
}
 
Example #7
Source File: XSConstraints.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public static void findElemInTable(XSComplexTypeDecl type, XSElementDecl elem,
        SymbolHash elemDeclHash)
    throws XMLSchemaException {

    // How can we avoid this concat?  LM.
    String name = elem.fName + "," + elem.fTargetNamespace;

    XSElementDecl existingElem = null;
    if ((existingElem = (XSElementDecl)(elemDeclHash.get(name))) == null) {
        // just add it in
        elemDeclHash.put(name, elem);
    }
    else {
        // If this is the same check element, we're O.K.
        if (elem == existingElem)
            return;

        if (elem.fType != existingElem.fType) {
            // Types are not the same
            throw new XMLSchemaException("cos-element-consistent",
                    new Object[] {type.fName, elem.fName});

        }
    }
}
 
Example #8
Source File: XSModelImpl.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private SymbolHash buildSubGroups_Org() {
    SubstitutionGroupHandler sgHandler = new SubstitutionGroupHandler(null);
    for (int i = 0 ; i < fGrammarCount; i++) {
        sgHandler.addSubstitutionGroup(fGrammarList[i].getSubstitutionGroups());
    }

    final XSNamedMap elements = getComponents(XSConstants.ELEMENT_DECLARATION);
    final int len = elements.getLength();
    final SymbolHash subGroupMap = new SymbolHash(len*2);
    XSElementDecl head;
    XSElementDeclaration[] subGroup;
    for (int i = 0; i < len; i++) {
        head = (XSElementDecl)elements.item(i);
        subGroup = sgHandler.getSubstitutionGroup(head);
        subGroupMap.put(head, subGroup.length > 0 ?
                new XSObjectListImpl(subGroup, subGroup.length) : XSObjectListImpl.EMPTY_LIST);
    }
    return subGroupMap;
}
 
Example #9
Source File: XSModelImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private SymbolHash buildSubGroups() {
    SubstitutionGroupHandler sgHandler = new SubstitutionGroupHandler(null);
    for (int i = 0 ; i < fGrammarCount; i++) {
        sgHandler.addSubstitutionGroup(fGrammarList[i].getSubstitutionGroups());
    }

    final XSObjectListImpl elements = getGlobalElements();
    final int len = elements.getLength();
    final SymbolHash subGroupMap = new SymbolHash(len*2);
    XSElementDecl head;
    XSElementDeclaration[] subGroup;
    for (int i = 0; i < len; i++) {
        head = (XSElementDecl)elements.item(i);
        subGroup = sgHandler.getSubstitutionGroup(head);
        subGroupMap.put(head, subGroup.length > 0 ?
                new XSObjectListImpl(subGroup, subGroup.length) : XSObjectListImpl.EMPTY_LIST);
    }
    return subGroupMap;
}
 
Example #10
Source File: AbstractSAXParser.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Notifies of the presence of the DOCTYPE line in the document.
 *
 * @param rootElement The name of the root element.
 * @param publicId    The public identifier if an external DTD or null
 *                    if the external DTD is specified using SYSTEM.
 * @param systemId    The system identifier if an external DTD, null
 *                    otherwise.
 * @param augs     Additional information that may include infoset augmentations
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void doctypeDecl(String rootElement,
                        String publicId, String systemId, Augmentations augs)
    throws XNIException {
    fInDTD = true;

    try {
        // SAX2 extension
        if (fLexicalHandler != null) {
            fLexicalHandler.startDTD(rootElement, publicId, systemId);
        }
    }
    catch (SAXException e) {
        throw new XNIException(e);
    }

    // is there a DeclHandler?
    if(fDeclHandler != null) {
        fDeclaredAttrs = new SymbolHash();
    }

}
 
Example #11
Source File: XSModelImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private SymbolHash buildSubGroups() {
    SubstitutionGroupHandler sgHandler = new SubstitutionGroupHandler(null);
    for (int i = 0 ; i < fGrammarCount; i++) {
        sgHandler.addSubstitutionGroup(fGrammarList[i].getSubstitutionGroups());
    }

    final XSObjectListImpl elements = getGlobalElements();
    final int len = elements.getLength();
    final SymbolHash subGroupMap = new SymbolHash(len*2);
    XSElementDecl head;
    XSElementDeclaration[] subGroup;
    for (int i = 0; i < len; i++) {
        head = (XSElementDecl)elements.item(i);
        subGroup = sgHandler.getSubstitutionGroup(head);
        subGroupMap.put(head, subGroup.length > 0 ?
                new XSObjectListImpl(subGroup, subGroup.length) : XSObjectListImpl.EMPTY_LIST);
    }
    return subGroupMap;
}
 
Example #12
Source File: XSConstraints.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void findElemInTable(XSComplexTypeDecl type, XSElementDecl elem,
        SymbolHash elemDeclHash)
    throws XMLSchemaException {

    // How can we avoid this concat?  LM.
    String name = elem.fName + "," + elem.fTargetNamespace;

    XSElementDecl existingElem = null;
    if ((existingElem = (XSElementDecl)(elemDeclHash.get(name))) == null) {
        // just add it in
        elemDeclHash.put(name, elem);
    }
    else {
        // If this is the same check element, we're O.K.
        if (elem == existingElem)
            return;

        if (elem.fType != existingElem.fType) {
            // Types are not the same
            throw new XMLSchemaException("cos-element-consistent",
                    new Object[] {type.fName, elem.fName});

        }
    }
}
 
Example #13
Source File: AbstractSAXParser.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Notifies of the presence of the DOCTYPE line in the document.
 *
 * @param rootElement The name of the root element.
 * @param publicId    The public identifier if an external DTD or null
 *                    if the external DTD is specified using SYSTEM.
 * @param systemId    The system identifier if an external DTD, null
 *                    otherwise.
 * @param augs     Additional information that may include infoset augmentations
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void doctypeDecl(String rootElement,
                        String publicId, String systemId, Augmentations augs)
    throws XNIException {
    fInDTD = true;

    try {
        // SAX2 extension
        if (fLexicalHandler != null) {
            fLexicalHandler.startDTD(rootElement, publicId, systemId);
        }
    }
    catch (SAXException e) {
        throw new XNIException(e);
    }

    // is there a DeclHandler?
    if(fDeclHandler != null) {
        fDeclaredAttrs = new SymbolHash();
    }

}
 
Example #14
Source File: XSModelImpl.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
private SymbolHash buildSubGroups_Org() {
    SubstitutionGroupHandler sgHandler = new SubstitutionGroupHandler(null);
    for (int i = 0 ; i < fGrammarCount; i++) {
        sgHandler.addSubstitutionGroup(fGrammarList[i].getSubstitutionGroups());
    }

    final XSNamedMap elements = getComponents(XSConstants.ELEMENT_DECLARATION);
    final int len = elements.getLength();
    final SymbolHash subGroupMap = new SymbolHash(len*2);
    XSElementDecl head;
    XSElementDeclaration[] subGroup;
    for (int i = 0; i < len; i++) {
        head = (XSElementDecl)elements.item(i);
        subGroup = sgHandler.getSubstitutionGroup(head);
        subGroupMap.put(head, subGroup.length > 0 ?
                new XSObjectListImpl(subGroup, subGroup.length) : XSObjectListImpl.EMPTY_LIST);
    }
    return subGroupMap;
}
 
Example #15
Source File: XSConstraints.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void findElemInTable(XSComplexTypeDecl type, XSElementDecl elem,
        SymbolHash elemDeclHash)
    throws XMLSchemaException {

    // How can we avoid this concat?  LM.
    String name = elem.fName + "," + elem.fTargetNamespace;

    XSElementDecl existingElem = null;
    if ((existingElem = (XSElementDecl)(elemDeclHash.get(name))) == null) {
        // just add it in
        elemDeclHash.put(name, elem);
    }
    else {
        // If this is the same check element, we're O.K.
        if (elem == existingElem)
            return;

        if (elem.fType != existingElem.fType) {
            // Types are not the same
            throw new XMLSchemaException("cos-element-consistent",
                    new Object[] {type.fName, elem.fName});

        }
    }
}
 
Example #16
Source File: XSModelImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private SymbolHash buildSubGroups() {
    SubstitutionGroupHandler sgHandler = new SubstitutionGroupHandler(null);
    for (int i = 0 ; i < fGrammarCount; i++) {
        sgHandler.addSubstitutionGroup(fGrammarList[i].getSubstitutionGroups());
    }

    final XSObjectListImpl elements = getGlobalElements();
    final int len = elements.getLength();
    final SymbolHash subGroupMap = new SymbolHash(len*2);
    XSElementDecl head;
    XSElementDeclaration[] subGroup;
    for (int i = 0; i < len; i++) {
        head = (XSElementDecl)elements.item(i);
        subGroup = sgHandler.getSubstitutionGroup(head);
        subGroupMap.put(head, subGroup.length > 0 ?
                new XSObjectListImpl(subGroup, subGroup.length) : XSObjectListImpl.EMPTY_LIST);
    }
    return subGroupMap;
}
 
Example #17
Source File: XSModelImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private SymbolHash buildSubGroups_Org() {
    SubstitutionGroupHandler sgHandler = new SubstitutionGroupHandler(null);
    for (int i = 0 ; i < fGrammarCount; i++) {
        sgHandler.addSubstitutionGroup(fGrammarList[i].getSubstitutionGroups());
    }

    final XSNamedMap elements = getComponents(XSConstants.ELEMENT_DECLARATION);
    final int len = elements.getLength();
    final SymbolHash subGroupMap = new SymbolHash(len*2);
    XSElementDecl head;
    XSElementDeclaration[] subGroup;
    for (int i = 0; i < len; i++) {
        head = (XSElementDecl)elements.item(i);
        subGroup = sgHandler.getSubstitutionGroup(head);
        subGroupMap.put(head, subGroup.length > 0 ?
                new XSObjectListImpl(subGroup, subGroup.length) : XSObjectListImpl.EMPTY_LIST);
    }
    return subGroupMap;
}
 
Example #18
Source File: XSModelImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private XSObjectListImpl getGlobalElements() {
    final SymbolHash[] tables = new SymbolHash[fGrammarCount];
    int length = 0;

    for (int i = 0; i < fGrammarCount; i++) {
        tables[i] = fGrammarList[i].fAllGlobalElemDecls;
        length += tables[i].getLength();
    }

    if (length == 0) {
        return XSObjectListImpl.EMPTY_LIST;
    }

    final XSObject[] components = new XSObject[length];

    int start = 0;
    for (int i = 0; i < fGrammarCount; i++) {
        tables[i].getValues(components, start);
        start += tables[i].getLength();
    }

    return new XSObjectListImpl(components, length);
}
 
Example #19
Source File: XSModelImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private XSObjectListImpl getGlobalElements() {
    final SymbolHash[] tables = new SymbolHash[fGrammarCount];
    int length = 0;

    for (int i = 0; i < fGrammarCount; i++) {
        tables[i] = fGrammarList[i].fAllGlobalElemDecls;
        length += tables[i].getLength();
    }

    if (length == 0) {
        return XSObjectListImpl.EMPTY_LIST;
    }

    final XSObject[] components = new XSObject[length];

    int start = 0;
    for (int i = 0; i < fGrammarCount; i++) {
        tables[i].getValues(components, start);
        start += tables[i].getLength();
    }

    return new XSObjectListImpl(components, length);
}
 
Example #20
Source File: XSConstraints.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void checkElementDeclsConsistent(XSComplexTypeDecl type,
        XSParticleDecl particle,
        SymbolHash elemDeclHash,
        SubstitutionGroupHandler sgHandler)
    throws XMLSchemaException {

    // check for elements in the tree with the same name and namespace

    int pType = particle.fType;

    if (pType == XSParticleDecl.PARTICLE_WILDCARD)
        return;

    if (pType == XSParticleDecl.PARTICLE_ELEMENT) {
        XSElementDecl elem = (XSElementDecl)(particle.fValue);
        findElemInTable(type, elem, elemDeclHash);

        if (elem.fScope == XSConstants.SCOPE_GLOBAL) {
            // Check for subsitution groups.
            XSElementDecl[] subGroup = sgHandler.getSubstitutionGroup(elem);
            for (int i = 0; i < subGroup.length; i++) {
                findElemInTable(type, subGroup[i], elemDeclHash);
            }
        }
        return;
    }

    XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
    for (int i = 0; i < group.fParticleCount; i++)
        checkElementDeclsConsistent(type, group.fParticles[i], elemDeclHash, sgHandler);
}
 
Example #21
Source File: XSConstraints.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public static void checkElementDeclsConsistent(XSComplexTypeDecl type,
        XSParticleDecl particle,
        SymbolHash elemDeclHash,
        SubstitutionGroupHandler sgHandler)
    throws XMLSchemaException {

    // check for elements in the tree with the same name and namespace

    int pType = particle.fType;

    if (pType == XSParticleDecl.PARTICLE_WILDCARD)
        return;

    if (pType == XSParticleDecl.PARTICLE_ELEMENT) {
        XSElementDecl elem = (XSElementDecl)(particle.fValue);
        findElemInTable(type, elem, elemDeclHash);

        if (elem.fScope == XSConstants.SCOPE_GLOBAL) {
            // Check for subsitution groups.
            XSElementDecl[] subGroup = sgHandler.getSubstitutionGroup(elem);
            for (int i = 0; i < subGroup.length; i++) {
                findElemInTable(type, subGroup[i], elemDeclHash);
            }
        }
        return;
    }

    XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
    for (int i = 0; i < group.fParticleCount; i++)
        checkElementDeclsConsistent(type, group.fParticles[i], elemDeclHash, sgHandler);
}
 
Example #22
Source File: XSConstraints.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public static void checkElementDeclsConsistent(XSComplexTypeDecl type,
        XSParticleDecl particle,
        SymbolHash elemDeclHash,
        SubstitutionGroupHandler sgHandler)
    throws XMLSchemaException {

    // check for elements in the tree with the same name and namespace

    int pType = particle.fType;

    if (pType == XSParticleDecl.PARTICLE_WILDCARD)
        return;

    if (pType == XSParticleDecl.PARTICLE_ELEMENT) {
        XSElementDecl elem = (XSElementDecl)(particle.fValue);
        findElemInTable(type, elem, elemDeclHash);

        if (elem.fScope == XSConstants.SCOPE_GLOBAL) {
            // Check for subsitution groups.
            XSElementDecl[] subGroup = sgHandler.getSubstitutionGroup(elem);
            for (int i = 0; i < subGroup.length; i++) {
                findElemInTable(type, subGroup[i], elemDeclHash);
            }
        }
        return;
    }

    XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
    for (int i = 0; i < group.fParticleCount; i++)
        checkElementDeclsConsistent(type, group.fParticles[i], elemDeclHash, sgHandler);
}
 
Example #23
Source File: XSConstraints.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void checkElementDeclsConsistent(XSComplexTypeDecl type,
        XSParticleDecl particle,
        SymbolHash elemDeclHash,
        SubstitutionGroupHandler sgHandler)
    throws XMLSchemaException {

    // check for elements in the tree with the same name and namespace

    int pType = particle.fType;

    if (pType == XSParticleDecl.PARTICLE_WILDCARD)
        return;

    if (pType == XSParticleDecl.PARTICLE_ELEMENT) {
        XSElementDecl elem = (XSElementDecl)(particle.fValue);
        findElemInTable(type, elem, elemDeclHash);

        if (elem.fScope == XSConstants.SCOPE_GLOBAL) {
            // Check for subsitution groups.
            XSElementDecl[] subGroup = sgHandler.getSubstitutionGroup(elem);
            for (int i = 0; i < subGroup.length; i++) {
                findElemInTable(type, subGroup[i], elemDeclHash);
            }
        }
        return;
    }

    XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
    for (int i = 0; i < group.fParticleCount; i++)
        checkElementDeclsConsistent(type, group.fParticles[i], elemDeclHash, sgHandler);
}
 
Example #24
Source File: SchemaGrammar.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * [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 #25
Source File: FullDVFactory.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
static void createBuiltInTypes(SymbolHash types) {
    // create base types first
    BaseDVFactory.createBuiltInTypes(types);

    // full schema simple type names
    final String DOUBLE            = "double";
    final String DURATION          = "duration";
    final String ENTITY            = "ENTITY";
    final String ENTITIES          = "ENTITIES";
    final String FLOAT             = "float";
    final String HEXBINARY         = "hexBinary";
    final String ID                = "ID";
    final String IDREF             = "IDREF";
    final String IDREFS            = "IDREFS";
    final String NAME              = "Name";
    final String NCNAME            = "NCName";
    final String NMTOKEN           = "NMTOKEN";
    final String NMTOKENS          = "NMTOKENS";
    final String LANGUAGE          = "language";
    final String NORMALIZEDSTRING  = "normalizedString";
    final String NOTATION          = "NOTATION";
    final String QNAME             = "QName";
    final String STRING            = "string";
    final String TOKEN             = "token";

    final XSFacets facets = new XSFacets();

    XSSimpleTypeDecl anySimpleType = XSSimpleTypeDecl.fAnySimpleType;
    XSSimpleTypeDecl stringDV = (XSSimpleTypeDecl)types.get(STRING);

    types.put(FLOAT, new XSSimpleTypeDecl(anySimpleType, FLOAT, XSSimpleTypeDecl.DV_FLOAT, XSSimpleType.ORDERED_PARTIAL, true, true, true, true, XSConstants.FLOAT_DT));
    types.put(DOUBLE, new XSSimpleTypeDecl(anySimpleType, DOUBLE, XSSimpleTypeDecl.DV_DOUBLE, XSSimpleType.ORDERED_PARTIAL, true, true, true, true, XSConstants.DOUBLE_DT));
    types.put(DURATION, new XSSimpleTypeDecl(anySimpleType, DURATION, XSSimpleTypeDecl.DV_DURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.DURATION_DT));
    types.put(HEXBINARY, new XSSimpleTypeDecl(anySimpleType, HEXBINARY, XSSimpleTypeDecl.DV_HEXBINARY, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.HEXBINARY_DT));
    types.put(QNAME, new XSSimpleTypeDecl(anySimpleType, QNAME, XSSimpleTypeDecl.DV_QNAME, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.QNAME_DT));
    types.put(NOTATION, new XSSimpleTypeDecl(anySimpleType, NOTATION, XSSimpleTypeDecl.DV_NOTATION, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.NOTATION_DT));

    facets.whiteSpace =  XSSimpleType.WS_REPLACE;
    XSSimpleTypeDecl normalizedDV = new XSSimpleTypeDecl(stringDV, NORMALIZEDSTRING , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NORMALIZEDSTRING_DT);
    normalizedDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0 );
    types.put(NORMALIZEDSTRING, normalizedDV);

    facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
    XSSimpleTypeDecl tokenDV = new XSSimpleTypeDecl(normalizedDV, TOKEN , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.TOKEN_DT);
    tokenDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0 );
    types.put(TOKEN, tokenDV);

    facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
    facets.pattern  = "([a-zA-Z]{1,8})(-[a-zA-Z0-9]{1,8})*";
    XSSimpleTypeDecl languageDV = new XSSimpleTypeDecl(tokenDV, LANGUAGE , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.LANGUAGE_DT);
    languageDV.applyFacets1(facets, (short)(XSSimpleType.FACET_WHITESPACE | XSSimpleType.FACET_PATTERN) ,(short)0);
    types.put(LANGUAGE, languageDV);

    facets.whiteSpace =  XSSimpleType.WS_COLLAPSE;
    XSSimpleTypeDecl nameDV = new XSSimpleTypeDecl(tokenDV, NAME , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NAME_DT);
    nameDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_NAME);
    types.put(NAME, nameDV);

    facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
    XSSimpleTypeDecl ncnameDV = new XSSimpleTypeDecl(nameDV, NCNAME , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NCNAME_DT) ;
    ncnameDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_NCNAME);
    types.put(NCNAME, ncnameDV);

    types.put(ID, new XSSimpleTypeDecl(ncnameDV,  ID, XSSimpleTypeDecl.DV_ID, XSSimpleType.ORDERED_FALSE, false, false, false , true, XSConstants.ID_DT));
    XSSimpleTypeDecl idrefDV = new XSSimpleTypeDecl(ncnameDV,  IDREF , XSSimpleTypeDecl.DV_IDREF, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.IDREF_DT);
    types.put(IDREF, idrefDV);

    facets.minLength = 1;
    XSSimpleTypeDecl tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0, idrefDV, true, null);
    XSSimpleTypeDecl idrefsDV = new XSSimpleTypeDecl(tempDV, IDREFS, URI_SCHEMAFORSCHEMA, (short)0, false, null);
    idrefsDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0);
    types.put(IDREFS, idrefsDV);

    XSSimpleTypeDecl entityDV = new XSSimpleTypeDecl(ncnameDV, ENTITY , XSSimpleTypeDecl.DV_ENTITY, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.ENTITY_DT);
    types.put(ENTITY, entityDV);

    facets.minLength = 1;
    tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0, entityDV, true, null);
    XSSimpleTypeDecl entitiesDV = new XSSimpleTypeDecl(tempDV, ENTITIES, URI_SCHEMAFORSCHEMA, (short)0, false, null);
    entitiesDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0);
    types.put(ENTITIES, entitiesDV);


    facets.whiteSpace  = XSSimpleType.WS_COLLAPSE;
    XSSimpleTypeDecl nmtokenDV = new XSSimpleTypeDecl(tokenDV, NMTOKEN, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NMTOKEN_DT);
    nmtokenDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_NMTOKEN);
    types.put(NMTOKEN, nmtokenDV);

    facets.minLength = 1;
    tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0, nmtokenDV, true, null);
    XSSimpleTypeDecl nmtokensDV = new XSSimpleTypeDecl(tempDV, NMTOKENS, URI_SCHEMAFORSCHEMA, (short)0, false, null);
    nmtokensDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0);
    types.put(NMTOKENS, nmtokensDV);
}
 
Example #26
Source File: XSModelImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public XSModelImpl(SchemaGrammar[] grammars, short s4sVersion) {
    // copy namespaces/grammars from the array to our arrays
    int len = grammars.length;
    final int initialSize = Math.max(len+1, 5);
    String[] namespaces = new String[initialSize];
    SchemaGrammar[] grammarList = new SchemaGrammar[initialSize];
    boolean hasS4S = false;
    for (int i = 0; i < len; i++) {
        final SchemaGrammar sg = grammars[i];
        final String tns = sg.getTargetNamespace();
        namespaces[i] = tns;
        grammarList[i] = sg;
        if (tns == SchemaSymbols.URI_SCHEMAFORSCHEMA) {
            hasS4S = true;
        }
    }
    // If a schema for the schema namespace isn't included, include it here.
    if (!hasS4S) {
        namespaces[len] = SchemaSymbols.URI_SCHEMAFORSCHEMA;
        grammarList[len++] = SchemaGrammar.getS4SGrammar(s4sVersion);
    }

    SchemaGrammar sg1, sg2;
    Vector gs;
    int i, j, k;
    // and recursively get all imported grammars, add them to our arrays
    for (i = 0; i < len; i++) {
        // get the grammar
        sg1 = grammarList[i];
        gs = sg1.getImportedGrammars();
        // for each imported grammar
        for (j = gs == null ? -1 : gs.size() - 1; j >= 0; j--) {
            sg2 = (SchemaGrammar)gs.elementAt(j);
            // check whether this grammar is already in the list
            for (k = 0; k < len; k++) {
                if (sg2 == grammarList[k]) {
                    break;
                }
            }
            // if it's not, add it to the list
            if (k == len) {
                // ensure the capacity of the arrays
                if (len == grammarList.length) {
                    String[] newSA = new String[len*2];
                    System.arraycopy(namespaces, 0, newSA, 0, len);
                    namespaces = newSA;
                    SchemaGrammar[] newGA = new SchemaGrammar[len*2];
                    System.arraycopy(grammarList, 0, newGA, 0, len);
                    grammarList = newGA;
                }
                namespaces[len] = sg2.getTargetNamespace();
                grammarList[len] = sg2;
                len++;
            }
        }
    }

    fNamespaces = namespaces;
    fGrammarList = grammarList;

    boolean hasIDC = false;
    // establish the mapping from namespace to grammars
    fGrammarMap = new SymbolHash(len*2);
    for (i = 0; i < len; i++) {
        fGrammarMap.put(null2EmptyString(fNamespaces[i]), fGrammarList[i]);
        // update the idc field
        if (fGrammarList[i].hasIDConstraints()) {
            hasIDC = true;
        }
    }

    fHasIDC = hasIDC;
    fGrammarCount = len;
    fGlobalComponents = new XSNamedMap[MAX_COMP_IDX+1];
    fNSComponents = new XSNamedMap[len][MAX_COMP_IDX+1];
    fNamespacesList = new StringListImpl(fNamespaces, fGrammarCount);

    // build substitution groups
    fSubGroupMap = buildSubGroups();
}
 
Example #27
Source File: XSModelImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 #28
Source File: XSModelImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 #29
Source File: XSModelImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
            }
        }
        // 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 #30
Source File: XSModelImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
            }
        }
        // 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];
}