Java Code Examples for com.sun.org.apache.xerces.internal.impl.xs.SchemaSymbols#OCCURRENCE_UNBOUNDED

The following examples show how to use com.sun.org.apache.xerces.internal.impl.xs.SchemaSymbols#OCCURRENCE_UNBOUNDED . 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: XSDComplexTypeTraverser.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static XSParticleDecl getErrorContent() {
    if (fErrorContent == null) {
        XSParticleDecl particle = new XSParticleDecl();
        particle.fType = XSParticleDecl.PARTICLE_WILDCARD;
        particle.fValue = getErrorWildcard();
        particle.fMinOccurs = 0;
        particle.fMaxOccurs = SchemaSymbols.OCCURRENCE_UNBOUNDED;
        XSModelGroupImpl group = new XSModelGroupImpl();
        group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE;
        group.fParticleCount = 1;
        group.fParticles = new XSParticleDecl[1];
        group.fParticles[0] = particle;
        XSParticleDecl errorContent = new XSParticleDecl();
        errorContent.fType = XSParticleDecl.PARTICLE_MODELGROUP;
        errorContent.fValue = group;
        fErrorContent = errorContent;
    }
    return fErrorContent;
}
 
Example 2
Source File: XSDComplexTypeTraverser.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static XSParticleDecl getErrorContent() {
    if (fErrorContent == null) {
        XSParticleDecl particle = new XSParticleDecl();
        particle.fType = XSParticleDecl.PARTICLE_WILDCARD;
        particle.fValue = getErrorWildcard();
        particle.fMinOccurs = 0;
        particle.fMaxOccurs = SchemaSymbols.OCCURRENCE_UNBOUNDED;
        XSModelGroupImpl group = new XSModelGroupImpl();
        group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE;
        group.fParticleCount = 1;
        group.fParticles = new XSParticleDecl[1];
        group.fParticles[0] = particle;
        XSParticleDecl errorContent = new XSParticleDecl();
        errorContent.fType = XSParticleDecl.PARTICLE_MODELGROUP;
        errorContent.fValue = group;
        fErrorContent = errorContent;
    }
    return fErrorContent;
}
 
Example 3
Source File: XSDComplexTypeTraverser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private static XSParticleDecl getErrorContent() {
    if (fErrorContent == null) {
        XSParticleDecl particle = new XSParticleDecl();
        particle.fType = XSParticleDecl.PARTICLE_WILDCARD;
        particle.fValue = getErrorWildcard();
        particle.fMinOccurs = 0;
        particle.fMaxOccurs = SchemaSymbols.OCCURRENCE_UNBOUNDED;
        XSModelGroupImpl group = new XSModelGroupImpl();
        group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE;
        group.fParticleCount = 1;
        group.fParticles = new XSParticleDecl[1];
        group.fParticles[0] = particle;
        XSParticleDecl errorContent = new XSParticleDecl();
        errorContent.fType = XSParticleDecl.PARTICLE_MODELGROUP;
        errorContent.fValue = group;
        fErrorContent = errorContent;
    }
    return fErrorContent;
}
 
Example 4
Source File: CMBuilder.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private CMNode buildCompactSyntaxTree2(XSParticleDecl particle, int minOccurs, int maxOccurs) {
    // Convert element and wildcard particles to leaf nodes. Wrap repeating particles in a CMUniOpNode.
    CMNode nodeRet = null;
    if (minOccurs == 1 && maxOccurs == 1) {
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
    }
    else if (minOccurs == 0 && maxOccurs == 1) {
        // zero or one
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_ONE, nodeRet);
    }
    else if (minOccurs == 0 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        // zero or more
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_MORE, nodeRet);
    }
    else if (minOccurs == 1 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        // one or more
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, nodeRet);
    }
    else {
        // {n,m}: Instead of expanding this out, create a compound leaf node which carries the
        // occurence information and wrap it in the appropriate CMUniOpNode.
        nodeRet = fNodeFactory.getCMRepeatingLeafNode(particle.fType, particle.fValue, minOccurs, maxOccurs, fParticleCount++, fLeafCount++);
        if (minOccurs == 0) {
            nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_MORE, nodeRet);
        }
        else {
            nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, nodeRet);
        }
    }
    return nodeRet;
}
 
