Class ExpressionAcceptor

java.lang.Object
com.sun.msv.verifier.regexp.ExpressionAcceptor
All Implemented Interfaces:
Acceptor
Direct Known Subclasses:
ContentModelAcceptor

public abstract class ExpressionAcceptor extends Object implements Acceptor
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.

Author:
Kohsuke KAWAGUCHI
  • Field Details

    • docDecl

      protected final REDocumentDeclaration docDecl
      this object provides various function objects
    • ignoreUndeclaredAttributes

      protected final boolean ignoreUndeclaredAttributes
      If true, this acceptor will ignore all undeclared attributes. If false, this acceptor will signal an error for an undeclared attribute.

      This flag is used to implement the semantics of RELAX Core, where undeclared attributes are allowed.

  • Constructor Details

  • Method Details

    • getExpression

      public Expression getExpression()
      gets the residual content model.

      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).

    • createChildAcceptor

      public Acceptor createChildAcceptor(StartTagInfo tag, StringRef errRef)
      creates combined child acceptor and primitive child acceptors (if necessary). be careful not to keep returned object too long because it is reused whenever the method is called.
      Specified by:
      createChildAcceptor in interface Acceptor
      Parameters:
      tag - this parameter provides the information about the start tag to the acceptor object. Usually attribute information is ignored, but sometimes they are used as hints.
      errRef - 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.
      Returns:
      null if errRef is null and this expression cannot accept given start tag. if errRef is non-null and error recovery is not possible.
    • createAcceptor

      protected abstract Acceptor createAcceptor(Expression contentModel, Expression continuation, ElementExp[] primitives, int numPrimitives)
    • onAttribute

      public final boolean onAttribute(String namespaceURI, String localName, String qName, String value, IDContextProvider context, StringRef refErr, DatatypeRef refType)
      Deprecated.
      Specified by:
      onAttribute in interface Acceptor
    • onAttribute2

      public final boolean onAttribute2(String namespaceURI, String localName, String qName, String value, IDContextProvider2 context, StringRef refErr, DatatypeRef refType)
      Description copied from interface: Acceptor
      processes an attribute.

      For every attribute present in the document, you need to call this method.

      An error at this method typically indicates that

      1. this attribute is not allowed to appear here
      2. the attribute name was OK, but the value was incorrect.
      Specified by:
      onAttribute2 in interface 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.

      Returns:
      false if an error happens and refErr parameter was not provided. Otherwise true.
    • onAttribute

      protected boolean onAttribute(AttributeToken token, StringRef refErr)
    • onEndAttributes

      public boolean onEndAttributes(StartTagInfo sti, StringRef refErr)
      Description copied from interface: Acceptor
      notifies the end of attributes.

      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.

      Specified by:
      onEndAttributes in interface Acceptor
      Parameters:
      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.
      Returns:
      false if an error happens and refErr parameter was not provided. Otherwise true.
    • stepForward

      protected boolean stepForward(Token token, StringRef errRef)
    • onText

      public final boolean onText(String literal, IDContextProvider context, StringRef refErr, DatatypeRef refType)
      Deprecated.
      Specified by:
      onText in interface Acceptor
    • onText2

      public boolean onText2(String literal, IDContextProvider2 provider, StringRef refErr, DatatypeRef refType)
      Description copied from interface: Acceptor
      processes a string literal.
      Specified by:
      onText2 in interface Acceptor
      provider - 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.
      Returns:
      false if the literal at this position is not allowed.
    • stepForwardByContinuation

      public final boolean stepForwardByContinuation(Expression continuation, StringRef errRef)
    • isAcceptState

      public boolean isAcceptState(StringRef errRef)
      checks if this Acceptor is satisifed
      Specified by:
      isAcceptState in interface Acceptor
      Parameters:
      errRef - If this value is non-null, implementation can diagnose the error and sets the message to the object.
    • getStringCareLevel

      public int getStringCareLevel()
      Description copied from interface: Acceptor
      gets how this acceptor handles characters.

      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.

      Specified by:
      getStringCareLevel in interface Acceptor
      Returns:
      one of the three constant values shown below.
    • diagnoseUncompletedContent

      protected String diagnoseUncompletedContent()
      diagnoses "uncompleted content model" error. It basically provides what we were expected.