FileDocCategorySizeDatePackage
XSCMBinOp.javaAPI DocApache Xerces 3.0.15364Fri Sep 14 20:33:52 BST 2007org.apache.xerces.impl.xs.models

XSCMBinOp

public class XSCMBinOp extends org.apache.xerces.impl.dtd.models.CMNode
Content model Bin-Op node.
xerces.internal
author
Neil Graham, IBM
version
$Id: XSCMBinOp.java 476309 2006-11-17 20:49:31Z mrglavas $

Fields Summary
private org.apache.xerces.impl.dtd.models.CMNode
fLeftChild
private org.apache.xerces.impl.dtd.models.CMNode
fRightChild
Constructors Summary
public XSCMBinOp(int type, org.apache.xerces.impl.dtd.models.CMNode leftNode, org.apache.xerces.impl.dtd.models.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;
    
Methods Summary
protected voidcalcFirstPos(org.apache.xerces.impl.dtd.models.CMStateSet toSet)

        if (type() == XSModelGroupImpl.MODELGROUP_CHOICE) {
            // Its the the union of the first positions of our children.
            toSet.setTo(fLeftChild.firstPos());
            toSet.union(fRightChild.firstPos());
        }
         else if (type() == XSModelGroupImpl.MODELGROUP_SEQUENCE) {
            //
            //  If our left child is nullable, then its the union of our
            //  children's first positions. Else is our left child's first
            //  positions.
            //
            toSet.setTo(fLeftChild.firstPos());
            if (fLeftChild.isNullable())
                toSet.union(fRightChild.firstPos());
        }
         else {
            throw new RuntimeException("ImplementationMessages.VAL_BST");
        }
    
protected voidcalcLastPos(org.apache.xerces.impl.dtd.models.CMStateSet toSet)

        if (type() == XSModelGroupImpl.MODELGROUP_CHOICE) {
            // Its the the union of the first positions of our children.
            toSet.setTo(fLeftChild.lastPos());
            toSet.union(fRightChild.lastPos());
        }
        else if (type() == XSModelGroupImpl.MODELGROUP_SEQUENCE) {
            //
            //  If our right child is nullable, then its the union of our
            //  children's last positions. Else is our right child's last
            //  positions.
            //
            toSet.setTo(fRightChild.lastPos());
            if (fRightChild.isNullable())
                toSet.union(fLeftChild.lastPos());
        }
        else {
            throw new RuntimeException("ImplementationMessages.VAL_BST");
        }
    
final org.apache.xerces.impl.dtd.models.CMNodegetLeft()

        return fLeftChild;
    
final org.apache.xerces.impl.dtd.models.CMNodegetRight()

        return fRightChild;
    
public booleanisNullable()

        //
        //  If its an alternation, then if either child is nullable then
        //  this node is nullable. If its a concatenation, then both of
        //  them have to be nullable.
        //
        if (type() == XSModelGroupImpl.MODELGROUP_CHOICE)
            return (fLeftChild.isNullable() || fRightChild.isNullable());
        else if (type() == XSModelGroupImpl.MODELGROUP_SEQUENCE)
            return (fLeftChild.isNullable() && fRightChild.isNullable());
        else
            throw new RuntimeException("ImplementationMessages.VAL_BST");