com.sun.org.apache.xerces.internal.impl.dtd.models.CMNode Java Examples

The following examples show how to use com.sun.org.apache.xerces.internal.impl.dtd.models.CMNode. 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: CMBuilder.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private CMNode copyNode(CMNode node) {
    int type = node.type();
    // for choice or sequence, copy the two subtrees, and combine them
    if (type == XSModelGroupImpl.MODELGROUP_CHOICE ||
        type == XSModelGroupImpl.MODELGROUP_SEQUENCE) {
        XSCMBinOp bin = (XSCMBinOp)node;
        node = fNodeFactory.getCMBinOpNode(type, copyNode(bin.getLeft()),
                             copyNode(bin.getRight()));
    }
    // for ?+*, copy the subtree, and put it in a new ?+* node
    else if (type == XSParticleDecl.PARTICLE_ZERO_OR_MORE ||
             type == XSParticleDecl.PARTICLE_ONE_OR_MORE ||
             type == XSParticleDecl.PARTICLE_ZERO_OR_ONE) {
        XSCMUniOp uni = (XSCMUniOp)node;
        node = fNodeFactory.getCMUniOpNode(type, copyNode(uni.getChild()));
    }
    // for element/wildcard (leaf), make a new leaf node,
    // with a distinct position
    else if (type == XSParticleDecl.PARTICLE_ELEMENT ||
             type == XSParticleDecl.PARTICLE_WILDCARD) {
        XSCMLeaf leaf = (XSCMLeaf)node;
        node = fNodeFactory.getCMLeafNode(leaf.type(), leaf.getLeaf(), leaf.getParticleId(), fLeafCount++);
    }

    return node;
}
 
Example #2
Source File: CMBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private CMNode copyNode(CMNode node) {
    int type = node.type();
    // for choice or sequence, copy the two subtrees, and combine them
    if (type == XSModelGroupImpl.MODELGROUP_CHOICE ||
        type == XSModelGroupImpl.MODELGROUP_SEQUENCE) {
        XSCMBinOp bin = (XSCMBinOp)node;
        node = fNodeFactory.getCMBinOpNode(type, copyNode(bin.getLeft()),
                             copyNode(bin.getRight()));
    }
    // for ?+*, copy the subtree, and put it in a new ?+* node
    else if (type == XSParticleDecl.PARTICLE_ZERO_OR_MORE ||
             type == XSParticleDecl.PARTICLE_ONE_OR_MORE ||
             type == XSParticleDecl.PARTICLE_ZERO_OR_ONE) {
        XSCMUniOp uni = (XSCMUniOp)node;
        node = fNodeFactory.getCMUniOpNode(type, copyNode(uni.getChild()));
    }
    // for element/wildcard (leaf), make a new leaf node,
    // with a distinct position
    else if (type == XSParticleDecl.PARTICLE_ELEMENT ||
             type == XSParticleDecl.PARTICLE_WILDCARD) {
        XSCMLeaf leaf = (XSCMLeaf)node;
        node = fNodeFactory.getCMLeafNode(leaf.type(), leaf.getLeaf(), leaf.getParticleId(), fLeafCount++);
    }

    return node;
}
 
Example #3
Source File: CMBuilder.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private CMNode copyNode(CMNode node) {
    int type = node.type();
    // for choice or sequence, copy the two subtrees, and combine them
    if (type == XSModelGroupImpl.MODELGROUP_CHOICE ||
        type == XSModelGroupImpl.MODELGROUP_SEQUENCE) {
        XSCMBinOp bin = (XSCMBinOp)node;
        node = fNodeFactory.getCMBinOpNode(type, copyNode(bin.getLeft()),
                             copyNode(bin.getRight()));
    }
    // for ?+*, copy the subtree, and put it in a new ?+* node
    else if (type == XSParticleDecl.PARTICLE_ZERO_OR_MORE ||
             type == XSParticleDecl.PARTICLE_ONE_OR_MORE ||
             type == XSParticleDecl.PARTICLE_ZERO_OR_ONE) {
        XSCMUniOp uni = (XSCMUniOp)node;
        node = fNodeFactory.getCMUniOpNode(type, copyNode(uni.getChild()));
    }
    // for element/wildcard (leaf), make a new leaf node,
    // with a distinct position
    else if (type == XSParticleDecl.PARTICLE_ELEMENT ||
             type == XSParticleDecl.PARTICLE_WILDCARD) {
        XSCMLeaf leaf = (XSCMLeaf)node;
        node = fNodeFactory.getCMLeafNode(leaf.type(), leaf.getLeaf(), leaf.getParticleId(), fLeafCount++);
    }

    return node;
}
 
