org.apache.xerces.impl.xs.models
Class XSDFACM

java.lang.Object
  extended by org.apache.xerces.impl.xs.models.XSDFACM
All Implemented Interfaces:
XSCMValidator

public class XSDFACM
extends java.lang.Object
implements XSCMValidator

DFAContentModel is the implementation of XSCMValidator that does all of the non-trivial element content validation. This class does the conversion from the regular expression to the DFA that it then uses in its validation algorithm.

Version:
$Id: XSDFACM.java 806363 2009-08-20 21:18:48Z mrglavas $
Author:
Neil Graham, IBM

INTERNAL:

Usage of this class is not supported. It may be altered or removed at any time.

Field Summary
 
Fields inherited from interface org.apache.xerces.impl.xs.models.XSCMValidator
FIRST_ERROR, SUBSEQUENT_ERROR
 
Constructor Summary
XSDFACM(CMNode syntaxTree, int leafCount)
          Constructs a DFA content model.
 
Method Summary
 boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler)
          check whether this content violates UPA constraint.
 boolean endContentModel(int[] state)
          The method indicates the end of list of children
 java.lang.String getTermName(int termId)
          Returns the name of the term (element or wildcard) for the given identifier.
 boolean isCompactedForUPA()
          Checks if this content model has had its min/maxOccurs values reduced for purposes of speeding up UPA.
 boolean isFinalState(int state)
          check whether the given state is one of the final states
 int[] occurenceInfo(int[] state)
          Returns an array containing information about the current repeating term or null if no occurrence counting was being performed at the current state.
 java.lang.Object oneTransition(org.apache.xerces.xni.QName curElem, int[] state, SubstitutionGroupHandler subGroupHandler)
          one transition only
 int[] startContentModel()
          This methods to be called on entering a first element whose type has this content model.
 java.util.Vector whatCanGoHere(int[] state)
          Check which elements are valid to appear at this point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XSDFACM

public XSDFACM(CMNode syntaxTree,
               int leafCount)
Constructs a DFA content model.

Parameters:
syntaxTree - The syntax tree of the content model.
leafCount - The number of leaves.
Throws:
java.lang.RuntimeException - Thrown if DFA can't be built.
Method Detail

isFinalState

public boolean isFinalState(int state)
check whether the given state is one of the final states

Parameters:
state - the state to check
Returns:
whether it's a final state

oneTransition

public java.lang.Object oneTransition(org.apache.xerces.xni.QName curElem,
                                      int[] state,
                                      SubstitutionGroupHandler subGroupHandler)
one transition only

Specified by:
oneTransition in interface XSCMValidator
Parameters:
curElem - The current element's QName
state - stack to store the previous state
subGroupHandler - the substitution group handler
Returns:
null if transition is invalid; otherwise the Object corresponding to the XSElementDecl or XSWildcardDecl identified. Also, the state array will be modified to include the new state; this so that the validator can store it away.
Throws:
java.lang.RuntimeException - thrown on error

startContentModel

public int[] startContentModel()
Description copied from interface: XSCMValidator
This methods to be called on entering a first element whose type has this content model. It will return the initial state of the content model

Specified by:
startContentModel in interface XSCMValidator
Returns:
Start state of the content model

endContentModel

public boolean endContentModel(int[] state)
Description copied from interface: XSCMValidator
The method indicates the end of list of children

Specified by:
endContentModel in interface XSCMValidator
Parameters:
state - Current state of the content model
Returns:
true if the last state was a valid final state

checkUniqueParticleAttribution

public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler)
                                       throws XMLSchemaException
check whether this content violates UPA constraint.

Specified by:
checkUniqueParticleAttribution in interface XSCMValidator
Parameters:
subGroupHandler - the substitution group handler
Returns:
true if this content model contains other or list wildcard
Throws:
XMLSchemaException

whatCanGoHere

public java.util.Vector whatCanGoHere(int[] state)
Check which elements are valid to appear at this point. This method also works if the state is in error, in which case it returns what should have been seen.

Specified by:
whatCanGoHere in interface XSCMValidator
Parameters:
state - the current state
Returns:
a Vector whose entries are instances of either XSWildcardDecl or XSElementDecl.

occurenceInfo

public int[] occurenceInfo(int[] state)
Description copied from interface: XSCMValidator

Returns an array containing information about the current repeating term or null if no occurrence counting was being performed at the current state.

If an array is returned it will have a length == 4 and will contain:

Specified by:
occurenceInfo in interface XSCMValidator
Parameters:
state - the current state
Returns:
an array containing information about the current repeating term

getTermName

public java.lang.String getTermName(int termId)
Description copied from interface: XSCMValidator
Returns the name of the term (element or wildcard) for the given identifier.

Specified by:
getTermName in interface XSCMValidator
Parameters:
termId - identifier for the element declaration or wildcard
Returns:
the name of the element declaration or wildcard

isCompactedForUPA

public boolean isCompactedForUPA()
Description copied from interface: XSCMValidator
Checks if this content model has had its min/maxOccurs values reduced for purposes of speeding up UPA. If so, this content model should not be used for any purpose other than checking unique particle attribution

Specified by:
isCompactedForUPA in interface XSCMValidator
Returns:
a boolean that says whether this content has been compacted for UPA


Copyright 1999-2010 The Apache Software Foundation. All Rights Reserved.