Example 5
Source File: CMBuilder.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private CMNode buildCompactSyntaxTree2(XSParticleDecl particle, int minOccurs, int maxOccurs) {
    // Convert element and wildcard particles to leaf nodes. Wrap repeating particles in a CMUniOpNode.
    CMNode nodeRet = null;
    if (minOccurs == 1 && maxOccurs == 1) {
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
    }
    else if (minOccurs == 0 && maxOccurs == 1) {
        // zero or one
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_ONE, nodeRet);
    }
    else if (minOccurs == 0 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        // zero or more
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_MORE, nodeRet);
    }
    else if (minOccurs == 1 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        // one or more
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, nodeRet);
    }
    else {
        // {n,m}: Instead of expanding this out, create a compound leaf node which carries the
        // occurence information and wrap it in the appropriate CMUniOpNode.
        nodeRet = fNodeFactory.getCMRepeatingLeafNode(particle.fType, particle.fValue, minOccurs, maxOccurs, fParticleCount++, fLeafCount++);
        if (minOccurs == 0) {
            nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_MORE, nodeRet);
        }
        else {
            nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, nodeRet);
        }
    }
    return nodeRet;
}
 
Example 6
Source File: XSDFACM.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Check which elements are valid to appear at this point. This method also
 * works if the state is in error, in which case it returns what should
 * have been seen.
 *
 * @param state  the current state
 * @return       a Vector whose entries are instances of
 *               either XSWildcardDecl or XSElementDecl.
 */
public Vector whatCanGoHere(int[] state) {
    int curState = state[0];
    if (curState < 0)
        curState = state[1];
    Occurence o = (fCountingStates != null) ?
            fCountingStates[curState] : null;
    int count = state[2];

    Vector ret = new Vector();
    for (int elemIndex = 0; elemIndex < fElemMapSize; elemIndex++) {
        int nextState = fTransTable[curState][elemIndex];
        if (nextState != -1) {
            if (o != null) {
                if (curState == nextState) {
                    // Do not include transitions which loop back to the
                    // current state if we've looped the maximum number
                    // of times or greater.
                    if (count >= o.maxOccurs &&
                        o.maxOccurs != SchemaSymbols.OCCURRENCE_UNBOUNDED) {
                        continue;
                    }
                }
                // Do not include transitions which advance past the
                // current state if we have not looped enough times.
                else if (count < o.minOccurs) {
                    continue;
                }
            }
            ret.addElement(fElemMap[elemIndex]);
        }
    }
    return ret;
}
 
Example 7
Source File: CMBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private CMNode buildCompactSyntaxTree2(XSParticleDecl particle, int minOccurs, int maxOccurs) {
    // Convert element and wildcard particles to leaf nodes. Wrap repeating particles in a CMUniOpNode.
    CMNode nodeRet = null;
    if (minOccurs == 1 && maxOccurs == 1) {
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
    }
    else if (minOccurs == 0 && maxOccurs == 1) {
        // zero or one
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_ONE, nodeRet);
    }
    else if (minOccurs == 0 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        // zero or more
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_MORE, nodeRet);
    }
    else if (minOccurs == 1 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        // one or more
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, nodeRet);
    }
    else {
        // {n,m}: Instead of expanding this out, create a compound leaf node which carries the
        // occurence information and wrap it in the appropriate CMUniOpNode.
        nodeRet = fNodeFactory.getCMRepeatingLeafNode(particle.fType, particle.fValue, minOccurs, maxOccurs, fParticleCount++, fLeafCount++);
        if (minOccurs == 0) {
            nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_MORE, nodeRet);
        }
        else {
            nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, nodeRet);
        }
    }
    return nodeRet;
}
 