Example #4
Source File: XSCMUniOp.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public XSCMUniOp(int type, CMNode childNode) {
    super(type);

    // Insure that its one of the types we require
    if ((type() != XSParticleDecl.PARTICLE_ZERO_OR_ONE)
    &&  (type() != XSParticleDecl.PARTICLE_ZERO_OR_MORE)
    &&  (type() != XSParticleDecl.PARTICLE_ONE_OR_MORE)) {
        throw new RuntimeException("ImplementationMessages.VAL_UST");
    }

    // Store the node and init any data that needs it
    fChild = childNode;
}
 
Example #5
Source File: XSCMUniOp.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public XSCMUniOp(int type, CMNode childNode) {
    super(type);

    // Insure that its one of the types we require
    if ((type() != XSParticleDecl.PARTICLE_ZERO_OR_ONE)
    &&  (type() != XSParticleDecl.PARTICLE_ZERO_OR_MORE)
    &&  (type() != XSParticleDecl.PARTICLE_ONE_OR_MORE)) {
        throw new RuntimeException("ImplementationMessages.VAL_UST");
    }

    // Store the node and init any data that needs it
    fChild = childNode;
}
 
Example #6
Source File: XSCMBinOp.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public XSCMBinOp(int type, CMNode leftNode, CMNode rightNode)
{
    super(type);

    // Insure that its one of the types we require
    if ((type() != XSModelGroupImpl.MODELGROUP_CHOICE)
    &&  (type() != XSModelGroupImpl.MODELGROUP_SEQUENCE)) {
        throw new RuntimeException("ImplementationMessages.VAL_BST");
    }

    // Store the nodes and init any data that needs it
    fLeftChild = leftNode;
    fRightChild = rightNode;
}
 
Example #7
Source File: CMBuilder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
XSCMValidator createDFACM(XSParticleDecl particle) {
    fLeafCount = 0;
    fParticleCount = 0;
    // convert particle tree to CM tree
    CMNode node = useRepeatingLeafNodes(particle) ? buildCompactSyntaxTree(particle) : buildSyntaxTree(particle, true);
    if (node == null)
        return null;
    // build DFA content model from the CM tree
    return new XSDFACM(node, fLeafCount);
}
 
Example #8
Source File: XSDFACM.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
  * Constructs a DFA content model.
  *
  * @param syntaxTree    The syntax tree of the content model.
  * @param leafCount     The number of leaves.
  *
  * @exception RuntimeException Thrown if DFA can't be built.
  */

public XSDFACM(CMNode syntaxTree, int leafCount) {

     // Store away our index and pools in members
     fLeafCount = leafCount;

     //
     //  Create some string pool indexes that represent the names of some
     //  magical nodes in the syntax tree.
     //  (already done in static initialization...
     //

     //
     //  Ok, so lets grind through the building of the DFA. This method
     //  handles the high level logic of the algorithm, but it uses a
     //  number of helper classes to do its thing.
     //
     //  In order to avoid having hundreds of references to the error and
     //  string handlers around, this guy and all of his helper classes
     //  just throw a simple exception and we then pass it along.
     //

     if(DEBUG_VALIDATE_CONTENT) {
         XSDFACM.time -= System.currentTimeMillis();
     }

     buildDFA(syntaxTree);

     if(DEBUG_VALIDATE_CONTENT) {
         XSDFACM.time += System.currentTimeMillis();
         System.out.println("DFA build: " + XSDFACM.time + "ms");
     }
 }
 
Example #9
Source File: XSDFACM.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
  * Constructs a DFA content model.
  *
  * @param syntaxTree    The syntax tree of the content model.
  * @param leafCount     The number of leaves.
  *
  * @exception RuntimeException Thrown if DFA can't be built.
  */

