com.objsys.asn1j.runtime
Class Asn1XerSaxHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by com.objsys.asn1j.runtime.Asn1XerSaxHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler
Direct Known Subclasses:
Asn1OpenType.SaxHandler, Asn1XmlAnyElem.XsdAnySaxHandler, Asn1XmlSaxSimpleType

public class Asn1XerSaxHandler
extends org.xml.sax.helpers.DefaultHandler

This class extends the DefaultHandler SAX handler class to add items specific to ASN.1 XER encoding.


Field Summary
protected  boolean mConsumedStartElement
           
protected  int mCurrElemID
           
protected  int mCurrState
           
protected  int mLevel
           
protected  int mStartLevel
           
protected  java.lang.String mXMLElemName
           
protected  int XERDATA
           
protected  int XEREND
           
protected  int XERINIT
           
protected  int XERSTART
           
protected  int XERUNKNOWN
           
 
Constructor Summary
protected Asn1XerSaxHandler()
           
 
Method Summary
 boolean consumeStartElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
          This method should be used in preference to invoking startElement directly when a parent SAX handler is delegating to a child SAX handler.
 void endGroup()
          This event method should be invoked when the group being decoded by this handler is decided to be complete.
 void error(org.xml.sax.SAXParseException exception)
           
 void fatalError(org.xml.sax.SAXParseException exception)
           
 int getState()
           
 void init(int startLevel)
           
 boolean isComplete()
          Returns true when the SAX handler has finished decoding the group.
 boolean isDecodingAsGroup()
          Return true if this SAX handler is decoding a group of elements rather than a single element (and possibly its children elements).
 boolean matchXMLElemName(java.lang.String elemName)
           
 void setComplete()
          Invoke this method to mark this SAX handler as being complete.
 void setLevel(int startLevel)
           
 void setXMLElemName(java.lang.String value)
           
 void warning(org.xml.sax.SAXParseException exception)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XERUNKNOWN

protected final int XERUNKNOWN
See Also:
Constant Field Values

XERINIT

protected final int XERINIT
See Also:
Constant Field Values

XERSTART

protected final int XERSTART
See Also:
Constant Field Values

XERDATA

protected final int XERDATA
See Also:
Constant Field Values

XEREND

protected final int XEREND
See Also:
Constant Field Values

mCurrState

protected int mCurrState

mCurrElemID

protected int mCurrElemID

mLevel

protected int mLevel

mStartLevel

protected int mStartLevel

mXMLElemName

protected java.lang.String mXMLElemName

mConsumedStartElement

protected boolean mConsumedStartElement
Constructor Detail

Asn1XerSaxHandler

protected Asn1XerSaxHandler()
Method Detail

getState

public int getState()

init

public void init(int startLevel)

endGroup

public void endGroup()
              throws org.xml.sax.SAXException
This event method should be invoked when the group being decoded by this handler is decided to be complete. Subclasses may implement this event method to do things such as check for missing required elements. This event will be triggerd, when appropriate, by consumeStartElement. Subclasses may invoke it directly when appropriate, but the preferred method is to invoke it indirectly by invoking setComplete.

Throws:
org.xml.sax.SAXException

consumeStartElement

public final boolean consumeStartElement(java.lang.String namespaceURI,
                                         java.lang.String localName,
                                         java.lang.String qName,
                                         org.xml.sax.Attributes atts)
                                  throws org.xml.sax.SAXException
This method should be used in preference to invoking startElement directly when a parent SAX handler is delegating to a child SAX handler. Using this method gives the startElement method the opportunity to set the mConsumedStartEvent flag to false to signal that the given element does not belong to the group and that the group is complete. This method invokes the startElement event and returns the resulting value of the mConsumedStartElement flag (true, unless the startElement method explicitly sets it to false). If mConsumedStartElement is set to false, this method will invoke setComplete, marking the handler complete and triggering the endGroup event, if it has not already fired. If the startElement method is certain that some other element is required instead of the one given, it is preferable to throw Asn1XmlSaxUnexpElemExc to indicate this. Otherwise, if the given element does not belong to the group being decoded, mConsumedStartElement can be be set false and the element ignored. It is then up to the parent SAX handler to recognize the element as part of a different group or report it as an unexpected element. The startElement method should not set mConsumedStartEvent false except when mLevel <= mStartLevel, since this is a precondition for setComplete.

Throws:
Asn1XmlSaxUnexpElemExc - if certain that some other element is expected.
org.xml.sax.SAXException

isComplete

public final boolean isComplete()
Returns true when the SAX handler has finished decoding the group.


isDecodingAsGroup

public final boolean isDecodingAsGroup()
Return true if this SAX handler is decoding a group of elements rather than a single element (and possibly its children elements).


setComplete

public final void setComplete()
                       throws org.xml.sax.SAXException
Invoke this method to mark this SAX handler as being complete. This method will trigger the endGroup event, if it has not already fired. This is the preferred way for a subclass to trigger the endGroup event, rather than to invoke endGroup directly (mainly for consistency). Subclasses should consider invoking this method in the endElement event when either of the following conditions obtain: - mLevel returns to 0 (indicating the group must be complete) - The group is self-delimiting and known to be complete on that basis This method should only be invoked when mLevel <= mStartLevel. Otherwise, the handler could not possibly be complete (note that mLevel == mStartLevel does not entail the handler is complete, because this is a normal state of affairs between elements when decoding a group).

Throws:
java.lang.IllegalStateException - if mLevel != mStartLevel.
org.xml.sax.SAXException

setLevel

public void setLevel(int startLevel)

warning

public void warning(org.xml.sax.SAXParseException exception)
             throws org.xml.sax.SAXException
Specified by:
warning in interface org.xml.sax.ErrorHandler
Overrides:
warning in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

error

public void error(org.xml.sax.SAXParseException exception)
           throws org.xml.sax.SAXException
Specified by:
error in interface org.xml.sax.ErrorHandler
Overrides:
error in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

fatalError

public void fatalError(org.xml.sax.SAXParseException exception)
                throws org.xml.sax.SAXException
Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Overrides:
fatalError in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

matchXMLElemName

public boolean matchXMLElemName(java.lang.String elemName)

setXMLElemName

public void setXMLElemName(java.lang.String value)