Example 8
Source File: CMBuilder.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private CMNode buildCompactSyntaxTree2(XSParticleDecl particle, int minOccurs, int maxOccurs) {
    // Convert element and wildcard particles to leaf nodes. Wrap repeating particles in a CMUniOpNode.
    CMNode nodeRet = null;
    if (minOccurs == 1 && maxOccurs == 1) {
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
    }
    else if (minOccurs == 0 && maxOccurs == 1) {
        // zero or one
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_ONE, nodeRet);
    }
    else if (minOccurs == 0 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        // zero or more
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_MORE, nodeRet);
    }
    else if (minOccurs == 1 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        // one or more
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, nodeRet);
    }
    else {
        // {n,m}: Instead of expanding this out, create a compound leaf node which carries the
        // occurence information and wrap it in the appropriate CMUniOpNode.
        nodeRet = fNodeFactory.getCMRepeatingLeafNode(particle.fType, particle.fValue, minOccurs, maxOccurs, fParticleCount++, fLeafCount++);
        if (minOccurs == 0) {
            nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_MORE, nodeRet);
        }
        else {
            nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, nodeRet);
        }
    }
    return nodeRet;
}
 
Example 9
Source File: CMBuilder.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private CMNode buildCompactSyntaxTree2(XSParticleDecl particle, int minOccurs, int maxOccurs) {
    // Convert element and wildcard particles to leaf nodes. Wrap repeating particles in a CMUniOpNode.
    CMNode nodeRet = null;
    if (minOccurs == 1 && maxOccurs == 1) {
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
    }
    else if (minOccurs == 0 && maxOccurs == 1) {
        // zero or one
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_ONE, nodeRet);
    }
    else if (minOccurs == 0 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        // zero or more
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_MORE, nodeRet);
    }
    else if (minOccurs == 1 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        // one or more
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, nodeRet);
    }
    else {
        // {n,m}: Instead of expanding this out, create a compound leaf node which carries the
        // occurence information and wrap it in the appropriate CMUniOpNode.
        nodeRet = fNodeFactory.getCMRepeatingLeafNode(particle.fType, particle.fValue, minOccurs, maxOccurs, fParticleCount++, fLeafCount++);
        if (minOccurs == 0) {
            nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_MORE, nodeRet);
        }
        else {
            nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, nodeRet);
        }
    }
    return nodeRet;
}
 
Example 10
Source File: XSDFACM.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check which elements are valid to appear at this point. This method also
 * works if the state is in error, in which case it returns what should
 * have been seen.
 *
 * @param state  the current state
 * @return       a Vector whose entries are instances of
 *               either XSWildcardDecl or XSElementDecl.
 */
public Vector whatCanGoHere(int[] state) {
    int curState = state[0];
    if (curState < 0)
        curState = state[1];
    Occurence o = (fCountingStates != null) ?
            fCountingStates[curState] : null;
    int count = state[2];

    Vector ret = new Vector();
    for (int elemIndex = 0; elemIndex < fElemMapSize; elemIndex++) {
        int nextState = fTransTable[curState][elemIndex];
        if (nextState != -1) {
            if (o != null) {
                if (curState == nextState) {
                    // Do not include transitions which loop back to the
                    // current state if we've looped the maximum number
                    // of times or greater.
                    if (count >= o.maxOccurs &&
                        o.maxOccurs != SchemaSymbols.OCCURRENCE_UNBOUNDED) {
                        continue;
                    }
                }
                // Do not include transitions which advance past the
                // current state if we have not looped enough times.
                else if (count < o.minOccurs) {
                    continue;
                }
            }
            ret.addElement(fElemMap[elemIndex]);
        }
    }
    return ret;
}
 
Example 11
Source File: XSDFACM.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check which elements are valid to appear at this point. This method also
 * works if the state is in error, in which case it returns what should
 * have been seen.
 *
 * @param state  the current state
 * @return       a list whose entries are instances of
 *               either XSWildcardDecl or XSElementDecl.
 */