public XSDFACM(CMNode syntaxTree, int leafCount) {

     // Store away our index and pools in members
     fLeafCount = leafCount;
     fIsCompactedForUPA = syntaxTree.isCompactedForUPA();

     //
     //  Create some string pool indexes that represent the names of some
     //  magical nodes in the syntax tree.
     //  (already done in static initialization...
     //

     //
     //  Ok, so lets grind through the building of the DFA. This method
     //  handles the high level logic of the algorithm, but it uses a
     //  number of helper classes to do its thing.
     //
     //  In order to avoid having hundreds of references to the error and
     //  string handlers around, this guy and all of his helper classes
     //  just throw a simple exception and we then pass it along.
     //

     if(DEBUG_VALIDATE_CONTENT) {
         XSDFACM.time -= System.currentTimeMillis();
     }

     buildDFA(syntaxTree);

     if(DEBUG_VALIDATE_CONTENT) {
         XSDFACM.time += System.currentTimeMillis();
         System.out.println("DFA build: " + XSDFACM.time + "ms");
     }
 }
 
Example #10
Source File: XSCMUniOp.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public XSCMUniOp(int type, CMNode childNode) {
    super(type);

    // Insure that its one of the types we require
    if ((type() != XSParticleDecl.PARTICLE_ZERO_OR_ONE)
    &&  (type() != XSParticleDecl.PARTICLE_ZERO_OR_MORE)
    &&  (type() != XSParticleDecl.PARTICLE_ONE_OR_MORE)) {
        throw new RuntimeException("ImplementationMessages.VAL_UST");
    }

    // Store the node and init any data that needs it
    fChild = childNode;
}
 
Example #11
Source File: CMBuilder.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private CMNode multiNodes(CMNode node, int num, boolean copyFirst) {
    if (num == 0) {
        return null;
    }
    if (num == 1) {
        return copyFirst ? copyNode(node) : node;
    }
    int num1 = num/2;
    return fNodeFactory.getCMBinOpNode(XSModelGroupImpl.MODELGROUP_SEQUENCE,
                                       multiNodes(node, num1, copyFirst),
                                       multiNodes(node, num-num1, true));
}
 
Example #12
Source File: XSDFACM.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
  * Constructs a DFA content model.
  *
  * @param syntaxTree    The syntax tree of the content model.
  * @param leafCount     The number of leaves.
  *
  * @exception RuntimeException Thrown if DFA can't be built.
  */

public XSDFACM(CMNode syntaxTree, int leafCount) {

     // Store away our index and pools in members
     fLeafCount = leafCount;

     //
     //  Create some string pool indexes that represent the names of some
     //  magical nodes in the syntax tree.
     //  (already done in static initialization...
     //

     //
     //  Ok, so lets grind through the building of the DFA. This method
     //  handles the high level logic of the algorithm, but it uses a
     //  number of helper classes to do its thing.
     //
     //  In order to avoid having hundreds of references to the error and
     //  string handlers around, this guy and all of his helper classes
     //  just throw a simple exception and we then pass it along.
     //

     if(DEBUG_VALIDATE_CONTENT) {
         XSDFACM.time -= System.currentTimeMillis();
     }

     buildDFA(syntaxTree);

     if(DEBUG_VALIDATE_CONTENT) {
         XSDFACM.time += System.currentTimeMillis();
         System.out.println("DFA build: " + XSDFACM.time + "ms");
     }
 }
 
Example #13
Source File: XSCMUniOp.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public XSCMUniOp(int type, CMNode childNode) {
    super(type);

    // Insure that its one of the types we require
    if ((type() != XSParticleDecl.PARTICLE_ZERO_OR_ONE)
    &&  (type() != XSParticleDecl.PARTICLE_ZERO_OR_MORE)
    &&  (type() != XSParticleDecl.PARTICLE_ONE_OR_MORE)) {
        throw new RuntimeException("ImplementationMessages.VAL_UST");
    }

    // Store the node and init any data that needs it
    fChild = childNode;
}
 
Example #14
Source File: XSDFACM.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
  * Constructs a DFA content model.
  *
  * @param syntaxTree    The syntax tree of the content model.
  * @param leafCount     The number of leaves.
  *
  * @exception RuntimeException Thrown if DFA can't be built.
  */

