sk.uniba.euromath.document.schema.impl.tools
Class ExpFinder

java.lang.Object
  extended by sk.uniba.euromath.document.schema.impl.tools.ExpFinder

public final class ExpFinder
extends Object

This class is capable of returning (for a particular element node) the MSV expression, that generates its children.

Author:
Martin Vysny

Constructor Summary
ExpFinder(SchemaImpl schema)
          Constructs the class, which will be working with this grammar.
 
Method Summary
 com.sun.msv.grammar.ElementExp getExpression(Element e, ExpFinderLevel level)
          Returns the ElementExp expression, that may validate element e.
 Set<com.sun.msv.grammar.ElementExp> getExpressionSet(Element e, ExpFinderLevel level, boolean validOnly)
           Returns set of ElementExp expression, that can be used to generate element e.
 Set<com.sun.msv.grammar.ElementExp> getParents(com.sun.msv.grammar.ElementExp exp)
          Returns all possible parent element expressions of given element expression.
 Set<com.sun.msv.grammar.ElementExp> getParents(Set<com.sun.msv.grammar.ElementExp> elementExps)
          Returns all possible parent element expressions of all given element expressions.
 boolean isContextFree(String localName)
          Checks if there is more than one ElementExp instance, that can generate element with specified local name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpFinder

public ExpFinder(SchemaImpl schema)
Constructs the class, which will be working with this grammar.

Parameters:
schema - SchemaImpl instance.
Method Detail

getExpression

public com.sun.msv.grammar.ElementExp getExpression(Element e,
                                                    ExpFinderLevel level)
Returns the ElementExp expression, that may validate element e. The function acts as if the validOnly==false.

Parameters:
e - The element.
level - level of test. For details see getExpressionSet.
Returns:
ElementExp validating given element.
Throws:
IllegalStateException - thrown when there are multiple rules on this level
DocumentValidityException - if no expression is suitable for given element.

isContextFree

public boolean isContextFree(String localName)
                      throws DocumentValidityException
Checks if there is more than one ElementExp instance, that can generate element with specified local name.

Parameters:
localName - Element's local name.
Returns:
true if there is exactly one rule, capable of generating such element.
Throws:
DocumentValidityException - thrown if no elementexp exists for such local name.

getExpressionSet

public Set<com.sun.msv.grammar.ElementExp> getExpressionSet(Element e,
                                                            ExpFinderLevel level,
                                                            boolean validOnly)

Returns set of ElementExp expression, that can be used to generate element e. Level parameter describes depth of test for each result, as described in the LEVEL_ constants.

Parameter validOnly controls the real validness of rules. If false is specified, and exactly one expression had been found, then element can have only this rule, and such is returned. That means that higher level tests aren't performed, even when required by the level parameter. Thus, if lower test returned one expression, this is returned without validity checks. This is ideal, when we are sure that document is valid. On the other side, if true is given, then all required tests are performed, regardless of result.

Warning: even when most restrictive tests are performed, we still can't be sure that returned expressions are really used to generate given element. More precisely, we can be sure that result is correct, when one of following is true:

Parameters:
e - The element.
level - describes level of tests, that will be applied on result rules, if needed.
validOnly - if true, then only really valid expressions are returned. If false, function may execute more faster.
Returns:
Set of ElementExp validating given element, may be empty set, but never null.

getParents

public Set<com.sun.msv.grammar.ElementExp> getParents(Set<com.sun.msv.grammar.ElementExp> elementExps)
Returns all possible parent element expressions of all given element expressions.

Parameters:
elementExps - set of element expressions.
Returns:
set of parent ElementExp s of all given elements.

getParents

public Set<com.sun.msv.grammar.ElementExp> getParents(com.sun.msv.grammar.ElementExp exp)
Returns all possible parent element expressions of given element expression.

Parameters:
exp - element expression.
Returns:
unmodifiable set of parent ElementExp s of given element.


Copyright © 2003-2006 null. All Rights Reserved.