com.caucho.relaxng.program
Class Item

java.lang.Object
  extended by com.caucho.relaxng.program.Item
Direct Known Subclasses:
AttributeItem, ChoiceItem, DataItem, ElementItem, EmptyItem, GroupItem, InElementItem, InterleaveItem, MemoItem, TextItem, ZeroOrMoreItem

public abstract class Item
extends java.lang.Object

Generates programs from patterns.


Field Summary
protected static L10N L
           
protected static java.util.logging.Logger log
           
 
Constructor Summary
Item()
           
 
Method Summary
protected  void addSyntaxNewline(CharBuffer cb, int depth)
          Adds a syntax newline.
 boolean allowAttribute(QName name, java.lang.String value)
          Sets an attribute.
 boolean allowEmpty()
          Returns true if the item can match empty.
 boolean allowsElement(QName name)
          Returns true if the element is allowed somewhere in the item.
 Item attributeEnd()
          Returns true if the item can match empty.
 void attributeSet(java.util.HashSet<QName> set)
          Adds to the first set, the set of attribute names possible.
protected  java.util.Iterator<Item> emptyItemIterator()
           
 Item endElement()
          Returns the next item when the element closes
protected  RelaxException error(java.lang.String msg)
          Throws an error.
 void firstSet(java.util.HashSet<QName> set)
          Adds to the first set the set of element names possible.
 java.util.Iterator<Item> getItemsIterator()
          Return all possible child items
 Item groupContinuation(Item cont)
          Appends a group to a continuation.
 Item inElementContinuation(Item cont)
          Interleaves a continuation.
 Item interleaveContinuation(Item cont)
          Interleaves a continuation.
protected  boolean isSimpleSyntax()
          Returns true for an element with simple syntax.
protected  java.util.Iterator<Item> itemIterator(Item item)
           
 void requiredFirstSet(java.util.HashSet<QName> set)
          Adds to the first set the set of element names required.
 Item setAttribute(QName name, java.lang.String value)
          Sets an attribute.
 Item startElement(QName name)
          Returns the next item when an element of the given name is returned
 Item text(java.lang.CharSequence text)
          Adds text.
 java.lang.String toSyntaxDescription(int depth)
          Returns the pretty printed syntax.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

L

protected static final L10N L

log

protected static final java.util.logging.Logger log
Constructor Detail

Item

public Item()
Method Detail

firstSet

public void firstSet(java.util.HashSet<QName> set)
Adds to the first set the set of element names possible.


requiredFirstSet

public void requiredFirstSet(java.util.HashSet<QName> set)
Adds to the first set the set of element names required.


allowEmpty

public boolean allowEmpty()
Returns true if the item can match empty.


getItemsIterator

public java.util.Iterator<Item> getItemsIterator()
Return all possible child items


emptyItemIterator

protected java.util.Iterator<Item> emptyItemIterator()

itemIterator

protected java.util.Iterator<Item> itemIterator(Item item)

startElement

public Item startElement(QName name)
                  throws RelaxException
Returns the next item when an element of the given name is returned

Parameters:
name - the name of the element
Returns:
the program for handling the element
Throws:
RelaxException

allowsElement

public boolean allowsElement(QName name)
Returns true if the element is allowed somewhere in the item. allowsElement is used for error messages to give more information in cases of order dependency.

Parameters:
name - the name of the element
Returns:
true if the element is allowed somewhere

attributeSet

public void attributeSet(java.util.HashSet<QName> set)
Adds to the first set, the set of attribute names possible.


allowAttribute

public boolean allowAttribute(QName name,
                              java.lang.String value)
                       throws RelaxException
Sets an attribute.

Parameters:
name - the name of the attribute
value - the value of the attribute
Returns:
the program for handling the element
Throws:
RelaxException

setAttribute

public Item setAttribute(QName name,
                         java.lang.String value)
                  throws RelaxException
Sets an attribute.

Parameters:
name - the name of the attribute
value - the value of the attribute
Returns:
the program for handling the element
Throws:
RelaxException

attributeEnd

public Item attributeEnd()
Returns true if the item can match empty.


text

public Item text(java.lang.CharSequence text)
          throws RelaxException
Adds text.

Throws:
RelaxException

endElement

public Item endElement()
                throws RelaxException
Returns the next item when the element closes

Throws:
RelaxException

interleaveContinuation

public Item interleaveContinuation(Item cont)
Interleaves a continuation.


inElementContinuation

public Item inElementContinuation(Item cont)
Interleaves a continuation.


groupContinuation

public Item groupContinuation(Item cont)
Appends a group to a continuation.


toSyntaxDescription

public java.lang.String toSyntaxDescription(int depth)
Returns the pretty printed syntax.


isSimpleSyntax

protected boolean isSimpleSyntax()
Returns true for an element with simple syntax.


addSyntaxNewline

protected void addSyntaxNewline(CharBuffer cb,
                                int depth)
Adds a syntax newline.


error

protected RelaxException error(java.lang.String msg)
Throws an error.