public XSDFACM(CMNode syntaxTree, int leafCount) {

     // Store away our index and pools in members
     fLeafCount = leafCount;

     //
     //  Create some string pool indexes that represent the names of some
     //  magical nodes in the syntax tree.
     //  (already done in static initialization...
     //

     //
     //  Ok, so lets grind through the building of the DFA. This method
     //  handles the high level logic of the algorithm, but it uses a
     //  number of helper classes to do its thing.
     //
     //  In order to avoid having hundreds of references to the error and
     //  string handlers around, this guy and all of his helper classes
     //  just throw a simple exception and we then pass it along.
     //

     if(DEBUG_VALIDATE_CONTENT) {
         XSDFACM.time -= System.currentTimeMillis();
     }

     buildDFA(syntaxTree);

     if(DEBUG_VALIDATE_CONTENT) {
         XSDFACM.time += System.currentTimeMillis();
         System.out.println("DFA build: " + XSDFACM.time + "ms");
     }
 }
 
Example #15
Source File: XSCMBinOp.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public XSCMBinOp(int type, CMNode leftNode, CMNode rightNode)
{
    super(type);

    // Insure that its one of the types we require
    if ((type() != XSModelGroupImpl.MODELGROUP_CHOICE)
    &&  (type() != XSModelGroupImpl.MODELGROUP_SEQUENCE)) {
        throw new RuntimeException("ImplementationMessages.VAL_BST");
    }

    // Store the nodes and init any data that needs it
    fLeftChild = leftNode;
    fRightChild = rightNode;
}
 
Example #16
Source File: XSDFACM.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/** Post tree build initialization. */
private void postTreeBuildInit(CMNode nodeCur) throws RuntimeException {
    // Set the maximum states on this node
    nodeCur.setMaxStates(fLeafCount);

    XSCMLeaf leaf = null;
    int pos = 0;
    // Recurse as required
    if (nodeCur.type() == XSParticleDecl.PARTICLE_WILDCARD) {
        leaf = (XSCMLeaf)nodeCur;
        pos = leaf.getPosition();
        fLeafList[pos] = leaf;
        fLeafListType[pos] = XSParticleDecl.PARTICLE_WILDCARD;
    }
    else if ((nodeCur.type() == XSModelGroupImpl.MODELGROUP_CHOICE) ||
             (nodeCur.type() == XSModelGroupImpl.MODELGROUP_SEQUENCE)) {
        postTreeBuildInit(((XSCMBinOp)nodeCur).getLeft());
        postTreeBuildInit(((XSCMBinOp)nodeCur).getRight());
    }
    else if (nodeCur.type() == XSParticleDecl.PARTICLE_ZERO_OR_MORE ||
             nodeCur.type() == XSParticleDecl.PARTICLE_ONE_OR_MORE ||
             nodeCur.type() == XSParticleDecl.PARTICLE_ZERO_OR_ONE) {
        postTreeBuildInit(((XSCMUniOp)nodeCur).getChild());
    }
    else if (nodeCur.type() == XSParticleDecl.PARTICLE_ELEMENT) {
        //  Put this node in the leaf list at the current index if its
        //  a non-epsilon leaf.
        leaf = (XSCMLeaf)nodeCur;
        pos = leaf.getPosition();
        fLeafList[pos] = leaf;
        fLeafListType[pos] = XSParticleDecl.PARTICLE_ELEMENT;
    }
    else {
        throw new RuntimeException("ImplementationMessages.VAL_NIICM");
    }
}
 
Example #17
Source File: XSCMBinOp.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public XSCMBinOp(int type, CMNode leftNode, CMNode rightNode)
{
    super(type);

    // Insure that its one of the types we require
    if ((type() != XSModelGroupImpl.MODELGROUP_CHOICE)
    &&  (type() != XSModelGroupImpl.MODELGROUP_SEQUENCE)) {
        throw new RuntimeException("ImplementationMessages.VAL_BST");
    }

    // Store the nodes and init any data that needs it
    fLeftChild = leftNode;
    fRightChild = rightNode;
}
 
