Package schema2template.model
Class MSVExpressionIterator
- java.lang.Object
-
- schema2template.model.MSVExpressionIterator
-
- All Implemented Interfaces:
Iterator<com.sun.msv.grammar.Expression>
public final class MSVExpressionIterator extends Object implements Iterator<com.sun.msv.grammar.Expression>
Iterates through the MSV expression tree.Traversing the MSV Tree structure by 1) First trying to get the child (going as deep as possible) 2) Second if no child is available, trying to get the next sibling 3) 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
Fields Modifier and Type Field Description static boolean
ALL_SUBTREE
static boolean
DIRECT_CHILDREN_ONLY
int
mCurrentExpressionDepth
-
Constructor Summary
Constructors Constructor Description MSVExpressionIterator(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String
dumpMSVExpressionTree(com.sun.msv.grammar.Expression rootExpression)
int
getDepth()
boolean
hasNext()
com.sun.msv.grammar.Expression
next()
void
remove()
-
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 Detail
-
mCurrentExpressionDepth
public int mCurrentExpressionDepth
-
ALL_SUBTREE
public static final boolean ALL_SUBTREE
- See Also:
- Constant Field Values
-
DIRECT_CHILDREN_ONLY
public static final boolean DIRECT_CHILDREN_ONLY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MSVExpressionIterator
public MSVExpressionIterator(com.sun.msv.grammar.Expression root)
Iterate through the expression tree- Parameters:
root
- Expression root
-
MSVExpressionIterator
public MSVExpressionIterator(com.sun.msv.grammar.Expression root, Class desiredExpression)
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
-
-