schema2template.model
Class MSVExpressionIterator

java.lang.Object
  extended by 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
static boolean ALL_SUBTREE
           
static boolean DIRECT_CHILDREN_ONLY
           
 int mCurrentExpressionDepth
           
 
Constructor Summary
MSVExpressionIterator(com.sun.msv.grammar.Expression root)
          Iterate through the expression tree
MSVExpressionIterator(com.sun.msv.grammar.Expression root, Class desiredExpression)
          Iterate through the expression tree, but only return objects of desiredExpression
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!).
 
Method Summary
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
 

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 root
desiredExpression - 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 root
desiredExpression - Limit returned expressions to subclasses of desiredExpression
onlyChildren - if only children should be returned
Method Detail

getDepth

public int getDepth()

dumpMSVExpressionTree

public static String dumpMSVExpressionTree(com.sun.msv.grammar.Expression rootExpression)
                                    throws Exception
Throws:
Exception

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<com.sun.msv.grammar.Expression>

next

public com.sun.msv.grammar.Expression next()
Specified by:
next in interface Iterator<com.sun.msv.grammar.Expression>

remove

public void remove()
Specified by:
remove in interface Iterator<com.sun.msv.grammar.Expression>


Copyright © 2010-2011 The Apache Software Foundation. All Rights Reserved.