Example #18
Source File: CMBuilder.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private CMNode multiNodes(CMNode node, int num, boolean copyFirst) {
    if (num == 0) {
        return null;
    }
    if (num == 1) {
        return copyFirst ? copyNode(node) : node;
    }
    int num1 = num/2;
    return fNodeFactory.getCMBinOpNode(XSModelGroupImpl.MODELGROUP_SEQUENCE,
                                       multiNodes(node, num1, copyFirst),
                                       multiNodes(node, num-num1, true));
}
 
Example #19
Source File: XSDFACM.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/** Post tree build initialization. */
private void postTreeBuildInit(CMNode nodeCur) throws RuntimeException {
    // Set the maximum states on this node
    nodeCur.setMaxStates(fLeafCount);

    XSCMLeaf leaf = null;
    int pos = 0;
    // Recurse as required
    if (nodeCur.type() == XSParticleDecl.PARTICLE_WILDCARD) {
        leaf = (XSCMLeaf)nodeCur;
        pos = leaf.getPosition();
        fLeafList[pos] = leaf;
        fLeafListType[pos] = XSParticleDecl.PARTICLE_WILDCARD;
    }
    else if ((nodeCur.type() == XSModelGroupImpl.MODELGROUP_CHOICE) ||
             (nodeCur.type() == XSModelGroupImpl.MODELGROUP_SEQUENCE)) {
        postTreeBuildInit(((XSCMBinOp)nodeCur).getLeft());
        postTreeBuildInit(((XSCMBinOp)nodeCur).getRight());
    }
    else if (nodeCur.type() == XSParticleDecl.PARTICLE_ZERO_OR_MORE ||
             nodeCur.type() == XSParticleDecl.PARTICLE_ONE_OR_MORE ||
             nodeCur.type() == XSParticleDecl.PARTICLE_ZERO_OR_ONE) {
        postTreeBuildInit(((XSCMUniOp)nodeCur).getChild());
    }
    else if (nodeCur.type() == XSParticleDecl.PARTICLE_ELEMENT) {
        //  Put this node in the leaf list at the current index if its
        //  a non-epsilon leaf.
        leaf = (XSCMLeaf)nodeCur;
        pos = leaf.getPosition();
        fLeafList[pos] = leaf;
        fLeafListType[pos] = XSParticleDecl.PARTICLE_ELEMENT;
    }
    else {
        throw new RuntimeException("ImplementationMessages.VAL_NIICM");
    }
}
 
Example #20
Source File: XSDFACM.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
  * Constructs a DFA content model.
  *
  * @param syntaxTree    The syntax tree of the content model.
  * @param leafCount     The number of leaves.
  *
  * @exception RuntimeException Thrown if DFA can't be built.
  */

public XSDFACM(CMNode syntaxTree, int leafCount) {

     // Store away our index and pools in members
     fLeafCount = leafCount;

     //
     //  Create some string pool indexes that represent the names of some
     //  magical nodes in the syntax tree.
     //  (already done in static initialization...
     //

     //
     //  Ok, so lets grind through the building of the DFA. This method
     //  handles the high level logic of the algorithm, but it uses a
     //  number of helper classes to do its thing.
     //
     //  In order to avoid having hundreds of references to the error and
     //  string handlers around, this guy and all of his helper classes
     //  just throw a simple exception and we then pass it along.
     //

     if(DEBUG_VALIDATE_CONTENT) {
         XSDFACM.time -= System.currentTimeMillis();
     }

     buildDFA(syntaxTree);

     if(DEBUG_VALIDATE_CONTENT) {
         XSDFACM.time += System.currentTimeMillis();
         System.out.println("DFA build: " + XSDFACM.time + "ms");
     }
 }
 
Example #21
Source File: CMBuilder.java    From TencentKona-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 #22
Source File: XSCMBinOp.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public XSCMBinOp(int type, CMNode leftNode, CMNode rightNode)
{
    super(type);

    // Insure that its one of the types we require
    if ((type() != XSModelGroupImpl.MODELGROUP_CHOICE)
    &&  (type() != XSModelGroupImpl.MODELGROUP_SEQUENCE)) {
        throw new RuntimeException("ImplementationMessages.VAL_BST");
    }

    // Store the nodes and init any data that needs it
    fLeftChild = leftNode;
    fRightChild = rightNode;
}
 
