com.sun.msv.verifier.regexp

Class CombinedChildContentExpCreator

public class CombinedChildContentExpCreator extends Object implements ExpressionVisitorVoid

creates "combined child content expression" and gathers "elements of concern" and its "attribute-pruned" content model. Intuitively, "combined child content expression" is a set of content models of "elements of concern", which is appropriately combined to express dependency between elements. "Elements of concern" are ElementExps that are possibly applicable to the next element. These gathered element declarations are then tested against next XML element. "Attribute-pruned" content model is a content model after consuming AttributeTokens and removing unused AttributeExp nodes.

For example, when the current expression is

    <!-- javadoc escape -->
   <choice>
     <concur>
       <element> ..(A).. </element>
       <group>
         <element> ..(B).. </element>
         ...
       </group>
     </concur>
     <group>
       <element> ..(C).. </element>
       ....
     </group>
   </choice>
 
then the combined child expression is

   <choice>
     <concur>
       ..(A').. 
       ..(B').. 
     </concur>
     ..(C').. 
   </choice>
 
and elements of concern and its attribute-pruned content models are <element> ..(A).. </element> -> ..(A').. <element> ..(B).. </element> -> ..(B').. <element> ..(C).. </element> -> ..(C').. (A'),(B'), and (C') are attribute-pruned content models of (A),(B), and (C) respectively. Note that combined child pattern contains only <choice> and <concur> as its grue (of course, except ..(A').. , ..(B').. , and ..(C').. ). This function object also calculates "continuation", which is the residual expression after eating elements of concern. For example, say the expression is "(A|(B,C))?,D". When EoC is B, then the continuation will be C,D. When EoC is A, then the continuation will be D. When EoC is D, then the continuation will be epsilon. When there are multiple EoC, (say A and B), then the continuation will be meaningless (because it depends on which EoC will be accepted), and thus won't be used. However, the implementator must be aware that it is possible for a binary operator to have EoC on both branch and EoC is still unique. The following expression is an example. (A|B)*,C?,(A|B)* when A is EoC, SequenceExp of (A|B)* and C?,(A|B)* has EoC on both branch.

Author: Kohsuke KAWAGUCHI

Nested Class Summary
static classCombinedChildContentExpCreator.ExpressionPair
Method Summary
CombinedChildContentExpCreator.ExpressionPaircontinueGet(Expression combinedPattern, StartTagInfo info, boolean checkTagName)
CombinedChildContentExpCreator.ExpressionPairget(Expression combinedPattern, StartTagInfo info, boolean checkTagName)
computes a combined child content pattern and its continuation, with error recovery.
CombinedChildContentExpCreator.ExpressionPairget(Expression combinedPattern, StartTagInfo info)
computes a combined child content pattern and (,if possible,) its continuation.
ElementExp[]getMatchedElements()
obtains matched elements.
booleanisComplex()
checks if the result of 'get' method is not the union of all elements of concern.
intnumMatchedElements()
gets the number of matched elements.
voidonAnyString()
voidonAttribute(AttributeExp exp)
voidonChoice(ChoiceExp exp)
voidonConcur(ConcurExp exp)
voidonData(DataExp exp)
voidonElement(ElementExp exp)
voidonEpsilon()
voidonInterleave(InterleaveExp exp)
voidonList(ListExp exp)
voidonMixed(MixedExp exp)
voidonNullSet()
voidonOneOrMore(OneOrMoreExp exp)
voidonOther(OtherExp exp)
voidonRef(ReferenceExp exp)
voidonSequence(SequenceExp exp)
voidonValue(ValueExp exp)

Method Detail

continueGet

public final CombinedChildContentExpCreator.ExpressionPair continueGet(Expression combinedPattern, StartTagInfo info, boolean checkTagName)

get

public CombinedChildContentExpCreator.ExpressionPair get(Expression combinedPattern, StartTagInfo info, boolean checkTagName)
computes a combined child content pattern and its continuation, with error recovery. After calling this method, caller can call getElementsOfConcern to obtain each EoC. If both feedAttributes and checkTagName are false, then StartTagInfo is also unnecessary.

Parameters: feedAttributes if this flag is false, Attribute feeding & pruning are skipped and AttributeExps are fully remained in the resulting expression. checkTagName if this flag is false, tag name check is skipped.

get

public CombinedChildContentExpCreator.ExpressionPair get(Expression combinedPattern, StartTagInfo info)
computes a combined child content pattern and (,if possible,) its continuation.

getMatchedElements

public final ElementExp[] getMatchedElements()
obtains matched elements. This method should be called after calling the get method. The result is in effect until the next invocation of get method.

The extra care should be taken not to hold reference to the result longer than necessary. The contents of the result is valid only until the next invocation. Because OwnerAndContent objects are reused.

Apparently this is a bad design, but this design gives us better performance.

isComplex

public final boolean isComplex()
checks if the result of 'get' method is not the union of all elements of concern. Within this class, combined child content expression is always the union of all elements of concern. However, some derived class does not guarantee this property.

Returns: true if the combined child content expression is not the union of all elements of concern. false if otherwise.

numMatchedElements

public final int numMatchedElements()
gets the number of matched elements. This method should be called after calling get method. The result is in effect until next invocation of get method. Apparently this is a bad design, but this design gives us better performance.

onAnyString

public void onAnyString()

onAttribute

public void onAttribute(AttributeExp exp)

onChoice

public void onChoice(ChoiceExp exp)

onConcur

public void onConcur(ConcurExp exp)

onData

public void onData(DataExp exp)

onElement

public void onElement(ElementExp exp)

onEpsilon

public void onEpsilon()

onInterleave

public void onInterleave(InterleaveExp exp)

onList

public void onList(ListExp exp)

onMixed

public void onMixed(MixedExp exp)

onNullSet

public void onNullSet()

onOneOrMore

public void onOneOrMore(OneOrMoreExp exp)

onOther

public void onOther(OtherExp exp)

onRef

public void onRef(ReferenceExp exp)

onSequence

public void onSequence(SequenceExp exp)

onValue

public void onValue(ValueExp exp)