Class MSVExpressionInformation

java.lang.Object
schema2template.grammar.MSVExpressionInformation

public class MSVExpressionInformation extends Object
Gather information from one MSV expression like:
  • which attributes are mandatory
  • which child elements are singletons
  • can it have text content
  • Constructor Summary

    Constructors
    Constructor
    Description
    MSVExpressionInformation(com.sun.msv.grammar.Expression exp, String schemaFileName)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Can the MSV expression have text content?
    Set<com.sun.msv.grammar.Expression>
    Returns all child elements which are no singletons
    List<List<com.sun.msv.grammar.Expression>>
    getPathsContaining(com.sun.msv.grammar.Expression exp)
    Gets all paths leading from this.getExpression() to exp (but not necessarily ending in exp).
    Set<com.sun.msv.grammar.Expression>
    Returns all singleton child elements
    boolean
    isMandatory(Collection<com.sun.msv.grammar.Expression> equallyNamedChildren)
    Determines whether an Element or Attribute child is mandatory.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MSVExpressionInformation

      public MSVExpressionInformation(com.sun.msv.grammar.Expression exp, String schemaFileName)
  • Method Details

    • getSingletons

      public Set<com.sun.msv.grammar.Expression> getSingletons()
      Returns all singleton child elements
      Returns:
      All child elements which can only occur one time
    • getMultiples

      public Set<com.sun.msv.grammar.Expression> getMultiples()
      Returns all child elements which are no singletons
      Returns:
      All child elements which can only occur one time
    • getPathsContaining

      public List<List<com.sun.msv.grammar.Expression>> getPathsContaining(com.sun.msv.grammar.Expression exp)
      Gets all paths leading from this.getExpression() to exp (but not necessarily ending in exp). A path always starts with this.getExpression() and ends in someChildDefinition.getExpression().
      Parameters:
      exp - The MSV Expression. If you use this.getExpression() you get all paths starting from this.getExpression(). If you use someChildDefinition.getExpression() you get all paths from this.getExpression() to the Expression of the Child Definition.
      Returns:
      A List of paths containing exp or null if there are no such paths
    • canHaveText

      public boolean canHaveText()
      Can the MSV expression have text content?
      Returns:
      true if the node defined by this can have text content
    • isMandatory

      public boolean isMandatory(Collection<com.sun.msv.grammar.Expression> equallyNamedChildren)
      Determines whether an Element or Attribute child is mandatory.

      If there are multiples of child (other equally named expressions) providing only one of those Expressions will determine whether exactly this expression is mandatory. In most cases this will return false, and in most cases this is not what you want to know. Therefore, you can provide a Collection of (equally named) child expressions.

      Returns:
      whether child is mandatory