Example #23
Source File: XSCMBinOp.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public XSCMBinOp(int type, CMNode leftNode, CMNode rightNode)
{
    super(type);

    // Insure that its one of the types we require
    if ((type() != XSModelGroupImpl.MODELGROUP_CHOICE)
    &&  (type() != XSModelGroupImpl.MODELGROUP_SEQUENCE)) {
        throw new RuntimeException("ImplementationMessages.VAL_BST");
    }

    // Store the nodes and init any data that needs it
    fLeftChild = leftNode;
    fRightChild = rightNode;
}
 
Example #24
Source File: XSDFACM.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
  * Constructs a DFA content model.
  *
  * @param syntaxTree    The syntax tree of the content model.
  * @param leafCount     The number of leaves.
  *
  * @exception RuntimeException Thrown if DFA can't be built.
  */

public XSDFACM(CMNode syntaxTree, int leafCount) {

     // Store away our index and pools in members
     fLeafCount = leafCount;

     //
     //  Create some string pool indexes that represent the names of some
     //  magical nodes in the syntax tree.
     //  (already done in static initialization...
     //

     //
     //  Ok, so lets grind through the building of the DFA. This method
     //  handles the high level logic of the algorithm, but it uses a
     //  number of helper classes to do its thing.
     //
     //  In order to avoid having hundreds of references to the error and
     //  string handlers around, this guy and all of his helper classes
     //  just throw a simple exception and we then pass it along.
     //

     if(DEBUG_VALIDATE_CONTENT) {
         XSDFACM.time -= System.currentTimeMillis();
     }

     buildDFA(syntaxTree);

     if(DEBUG_VALIDATE_CONTENT) {
         XSDFACM.time += System.currentTimeMillis();
         System.out.println("DFA build: " + XSDFACM.time + "ms");
     }
 }
 
Example #25
Source File: XSDFACM.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
  * Constructs a DFA content model.
  *
  * @param syntaxTree    The syntax tree of the content model.
  * @param leafCount     The number of leaves.
  *
  * @exception RuntimeException Thrown if DFA can't be built.
  */

public XSDFACM(CMNode syntaxTree, int leafCount) {

     // Store away our index and pools in members
     fLeafCount = leafCount;

     //
     //  Create some string pool indexes that represent the names of some
     //  magical nodes in the syntax tree.
     //  (already done in static initialization...
     //

     //
     //  Ok, so lets grind through the building of the DFA. This method
     //  handles the high level logic of the algorithm, but it uses a
     //  number of helper classes to do its thing.
     //
     //  In order to avoid having hundreds of references to the error and
     //  string handlers around, this guy and all of his helper classes
     //  just throw a simple exception and we then pass it along.
     //

     if(DEBUG_VALIDATE_CONTENT) {
         XSDFACM.time -= System.currentTimeMillis();
     }

     buildDFA(syntaxTree);

     if(DEBUG_VALIDATE_CONTENT) {
         XSDFACM.time += System.currentTimeMillis();
         System.out.println("DFA build: " + XSDFACM.time + "ms");
     }
 }
 
Example #26
Source File: CMBuilder.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private CMNode multiNodes(CMNode node, int num, boolean copyFirst) {
    if (num == 0) {
        return null;
    }
    if (num == 1) {
        return copyFirst ? copyNode(node) : node;
    }
    int num1 = num/2;
    return fNodeFactory.getCMBinOpNode(XSModelGroupImpl.MODELGROUP_SEQUENCE,
                                       multiNodes(node, num1, copyFirst),
                                       multiNodes(node, num-num1, true));
}
 
