Java Code Examples for com.sun.org.apache.xerces.internal.impl.xs.XSParticleDecl#PARTICLE_ONE_OR_MORE

The following examples show how to use com.sun.org.apache.xerces.internal.impl.xs.XSParticleDecl#PARTICLE_ONE_OR_MORE . 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 Bytecoder with Apache License 2.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 jdk8u60 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: CMBuilder.java    From openjdk-jdk8u-backup 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 5
Source File: XSCMUniOp.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public boolean isNullable() {
    //
    //  For debugging purposes, make sure we got rid of all non '*'
    //  repetitions. Otherwise, '*' style nodes are always nullable.
    //
    if (type() == XSParticleDecl.PARTICLE_ONE_OR_MORE)
            return fChild.isNullable();
        else
            return true;
}
 
Example 6
Source File: XSCMUniOp.java    From openjdk-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 7
Source File: XSCMUniOp.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public boolean isNullable() {
    //
    //  For debugging purposes, make sure we got rid of all non '*'
    //  repetitions. Otherwise, '*' style nodes are always nullable.
    //
    if (type() == XSParticleDecl.PARTICLE_ONE_OR_MORE)
            return fChild.isNullable();
        else
            return true;
}
 
Example 8
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 9
Source File: XSCMUniOp.java    From openjdk-jdk9 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 10
Source File: XSCMUniOp.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public boolean isNullable() {
    //
    //  For debugging purposes, make sure we got rid of all non '*'
    //  repetitions. Otherwise, '*' style nodes are always nullable.
    //
    if (type() == XSParticleDecl.PARTICLE_ONE_OR_MORE)
            return fChild.isNullable();
        else
            return true;
}
 
Example 11
Source File: XSCMUniOp.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public boolean isNullable() {
    //
    //  For debugging purposes, make sure we got rid of all non '*'
    //  repetitions. Otherwise, '*' style nodes are always nullable.
    //
    if (type() == XSParticleDecl.PARTICLE_ONE_OR_MORE)
            return fChild.isNullable();
        else
            return true;
}
 
Example 12
Source File: XSCMUniOp.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public boolean isNullable() {
    //
    //  For debugging purposes, make sure we got rid of all non '*'
    //  repetitions. Otherwise, '*' style nodes are always nullable.
    //
    if (type() == XSParticleDecl.PARTICLE_ONE_OR_MORE)
            return fChild.isNullable();
        else
            return true;
}
 
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 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");
    }
}
 
Example 15
Source File: XSCMUniOp.java    From jdk1.8-source-analysis 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 16
Source File: XSDFACM.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Dumps the tree of the current node to standard output.
 *
 * @param nodeCur The current node.
 * @param level   The maximum levels to output.
 *
 * @exception RuntimeException Thrown on error.
 */
private void dumpTree(CMNode nodeCur, int level) {
    for (int index = 0; index < level; index++)
        System.out.print("   ");

    int type = nodeCur.type();

    switch(type ) {

    case XSModelGroupImpl.MODELGROUP_CHOICE:
    case XSModelGroupImpl.MODELGROUP_SEQUENCE: {
        if (type == XSModelGroupImpl.MODELGROUP_CHOICE)
            System.out.print("Choice Node ");
        else
            System.out.print("Seq Node ");

        if (nodeCur.isNullable())
            System.out.print("Nullable ");

        System.out.print("firstPos=");
        System.out.print(nodeCur.firstPos().toString());
        System.out.print(" lastPos=");
        System.out.println(nodeCur.lastPos().toString());

        dumpTree(((XSCMBinOp)nodeCur).getLeft(), level+1);
        dumpTree(((XSCMBinOp)nodeCur).getRight(), level+1);
        break;
    }
    case XSParticleDecl.PARTICLE_ZERO_OR_MORE:
    case XSParticleDecl.PARTICLE_ONE_OR_MORE:
    case XSParticleDecl.PARTICLE_ZERO_OR_ONE: {
        System.out.print("Rep Node ");

        if (nodeCur.isNullable())
            System.out.print("Nullable ");

        System.out.print("firstPos=");
        System.out.print(nodeCur.firstPos().toString());
        System.out.print(" lastPos=");
        System.out.println(nodeCur.lastPos().toString());

        dumpTree(((XSCMUniOp)nodeCur).getChild(), level+1);
        break;
    }
    case XSParticleDecl.PARTICLE_ELEMENT: {
        System.out.print
        (
            "Leaf: (pos="
            + ((XSCMLeaf)nodeCur).getPosition()
            + "), "
            + "(elemIndex="
            + ((XSCMLeaf)nodeCur).getLeaf()
            + ") "
        );

        if (nodeCur.isNullable())
            System.out.print(" Nullable ");

        System.out.print("firstPos=");
        System.out.print(nodeCur.firstPos().toString());
        System.out.print(" lastPos=");
        System.out.println(nodeCur.lastPos().toString());
        break;
    }
    case XSParticleDecl.PARTICLE_WILDCARD:
          System.out.print("Any Node: ");

        System.out.print("firstPos=");
        System.out.print(nodeCur.firstPos().toString());
        System.out.print(" lastPos=");
        System.out.println(nodeCur.lastPos().toString());
        break;
    default: {
        throw new RuntimeException("ImplementationMessages.VAL_NIICM");
    }
    }

}
 