public ArrayList whatCanGoHere(int[] state) {
    int curState = state[0];
    if (curState < 0)
        curState = state[1];
    Occurence o = (fCountingStates != null) ?
            fCountingStates[curState] : null;
    int count = state[2];

    ArrayList ret = new ArrayList();
    for (int elemIndex = 0; elemIndex < fElemMapSize; elemIndex++) {
        int nextState = fTransTable[curState][elemIndex];
        if (nextState != -1) {
            if (o != null) {
                if (curState == nextState) {
                    // Do not include transitions which loop back to the
                    // current state if we've looped the maximum number
                    // of times or greater.
                    if (count >= o.maxOccurs &&
                        o.maxOccurs != SchemaSymbols.OCCURRENCE_UNBOUNDED) {
                        continue;
                    }
                }
                // Do not include transitions which advance past the
                // current state if we have not looped enough times.
                else if (count < o.minOccurs) {
                    continue;
                }
            }
            ret.add(fElemMap[elemIndex]);
        }
    }
    return ret;
}
 
Example 12
Source File: XSDFACM.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check which elements are valid to appear at this point. This method also
 * works if the state is in error, in which case it returns what should
 * have been seen.
 *
 * @param state  the current state
 * @return       a Vector whose entries are instances of
 *               either XSWildcardDecl or XSElementDecl.
 */
public Vector whatCanGoHere(int[] state) {
    int curState = state[0];
    if (curState < 0)
        curState = state[1];
    Occurence o = (fCountingStates != null) ?
            fCountingStates[curState] : null;
    int count = state[2];

    Vector ret = new Vector();
    for (int elemIndex = 0; elemIndex < fElemMapSize; elemIndex++) {
        int nextState = fTransTable[curState][elemIndex];
        if (nextState != -1) {
            if (o != null) {
                if (curState == nextState) {
                    // Do not include transitions which loop back to the
                    // current state if we've looped the maximum number
                    // of times or greater.
                    if (count >= o.maxOccurs &&
                        o.maxOccurs != SchemaSymbols.OCCURRENCE_UNBOUNDED) {
                        continue;
                    }
                }
                // Do not include transitions which advance past the
                // current state if we have not looped enough times.
                else if (count < o.minOccurs) {
                    continue;
                }
            }
            ret.addElement(fElemMap[elemIndex]);
        }
    }
    return ret;
}
 
Example 13
Source File: XSDFACM.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check which elements are valid to appear at this point. This method also
 * works if the state is in error, in which case it returns what should
 * have been seen.
 *
 * @param state  the current state
 * @return       a Vector whose entries are instances of
 *               either XSWildcardDecl or XSElementDecl.
 */
public Vector whatCanGoHere(int[] state) {
    int curState = state[0];
    if (curState < 0)
        curState = state[1];
    Occurence o = (fCountingStates != null) ?
            fCountingStates[curState] : null;
    int count = state[2];

    Vector ret = new Vector();
    for (int elemIndex = 0; elemIndex < fElemMapSize; elemIndex++) {
        int nextState = fTransTable[curState][elemIndex];
        if (nextState != -1) {
            if (o != null) {
                if (curState == nextState) {
                    // Do not include transitions which loop back to the
                    // current state if we've looped the maximum number
                    // of times or greater.
                    if (count >= o.maxOccurs &&
                        o.maxOccurs != SchemaSymbols.OCCURRENCE_UNBOUNDED) {
                        continue;
                    }
                }
                // Do not include transitions which advance past the
                // current state if we have not looped enough times.
                else if (count < o.minOccurs) {
                    continue;
                }
            }
            ret.addElement(fElemMap[elemIndex]);
        }
    }
    return ret;
}
 
