|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sun.msv.verifier.regexp.ExpressionAcceptor
Acceptor
implementation.
When you are using REDocumentDeclaration
, then the acceptor
is always guaranteed to be a subclass of this class.
Therefore, by using this regexp implementation of VGM, you can always downcast
Acceptor
to this class and access its contents to get more information.
If you consider VGM as an automaton, this class can be thought as a lazy automaton acceptor.
Fields inherited from interface com.sun.msv.verifier.Acceptor |
STRING_IGNORE, STRING_PROHIBITED, STRING_STRICT |
Constructor Summary | |
ExpressionAcceptor(REDocumentDeclaration docDecl,
Expression exp,
boolean ignoreUndeclaredAttributes)
|
Method Summary | |
Acceptor |
createChildAcceptor(StartTagInfo tag,
StringRef errRef)
creates combined child acceptor and primitive child acceptors (if necessary). |
Expression |
getExpression()
gets the residual content model. |
int |
getStringCareLevel()
gets how this acceptor handles characters. |
boolean |
isAcceptState(StringRef errRef)
checks if this Acceptor is satisifed |
boolean |
onAttribute(String namespaceURI,
String localName,
String qName,
String value,
IDContextProvider context,
StringRef refErr,
DatatypeRef refType)
processes an attribute. |
boolean |
onEndAttributes(StartTagInfo sti,
StringRef refErr)
notifies the end of attributes. |
boolean |
onText(String literal,
IDContextProvider provider,
StringRef refErr,
DatatypeRef refType)
processes a string literal. |
boolean |
stepForwardByContinuation(Expression continuation,
StringRef errRef)
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.sun.msv.verifier.Acceptor |
createClone, getOwnerType, stepForward |
Constructor Detail |
public ExpressionAcceptor(REDocumentDeclaration docDecl, Expression exp, boolean ignoreUndeclaredAttributes)
Method Detail |
public Expression getExpression()
This method returns the expression that represents the expected content model it will read. For example, if the original content model is (A,(B|C)) and this acceptor has already read A, then this method returns (B|C).
The returned residual is useful to find out what elements can appear next.
If you consider VGM as an automaton, the residual content model can be thought as the current state. Also, At the same time, right language (a regular expression that represents the language it can accept from now on).
public Acceptor createChildAcceptor(StartTagInfo tag, StringRef errRef)
createChildAcceptor
in interface Acceptor
public final boolean onAttribute(String namespaceURI, String localName, String qName, String value, IDContextProvider context, StringRef refErr, DatatypeRef refType)
Acceptor
For every attribute present in the document, you need to call this method.
An error at this method typically indicates that
onAttribute
in interface Acceptor
com.sun.msv.verifier.Acceptor
refErr
- In case of an error, this object will receive the localized error
message. Null is a valid value for this parameter.
The implementation must provide some kind of message.refType
- If this parameter is non-null, this object will receive the datatype
assigned to the attribute value.
This feature is optional and therefore the implementation is not necessarily provide this information.
public boolean onEndAttributes(StartTagInfo sti, StringRef refErr)
Acceptor
This method needs to be called after the Acceptor.onAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String, com.sun.msv.grammar.IDContextProvider, com.sun.msv.util.StringRef, com.sun.msv.util.DatatypeRef)
method is called for each present attribute.
An error at this method typically indicates that some required attributes are missing.
onEndAttributes
in interface Acceptor
com.sun.msv.verifier.Acceptor
sti
- This information is used to produce the error message if that is
necessary.refErr
- In case of an error, this object will receive the localized error
message. Null is a valid value for this parameter.
The implementation must provide some kind of message.public boolean onText(String literal, IDContextProvider provider, StringRef refErr, DatatypeRef refType)
Acceptor
onText
in interface Acceptor
com.sun.msv.verifier.Acceptor
context
- an object that provides context information necessary to validate
some datatypes.refErr
- if this parameter is non-null, the implementation should
try to detect the reason of error and recover from it.
and this object should have the error message as its str field.refType
- if this parameter is non-null and the callee supports
type-assignment, the callee will assign the DataType object
to this variable.
Caller must initialize refType.type to null before calling this method.
If the callee doesn't support type-assignment or type-assignment
is impossible for this literal (possibly by ambiguous grammar),
this variable must kept null.public final boolean stepForwardByContinuation(Expression continuation, StringRef errRef)
public boolean isAcceptState(StringRef errRef)
isAcceptState
in interface Acceptor
com.sun.msv.verifier.Acceptor
errRef
- If this value is non-null, implementation can diagnose the error
and sets the message to the object.public int getStringCareLevel()
Acceptor
This method makes it possible to optimize character handling. For many elements of data-oriented schemas, characters are completely prohibited. For example, In SVG, only handful elements are allowed to have #PCDATA and all other elements have element-only content model. Also, for many elements of document-oriented schemas, #PCDATA is allowed just about anywhere.
In the former case, this method returns Acceptor.STRING_PROHIBITED
.
In other words, this declares that any onText(String) method with
non-whitespace characters will always result in a failure.
The caller can then exploit this property of the content model and
can immediately signal an error when it finds characters, or discard any
whitespace characters without keeping them in memory.
In the latter case, this method returns Acceptor.STRING_IGNORE
.
This declares that any onText(String) call does not change anything at all.
The caller can then exploit this property and discard any characeters it found.
If non of the above applies, or the implementation is simply not capable of
providing this information, then this method returns Acceptor.STRING_STRICT
.
In this case, the caller has to faithfully call the onText(String) method
for all characeters it found.
Although this method can be called anytime, it is intended to be called only once when the acceptor is first created.
getStringCareLevel
in interface Acceptor
com.sun.msv.verifier.Acceptor
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |