FileDocCategorySizeDatePackage
CMLeaf.javaAPI DocJava SE 5 API5562Fri Aug 26 14:55:46 BST 2005com.sun.org.apache.xerces.internal.impl.dtd.models

CMLeaf

public class CMLeaf extends CMNode
Content model leaf node.
version
$Id: CMLeaf.java,v 1.2 2002/01/29 01:15:10 lehors Exp $

Fields Summary
private QName
fElement
This is the element that this leaf represents.
private int
fPosition
Part of the algorithm to convert a regex directly to a DFA numbers each leaf sequentially. If its -1, that means its an epsilon node. Zero and greater are non-epsilon positions.
Constructors Summary
public CMLeaf(QName element, int position)
Constructs a content model leaf.


    //
    // Constructors
    //

          
          
        super(XMLContentSpec.CONTENTSPECNODE_LEAF);

        // Store the element index and position
        fElement.setValues(element);
        fPosition = position;
    
public CMLeaf(QName element)
Constructs a content model leaf.

        super(XMLContentSpec.CONTENTSPECNODE_LEAF);

        // Store the element index and position
        fElement.setValues(element);
    
Methods Summary
protected voidcalcFirstPos(com.sun.org.apache.xerces.internal.impl.dtd.models.CMStateSet toSet)

        // If we are an epsilon node, then the first pos is an empty set
        if (fPosition == -1)
            toSet.zeroBits();

        // Otherwise, its just the one bit of our position
        else
            toSet.setBit(fPosition);
    
protected voidcalcLastPos(com.sun.org.apache.xerces.internal.impl.dtd.models.CMStateSet toSet)

        // If we are an epsilon node, then the last pos is an empty set
        if (fPosition == -1)
            toSet.zeroBits();

        // Otherwise, its just the one bit of our position
        else
            toSet.setBit(fPosition);
    
final com.sun.org.apache.xerces.internal.xni.QNamegetElement()

        return fElement;
    
final intgetPosition()

        return fPosition;
    
public booleanisNullable()

        // Leaf nodes are never nullable unless its an epsilon node
        return (fPosition == -1);
    
final voidsetPosition(int newPosition)

        fPosition = newPosition;
    
public java.lang.StringtoString()

        StringBuffer strRet = new StringBuffer(fElement.toString());
        strRet.append(" (");
        strRet.append(fElement.uri);
        strRet.append(',");
        strRet.append(fElement.localpart);
        strRet.append(')");
        if (fPosition >= 0)
        {
            strRet.append
            (
                " (Pos:"
                + new Integer(fPosition).toString()
                + ")"
            );
        }
        return strRet.toString();