Example 14
Source File: XSDFACM.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public String toString() {
    return "minOccurs=" + minOccurs
        + ";maxOccurs=" +
        ((maxOccurs != SchemaSymbols.OCCURRENCE_UNBOUNDED)
                ? Integer.toString(maxOccurs) : "unbounded");
}
 
Example 15
Source File: CMBuilder.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private CMNode expandContentModel(CMNode node,
                                  int minOccurs, int maxOccurs, boolean optimize) {

    CMNode nodeRet = null;

    if (minOccurs==1 && maxOccurs==1) {
        nodeRet = node;
    }
    else if (minOccurs==0 && maxOccurs==1) {
        //zero or one
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_ONE, node);
    }
    else if (minOccurs == 0 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        //zero or more
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_MORE, node);
    }
    else if (minOccurs == 1 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        //one or more
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, node);
    }
    else if (optimize && node.type() == XSParticleDecl.PARTICLE_ELEMENT ||
             node.type() == XSParticleDecl.PARTICLE_WILDCARD) {
        // Only for elements and wildcards, subsume e{n,m} and e{n,unbounded} to e*
        // or e+ and, once the DFA reaches a final state, check if the actual number
        // of elements is between minOccurs and maxOccurs. This new algorithm runs
        // in constant space.

        // TODO: What is the impact of this optimization on the PSVI?
        nodeRet = fNodeFactory.getCMUniOpNode(
                minOccurs == 0 ? XSParticleDecl.PARTICLE_ZERO_OR_MORE
                    : XSParticleDecl.PARTICLE_ONE_OR_MORE, node);
        nodeRet.setUserData(new int[] { minOccurs, maxOccurs });
    }
    else if (maxOccurs == SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        // => a,a,..,a+
        // create a+ node first, then put minOccurs-1 a's in front of it
        // for the first time "node" is used, we don't need to make a copy
        // and for other references to node, we make copies
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, node);
        // (task 4) we need to call copyNode here, so that we append
        // an entire new copy of the node (a subtree). this is to ensure
        // all leaf nodes have distinct position
        // we know that minOccurs > 1
        nodeRet = fNodeFactory.getCMBinOpNode(XSModelGroupImpl.MODELGROUP_SEQUENCE,
                                              multiNodes(node, minOccurs-1, true), nodeRet);
    }
    else {
        // {n,m} => a,a,a,...(a),(a),...
        // first n a's, then m-n a?'s.
        // copyNode is called, for the same reason as above
        if (minOccurs > 0) {
            nodeRet = multiNodes(node, minOccurs, false);
        }
        if (maxOccurs > minOccurs) {
            node = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_ONE, node);
            if (nodeRet == null) {
                nodeRet = multiNodes(node, maxOccurs-minOccurs, false);
            }
            else {
                nodeRet = fNodeFactory.getCMBinOpNode(XSModelGroupImpl.MODELGROUP_SEQUENCE,
                                                      nodeRet, multiNodes(node, maxOccurs-minOccurs, true));
            }
        }
    }

    return nodeRet;
}
 
Example 16
Source File: XSDFACM.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public String toString() {
    return "minOccurs=" + minOccurs
        + ";maxOccurs=" +
        ((maxOccurs != SchemaSymbols.OCCURRENCE_UNBOUNDED)
                ? Integer.toString(maxOccurs) : "unbounded");
}
 
