Class 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 Detail

      • mCurrentExpressionDepth

        public int mCurrentExpressionDepth
    • 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>