Example 17
Source File: XSDFACM.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Dumps the tree of the current node to standard output.
 *
 * @param nodeCur The current node.
 * @param level   The maximum levels to output.
 *
 * @exception RuntimeException Thrown on error.
 */
private void dumpTree(CMNode nodeCur, int level) {
    for (int index = 0; index < level; index++)
        System.out.print("   ");

    int type = nodeCur.type();

    switch(type ) {

    case XSModelGroupImpl.MODELGROUP_CHOICE:
    case XSModelGroupImpl.MODELGROUP_SEQUENCE: {
        if (type == XSModelGroupImpl.MODELGROUP_CHOICE)
            System.out.print("Choice Node ");
        else
            System.out.print("Seq Node ");

        if (nodeCur.isNullable())
            System.out.print("Nullable ");

        System.out.print("firstPos=");
        System.out.print(nodeCur.firstPos().toString());
        System.out.print(" lastPos=");
        System.out.println(nodeCur.lastPos().toString());

        dumpTree(((XSCMBinOp)nodeCur).getLeft(), level+1);
        dumpTree(((XSCMBinOp)nodeCur).getRight(), level+1);
        break;
    }
    case XSParticleDecl.PARTICLE_ZERO_OR_MORE:
    case XSParticleDecl.PARTICLE_ONE_OR_MORE:
    case XSParticleDecl.PARTICLE_ZERO_OR_ONE: {
        System.out.print("Rep Node ");

        if (nodeCur.isNullable())
            System.out.print("Nullable ");

        System.out.print("firstPos=");
        System.out.print(nodeCur.firstPos().toString());
        System.out.print(" lastPos=");
        System.out.println(nodeCur.lastPos().toString());

        dumpTree(((XSCMUniOp)nodeCur).getChild(), level+1);
        break;
    }
    case XSParticleDecl.PARTICLE_ELEMENT: {
        System.out.print
        (
            "Leaf: (pos="
            + ((XSCMLeaf)nodeCur).getPosition()
            + "), "
            + "(elemIndex="
            + ((XSCMLeaf)nodeCur).getLeaf()
            + ") "
        );

        if (nodeCur.isNullable())
            System.out.print(" Nullable ");

        System.out.print("firstPos=");
        System.out.print(nodeCur.firstPos().toString());
        System.out.print(" lastPos=");
        System.out.println(nodeCur.lastPos().toString());
        break;
    }
    case XSParticleDecl.PARTICLE_WILDCARD:
          System.out.print("Any Node: ");

        System.out.print("firstPos=");
        System.out.print(nodeCur.firstPos().toString());
        System.out.print(" lastPos=");
        System.out.println(nodeCur.lastPos().toString());
        break;
    default: {
        throw new RuntimeException("ImplementationMessages.VAL_NIICM");
    }
    }

}
 
Example 18
Source File: XSDFACM.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Dumps the tree of the current node to standard output.
 *
 * @param nodeCur The current node.
 * @param level   The maximum levels to output.
 *
 * @exception RuntimeException Thrown on error.
 */