Example 17
Source File: CMBuilder.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private CMNode expandContentModel(CMNode node,
                                  int minOccurs, int maxOccurs, boolean optimize) {

    CMNode nodeRet = null;

    if (minOccurs==1 && maxOccurs==1) {
        nodeRet = node;
    }
    else if (minOccurs==0 && maxOccurs==1) {
        //zero or one
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_ONE, node);
    }
    else if (minOccurs == 0 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        //zero or more
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_MORE, node);
    }
    else if (minOccurs == 1 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        //one or more
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, node);
    }
    else if (optimize && node.type() == XSParticleDecl.PARTICLE_ELEMENT ||
             node.type() == XSParticleDecl.PARTICLE_WILDCARD) {
        // Only for elements and wildcards, subsume e{n,m} and e{n,unbounded} to e*
        // or e+ and, once the DFA reaches a final state, check if the actual number
        // of elements is between minOccurs and maxOccurs. This new algorithm runs
        // in constant space.

        // TODO: What is the impact of this optimization on the PSVI?
        nodeRet = fNodeFactory.getCMUniOpNode(
                minOccurs == 0 ? XSParticleDecl.PARTICLE_ZERO_OR_MORE
                    : XSParticleDecl.PARTICLE_ONE_OR_MORE, node);
        nodeRet.setUserData(new int[] { minOccurs, maxOccurs });
    }
    else if (maxOccurs == SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        // => a,a,..,a+
        // create a+ node first, then put minOccurs-1 a's in front of it
        // for the first time "node" is used, we don't need to make a copy
        // and for other references to node, we make copies
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, node);
        // (task 4) we need to call copyNode here, so that we append
        // an entire new copy of the node (a subtree). this is to ensure
        // all leaf nodes have distinct position
        // we know that minOccurs > 1
        nodeRet = fNodeFactory.getCMBinOpNode(XSModelGroupImpl.MODELGROUP_SEQUENCE,
                                              multiNodes(node, minOccurs-1, true), nodeRet);
    }
    else {
        // {n,m} => a,a,a,...(a),(a),...
        // first n a's, then m-n a?'s.
        // copyNode is called, for the same reason as above
        if (minOccurs > 0) {
            nodeRet = multiNodes(node, minOccurs, false);
        }
        if (maxOccurs > minOccurs) {
            node = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_ONE, node);
            if (nodeRet == null) {
                nodeRet = multiNodes(node, maxOccurs-minOccurs, false);
            }
            else {
                nodeRet = fNodeFactory.getCMBinOpNode(XSModelGroupImpl.MODELGROUP_SEQUENCE,
                                                      nodeRet, multiNodes(node, maxOccurs-minOccurs, true));
            }
        }
    }

    return nodeRet;
}
 
Example 18
Source File: CMBuilder.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private CMNode expandContentModel(CMNode node,
                                  int minOccurs, int maxOccurs, boolean optimize) {

    CMNode nodeRet = null;

    if (minOccurs==1 && maxOccurs==1) {
        nodeRet = node;
    }
    else if (minOccurs==0 && maxOccurs==1) {
        //zero or one
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_ONE, node);
    }
    else if (minOccurs == 0 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        //zero or more
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_MORE, node);
    }
    else if (minOccurs == 1 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        //one or more
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, node);
    }
    else if (optimize && node.type() == XSParticleDecl.PARTICLE_ELEMENT ||
             node.type() == XSParticleDecl.PARTICLE_WILDCARD) {
        // Only for elements and wildcards, subsume e{n,m} and e{n,unbounded} to e*
        // or e+ and, once the DFA reaches a final state, check if the actual number
        // of elements is between minOccurs and maxOccurs. This new algorithm runs
        // in constant space.

        // TODO: What is the impact of this optimization on the PSVI?
        nodeRet = fNodeFactory.getCMUniOpNode(
                minOccurs == 0 ? XSParticleDecl.PARTICLE_ZERO_OR_MORE
                    : XSParticleDecl.PARTICLE_ONE_OR_MORE, node);
        nodeRet.setUserData(new int[] { minOccurs, maxOccurs });
    }
    else if (maxOccurs == SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        // => a,a,..,a+
        // create a+ node first, then put minOccurs-1 a's in front of it
        // for the first time "node" is used, we don't need to make a copy
        // and for other references to node, we make copies
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, node);
        // (task 4) we need to call copyNode here, so that we append
        // an entire new copy of the node (a subtree). this is to ensure
        // all leaf nodes have distinct position
        // we know that minOccurs > 1
        nodeRet = fNodeFactory.getCMBinOpNode(XSModelGroupImpl.MODELGROUP_SEQUENCE,
                                              multiNodes(node, minOccurs-1, true), nodeRet);
    }
    else {
        // {n,m} => a,a,a,...(a),(a),...
        // first n a's, then m-n a?'s.
        // copyNode is called, for the same reason as above
        if (minOccurs > 0) {
            nodeRet = multiNodes(node, minOccurs, false);
        }
        if (maxOccurs > minOccurs) {
            node = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_ONE, node);
            if (nodeRet == null) {
                nodeRet = multiNodes(node, maxOccurs-minOccurs, false);
            }
            else {
                nodeRet = fNodeFactory.getCMBinOpNode(XSModelGroupImpl.MODELGROUP_SEQUENCE,
                                                      nodeRet, multiNodes(node, maxOccurs-minOccurs, true));
            }
        }
    }

    return nodeRet;
}
 
