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.

  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 Details

  • Constructor Details

    • 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 Details

    • getDepth

      public int getDepth()
    • 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>