private void dumpTree(CMNode nodeCur, int level) {
    for (int index = 0; index < level; index++)
        System.out.print("   ");

    int type = nodeCur.type();

    switch(type ) {

    case XSModelGroupImpl.MODELGROUP_CHOICE:
    case XSModelGroupImpl.MODELGROUP_SEQUENCE: {
        if (type == XSModelGroupImpl.MODELGROUP_CHOICE)
            System.out.print("Choice Node ");
        else
            System.out.print("Seq Node ");

        if (nodeCur.isNullable())
            System.out.print("Nullable ");

        System.out.print("firstPos=");
        System.out.print(nodeCur.firstPos().toString());
        System.out.print(" lastPos=");
        System.out.println(nodeCur.lastPos().toString());

        dumpTree(((XSCMBinOp)nodeCur).getLeft(), level+1);
        dumpTree(((XSCMBinOp)nodeCur).getRight(), level+1);
        break;
    }
    case XSParticleDecl.PARTICLE_ZERO_OR_MORE:
    case XSParticleDecl.PARTICLE_ONE_OR_MORE:
    case XSParticleDecl.PARTICLE_ZERO_OR_ONE: {
        System.out.print("Rep Node ");

        if (nodeCur.isNullable())
            System.out.print("Nullable ");

        System.out.print("firstPos=");
        System.out.print(nodeCur.firstPos().toString());
        System.out.print(" lastPos=");
        System.out.println(nodeCur.lastPos().toString());

        dumpTree(((XSCMUniOp)nodeCur).getChild(), level+1);
        break;
    }
    case XSParticleDecl.PARTICLE_ELEMENT: {
        System.out.print
        (
            "Leaf: (pos="
            + ((XSCMLeaf)nodeCur).getPosition()
            + "), "
            + "(elemIndex="
            + ((XSCMLeaf)nodeCur).getLeaf()
            + ") "
        );

        if (nodeCur.isNullable())
            System.out.print(" Nullable ");

        System.out.print("firstPos=");
        System.out.print(nodeCur.firstPos().toString());
        System.out.print(" lastPos=");
        System.out.println(nodeCur.lastPos().toString());
        break;
    }
    case XSParticleDecl.PARTICLE_WILDCARD:
          System.out.print("Any Node: ");

        System.out.print("firstPos=");
        System.out.print(nodeCur.firstPos().toString());
        System.out.print(" lastPos=");
        System.out.println(nodeCur.lastPos().toString());
        break;
    default: {
        throw new RuntimeException("ImplementationMessages.VAL_NIICM");
    }
    }

}
 
Example 19
Source File: XSDFACM.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Dumps the tree of the current node to standard output.
 *
 * @param nodeCur The current node.
 * @param level   The maximum levels to output.
 *
 * @exception RuntimeException Thrown on error.
 */