Example 19
Source File: XSDFACM.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public String toString() {
    return "minOccurs=" + minOccurs
        + ";maxOccurs=" +
        ((maxOccurs != SchemaSymbols.OCCURRENCE_UNBOUNDED)
                ? Integer.toString(maxOccurs) : "unbounded");
}
 
Example 20
Source File: CMBuilder.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
private CMNode expandContentModel(CMNode node,
                                  int minOccurs, int maxOccurs, boolean optimize) {

    CMNode nodeRet = null;

    if (minOccurs==1 && maxOccurs==1) {
        nodeRet = node;
    }
    else if (minOccurs==0 && maxOccurs==1) {
        //zero or one
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_ONE, node);
    }
    else if (minOccurs == 0 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        //zero or more
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_MORE, node);
    }
    else if (minOccurs == 1 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        //one or more
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, node);
    }
    else if (optimize && node.type() == XSParticleDecl.PARTICLE_ELEMENT ||
             node.type() == XSParticleDecl.PARTICLE_WILDCARD) {
        // Only for elements and wildcards, subsume e{n,m} and e{n,unbounded} to e*
        // or e+ and, once the DFA reaches a final state, check if the actual number
        // of elements is between minOccurs and maxOccurs. This new algorithm runs
        // in constant space.

        // TODO: What is the impact of this optimization on the PSVI?
        nodeRet = fNodeFactory.getCMUniOpNode(
                minOccurs == 0 ? XSParticleDecl.PARTICLE_ZERO_OR_MORE
                    : XSParticleDecl.PARTICLE_ONE_OR_MORE, node);
        nodeRet.setUserData(new int[] { minOccurs, maxOccurs });
    }
    else if (maxOccurs == SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        // => a,a,..,a+
        // create a+ node first, then put minOccurs-1 a's in front of it
        // for the first time "node" is used, we don't need to make a copy
        // and for other references to node, we make copies
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, node);
        // (task 4) we need to call copyNode here, so that we append
        // an entire new copy of the node (a subtree). this is to ensure
        // all leaf nodes have distinct position
        // we know that minOccurs > 1
        nodeRet = fNodeFactory.getCMBinOpNode(XSModelGroupImpl.MODELGROUP_SEQUENCE,
                                              multiNodes(node, minOccurs-1, true), nodeRet);
    }
    else {
        // {n,m} => a,a,a,...(a),(a),...
        // first n a's, then m-n a?'s.
        // copyNode is called, for the same reason as above
        if (minOccurs > 0) {
            nodeRet = multiNodes(node, minOccurs, false);
        }
        if (maxOccurs > minOccurs) {
            node = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_ONE, node);
            if (nodeRet == null) {
                nodeRet = multiNodes(node, maxOccurs-minOccurs, false);
            }
            else {
                nodeRet = fNodeFactory.getCMBinOpNode(XSModelGroupImpl.MODELGROUP_SEQUENCE,
                                                      nodeRet, multiNodes(node, maxOccurs-minOccurs, true));
            }
        }
    }

    return nodeRet;
}