Example #27
Source File: XSDFACM.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/** Post tree build initialization. */
private void postTreeBuildInit(CMNode nodeCur) throws RuntimeException {
    // Set the maximum states on this node
    nodeCur.setMaxStates(fLeafCount);

    XSCMLeaf leaf = null;
    int pos = 0;
    // Recurse as required
    if (nodeCur.type() == XSParticleDecl.PARTICLE_WILDCARD) {
        leaf = (XSCMLeaf)nodeCur;
        pos = leaf.getPosition();
        fLeafList[pos] = leaf;
        fLeafListType[pos] = XSParticleDecl.PARTICLE_WILDCARD;
    }
    else if ((nodeCur.type() == XSModelGroupImpl.MODELGROUP_CHOICE) ||
             (nodeCur.type() == XSModelGroupImpl.MODELGROUP_SEQUENCE)) {
        postTreeBuildInit(((XSCMBinOp)nodeCur).getLeft());
        postTreeBuildInit(((XSCMBinOp)nodeCur).getRight());
    }
    else if (nodeCur.type() == XSParticleDecl.PARTICLE_ZERO_OR_MORE ||
             nodeCur.type() == XSParticleDecl.PARTICLE_ONE_OR_MORE ||
             nodeCur.type() == XSParticleDecl.PARTICLE_ZERO_OR_ONE) {
        postTreeBuildInit(((XSCMUniOp)nodeCur).getChild());
    }
    else if (nodeCur.type() == XSParticleDecl.PARTICLE_ELEMENT) {
        //  Put this node in the leaf list at the current index if its
        //  a non-epsilon leaf.
        leaf = (XSCMLeaf)nodeCur;
        pos = leaf.getPosition();
        fLeafList[pos] = leaf;
        fLeafListType[pos] = XSParticleDecl.PARTICLE_ELEMENT;
    }
    else {
        throw new RuntimeException("ImplementationMessages.VAL_NIICM");
    }
}
 
Example #28
Source File: XSCMUniOp.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public XSCMUniOp(int type, CMNode childNode) {
    super(type);

    // Insure that its one of the types we require
    if ((type() != XSParticleDecl.PARTICLE_ZERO_OR_ONE)
    &&  (type() != XSParticleDecl.PARTICLE_ZERO_OR_MORE)
    &&  (type() != XSParticleDecl.PARTICLE_ONE_OR_MORE)) {
        throw new RuntimeException("ImplementationMessages.VAL_UST");
    }

    // Store the node and init any data that needs it
    fChild = childNode;
}
 
Example #29
Source File: XSCMBinOp.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public XSCMBinOp(int type, CMNode leftNode, CMNode rightNode)
{
    super(type);

    // Insure that its one of the types we require
    if ((type() != XSModelGroupImpl.MODELGROUP_CHOICE)
    &&  (type() != XSModelGroupImpl.MODELGROUP_SEQUENCE)) {
        throw new RuntimeException("ImplementationMessages.VAL_BST");
    }

    // Store the nodes and init any data that needs it
    fLeftChild = leftNode;
    fRightChild = rightNode;
}
 
Example #30
Source File: XSDFACM.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/** Post tree build initialization. */
private void postTreeBuildInit(CMNode nodeCur) throws RuntimeException {
    // Set the maximum states on this node
    nodeCur.setMaxStates(fLeafCount);

    XSCMLeaf leaf = null;
    int pos = 0;
    // Recurse as required
    if (nodeCur.type() == XSParticleDecl.PARTICLE_WILDCARD) {
        leaf = (XSCMLeaf)nodeCur;
        pos = leaf.getPosition();
        fLeafList[pos] = leaf;
        fLeafListType[pos] = XSParticleDecl.PARTICLE_WILDCARD;
    }
    else if ((nodeCur.type() == XSModelGroupImpl.MODELGROUP_CHOICE) ||
             (nodeCur.type() == XSModelGroupImpl.MODELGROUP_SEQUENCE)) {
        postTreeBuildInit(((XSCMBinOp)nodeCur).getLeft());
        postTreeBuildInit(((XSCMBinOp)nodeCur).getRight());
    }
    else if (nodeCur.type() == XSParticleDecl.PARTICLE_ZERO_OR_MORE ||
             nodeCur.type() == XSParticleDecl.PARTICLE_ONE_OR_MORE ||
             nodeCur.type() == XSParticleDecl.PARTICLE_ZERO_OR_ONE) {
        postTreeBuildInit(((XSCMUniOp)nodeCur).getChild());
    }
    else if (nodeCur.type() == XSParticleDecl.PARTICLE_ELEMENT) {
        //  Put this node in the leaf list at the current index if its
        //  a non-epsilon leaf.
        leaf = (XSCMLeaf)nodeCur;
        pos = leaf.getPosition();
        fLeafList[pos] = leaf;
        fLeafListType[pos] = XSParticleDecl.PARTICLE_ELEMENT;
    }
    else {
        throw new RuntimeException("ImplementationMessages.VAL_NIICM");
    }
}