private void dumpTree(CMNode nodeCur, int level) {
    for (int index = 0; index < level; index++)
        System.out.print("   ");

    int type = nodeCur.type();

    switch(type ) {

    case XSModelGroupImpl.MODELGROUP_CHOICE:
    case XSModelGroupImpl.MODELGROUP_SEQUENCE: {
        if (type == XSModelGroupImpl.MODELGROUP_CHOICE)
            System.out.print("Choice Node ");
        else
            System.out.print("Seq Node ");

        if (nodeCur.isNullable())
            System.out.print("Nullable ");

        System.out.print("firstPos=");
        System.out.print(nodeCur.firstPos().toString());
        System.out.print(" lastPos=");
        System.out.println(nodeCur.lastPos().toString());

        dumpTree(((XSCMBinOp)nodeCur).getLeft(), level+1);
        dumpTree(((XSCMBinOp)nodeCur).getRight(), level+1);
        break;
    }
    case XSParticleDecl.PARTICLE_ZERO_OR_MORE:
    case XSParticleDecl.PARTICLE_ONE_OR_MORE:
    case XSParticleDecl.PARTICLE_ZERO_OR_ONE: {
        System.out.print("Rep Node ");

        if (nodeCur.isNullable())
            System.out.print("Nullable ");

        System.out.print("firstPos=");
        System.out.print(nodeCur.firstPos().toString());
        System.out.print(" lastPos=");
        System.out.println(nodeCur.lastPos().toString());

        dumpTree(((XSCMUniOp)nodeCur).getChild(), level+1);
        break;
    }
    case XSParticleDecl.PARTICLE_ELEMENT: {
        System.out.print
        (
            "Leaf: (pos="
            + ((XSCMLeaf)nodeCur).getPosition()
            + "), "
            + "(elemIndex="
            + ((XSCMLeaf)nodeCur).getLeaf()
            + ") "
        );

        if (nodeCur.isNullable())
            System.out.print(" Nullable ");

        System.out.print("firstPos=");
        System.out.print(nodeCur.firstPos().toString());
        System.out.print(" lastPos=");
        System.out.println(nodeCur.lastPos().toString());
        break;
    }
    case XSParticleDecl.PARTICLE_WILDCARD:
          System.out.print("Any Node: ");

        System.out.print("firstPos=");
        System.out.print(nodeCur.firstPos().toString());
        System.out.print(" lastPos=");
        System.out.println(nodeCur.lastPos().toString());
        break;
    default: {
        throw new RuntimeException("ImplementationMessages.VAL_NIICM");
    }
    }

}
 
Example 20
Source File: XSDFACM.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Dumps the tree of the current node to standard output.
 *
 * @param nodeCur The current node.
 * @param level   The maximum levels to output.
 *
 * @exception RuntimeException Thrown on error.
 */
private void dumpTree(CMNode nodeCur, int level) {
    for (int index = 0; index < level; index++)
        System.out.print("   ");

    int type = nodeCur.type();

    switch(type ) {

    case XSModelGroupImpl.MODELGROUP_CHOICE:
    case XSModelGroupImpl.MODELGROUP_SEQUENCE: {
        if (type == XSModelGroupImpl.MODELGROUP_CHOICE)
            System.out.print("Choice Node ");
        else
            System.out.print("Seq Node ");

        if (nodeCur.isNullable())
            System.out.print("Nullable ");

        System.out.print("firstPos=");
        System.out.print(nodeCur.firstPos().toString());
        System.out.print(" lastPos=");
        System.out.println(nodeCur.lastPos().toString());

        dumpTree(((XSCMBinOp)nodeCur).getLeft(), level+1);
        dumpTree(((XSCMBinOp)nodeCur).getRight(), level+1);
        break;
    }
    case XSParticleDecl.PARTICLE_ZERO_OR_MORE:
    case XSParticleDecl.PARTICLE_ONE_OR_MORE:
    case XSParticleDecl.PARTICLE_ZERO_OR_ONE: {
        System.out.print("Rep Node ");

        if (nodeCur.isNullable())
            System.out.print("Nullable ");

        System.out.print("firstPos=");
        System.out.print(nodeCur.firstPos().toString());
        System.out.print(" lastPos=");
        System.out.println(nodeCur.lastPos().toString());

        dumpTree(((XSCMUniOp)nodeCur).getChild(), level+1);
        break;
    }
    case XSParticleDecl.PARTICLE_ELEMENT: {
        System.out.print
        (
            "Leaf: (pos="
            + ((XSCMLeaf)nodeCur).getPosition()
            + "), "
            + "(elemIndex="
            + ((XSCMLeaf)nodeCur).getLeaf()
            + ") "
        );

        if (nodeCur.isNullable())
            System.out.print(" Nullable ");

        System.out.print("firstPos=");
        System.out.print(nodeCur.firstPos().toString());
        System.out.print(" lastPos=");
        System.out.println(nodeCur.lastPos().toString());
        break;
    }
    case XSParticleDecl.PARTICLE_WILDCARD:
          System.out.print("Any Node: ");

        System.out.print("firstPos=");
        System.out.print(nodeCur.firstPos().toString());
        System.out.print(" lastPos=");
        System.out.println(nodeCur.lastPos().toString());
        break;
    default: {
        throw new RuntimeException("ImplementationMessages.VAL_NIICM");
    }
    }

}