Package schema2template.grammar
Class MSVExpressionIterator
java.lang.Object
schema2template.grammar.MSVExpressionIterator
- All Implemented Interfaces:
Iterator<com.sun.msv.grammar.Expression>
public final class MSVExpressionIterator
extends Object
implements Iterator<com.sun.msv.grammar.Expression>
Traversing through the MSV expression tree using See depth-first_search similar to
reading the grammar in XML document order.
- First trying to get the child (going as deep as possible)
- Second if no child is available, trying to get the next sibling
- If no sibling available, get a sibling of the parent (going back to step 1)
Also has the ability to limit iteration to given subclasses and to limit subtree to the next element expressions below.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final boolean
static final boolean
-
Constructor Summary
ConstructorDescriptionMSVExpressionIterator
(com.sun.msv.grammar.Expression root) Iterate through the expression treeMSVExpressionIterator
(com.sun.msv.grammar.Expression root, Class desiredExpression) Iterate through the expression tree, but only return objects of desiredExpressionMSVExpressionIterator
(com.sun.msv.grammar.Expression root, Class desiredExpression, boolean onlyChildren) Iterate..., but only return objects of desiredExpression and (if not onlyChildren) don't go to children of ElementExp elements (this does not concern root node!). -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
ALL_SUBTREE
public static final boolean ALL_SUBTREE- See Also:
-
DIRECT_CHILDREN_ONLY
public static final boolean DIRECT_CHILDREN_ONLY- See Also:
-
-
Constructor Details
-
MSVExpressionIterator
public MSVExpressionIterator(com.sun.msv.grammar.Expression root) Iterate through the expression tree- Parameters:
root
- Expression root
-
MSVExpressionIterator
Iterate through the expression tree, but only return objects of desiredExpression- Parameters:
root
- Expression rootdesiredExpression
- Limit returned expressions to subclasses of desiredExpression
-
MSVExpressionIterator
public MSVExpressionIterator(com.sun.msv.grammar.Expression root, Class desiredExpression, boolean onlyChildren) Iterate..., but only return objects of desiredExpression and (if not onlyChildren) don't go to children of ElementExp elements (this does not concern root node!).Example: Root is table:table. If you choose onlyChildren=false and to limit desiredExpression=ElementExp.class, then you will get all direct element children of table:table, like table:table-row. But you won't get the children of table:table-row.
- Parameters:
root
- Expression rootdesiredExpression
- Limit returned expressions to subclasses of desiredExpressiononlyChildren
- if only children should be returned
-
-
Method Details
-
getDepth
public int getDepth() -
hasNext
public boolean hasNext() -
next
public com.sun.msv.grammar.Expression next() -
remove
public void remove()
-