org.sandev.TaskHeap.util
Class XMLStandardReader

java.lang.Object
  extended by org.sandev.TaskHeap.util.XMLStandardReader
All Implemented Interfaces:
org.xml.sax.ContentHandler

public class XMLStandardReader
extends java.lang.Object
implements org.xml.sax.ContentHandler

A utility to read a SandMessage from XML using a SAX parser. This is higher overhead but more forgiving than what the XMLSerializer does. Reads a single SandMesssage, which may be a SandCollectionMessage. AUTOGENERATED FILE, DO NOT EDIT DIRECTLY.
source: declared in build
generator: org.sandev.generator.XMLStandardReaderGenerator
time: Jul 31, 2008 4:34:17 PM


Field Summary
protected  java.util.ArrayList context
          A stack of context entries.
protected  java.lang.String currElem
          The qualified name of the current element we are reading while parsing the XML.
protected  org.xml.sax.Locator documentLocator
          During a callback method implementation, the locator can be used to report where you are in the XML file.
 
Constructor Summary
XMLStandardReader()
           
 
Method Summary
protected  void addMessageToParentInContext(org.sandev.basics.structs.SandMessage child)
          Add the given message to the appropriate contained field in the parent message, which is the last entry in the context stack.
 void characters(char[] ch, int start, int length)
          Receive notification of character data.
 void endDocument()
          Receive notification of the end of a document.
 void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
          Receive notification of the end of an element
 void endPrefixMapping(java.lang.String prefix)
          Hook for notifying close of prefix mapping.
protected  org.sandev.TaskHeap.util.XMLStandardReader.SMContext getCurrContext()
          Return the current SMContext we are working with.
 org.xml.sax.Locator getDocumentLocator()
          accessor for documentLocator
protected  java.lang.String getFullClassName(java.lang.String name)
          Given the short name of a SandMessage, return the fully qualified class name.
 org.sandev.basics.structs.SandMessage getMessageFromXML(java.lang.String xml)
          Returns the SandMessage read from the given XML.
protected  org.sandev.basics.structs.SandMessage getSandMessageForName(java.lang.String name)
          Given the fully qualified name of a SandMessage, return an instance of that message or throw.
 void ignorableWhitespace(char[] ch, int start, int length)
          Receive notification of ignorable whitespace in element content.
protected static void info(java.lang.String text)
          For messages outside of normal operation that are helpful to log.
protected  org.sandev.basics.structs.SandMessage popMessageContext()
          Pop the last SMContext off the stack and return its SandMessage.
 void processingInstruction(java.lang.String target, java.lang.String data)
          Receive notification of a processing instruction.
protected  void pushMessageContext(org.sandev.basics.structs.SandMessage sm, int index)
          Create a new SMContext instance and push it onto our context stack.
protected static void readTrace(java.lang.String text)
          Body of method can be uncommented to produce a trace of the message read processing
 void setDocumentLocator(org.xml.sax.Locator loc)
          mutator for documentLocator
protected  void setFieldValuesFromAttributes(org.sandev.basics.structs.SandMessage sm, org.xml.sax.Attributes atts)
          Read the attributes and set the field values in the given message accordingly.
 void skippedEntity(java.lang.String name)
          Receive notification of a skipped entity.
 void startDocument()
          Receive notification of the beginning of a document.
 void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
          Receive notification of the beginning of an element
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
          Hook for handling prefix URIs for Namespace expansion.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currElem

protected java.lang.String currElem
The qualified name of the current element we are reading while parsing the XML. Used for debug tracing the tree as we read it.


context

protected java.util.ArrayList context
A stack of context entries.


documentLocator

protected org.xml.sax.Locator documentLocator
During a callback method implementation, the locator can be used to report where you are in the XML file. This may be null, and it is not valid to refer to it outside of the scope of one of the callback methods.

Constructor Detail

XMLStandardReader

public XMLStandardReader()
Method Detail

getMessageFromXML

public org.sandev.basics.structs.SandMessage getMessageFromXML(java.lang.String xml)
                                                        throws org.sandev.basics.structs.SandException
Returns the SandMessage read from the given XML. Throws if anything goes wrong.

Throws:
org.sandev.basics.structs.SandException

getDocumentLocator

public org.xml.sax.Locator getDocumentLocator()
accessor for documentLocator


setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator loc)
mutator for documentLocator

Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Receive notification of the beginning of a document.

Specified by:
startDocument in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

endDocument

public void endDocument()
Receive notification of the end of a document.

Specified by:
endDocument in interface org.xml.sax.ContentHandler

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
                        throws org.xml.sax.SAXException
Hook for handling prefix URIs for Namespace expansion. Does nothing.

Specified by:
startPrefixMapping in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

endPrefixMapping

public void endPrefixMapping(java.lang.String prefix)
                      throws org.xml.sax.SAXException
Hook for notifying close of prefix mapping. Does nothing.

Specified by:
endPrefixMapping in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
Receive notification of the beginning of an element

Specified by:
startElement in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Receive notification of the end of an element

Specified by:
endElement in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Receive notification of character data.

Specified by:
characters in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws org.xml.sax.SAXException
Receive notification of ignorable whitespace in element content. Does nothing.

Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
Receive notification of a processing instruction. Does nothing.

Specified by:
processingInstruction in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

skippedEntity

public void skippedEntity(java.lang.String name)
                   throws org.xml.sax.SAXException
Receive notification of a skipped entity. Does nothing.

Specified by:
skippedEntity in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

readTrace

protected static void readTrace(java.lang.String text)
Body of method can be uncommented to produce a trace of the message read processing


info

protected static void info(java.lang.String text)
For messages outside of normal operation that are helpful to log.


getSandMessageForName

protected org.sandev.basics.structs.SandMessage getSandMessageForName(java.lang.String name)
                                                               throws org.xml.sax.SAXException
Given the fully qualified name of a SandMessage, return an instance of that message or throw.

Throws:
org.xml.sax.SAXException

getFullClassName

protected java.lang.String getFullClassName(java.lang.String name)
Given the short name of a SandMessage, return the fully qualified class name.


setFieldValuesFromAttributes

protected void setFieldValuesFromAttributes(org.sandev.basics.structs.SandMessage sm,
                                            org.xml.sax.Attributes atts)
                                     throws org.xml.sax.SAXException
Read the attributes and set the field values in the given message accordingly. Throws if something was not understood.

Throws:
org.xml.sax.SAXException

pushMessageContext

protected void pushMessageContext(org.sandev.basics.structs.SandMessage sm,
                                  int index)
Create a new SMContext instance and push it onto our context stack.


popMessageContext

protected org.sandev.basics.structs.SandMessage popMessageContext()
Pop the last SMContext off the stack and return its SandMessage.


getCurrContext

protected org.sandev.TaskHeap.util.XMLStandardReader.SMContext getCurrContext()
Return the current SMContext we are working with.


addMessageToParentInContext

protected void addMessageToParentInContext(org.sandev.basics.structs.SandMessage child)
                                    throws org.xml.sax.SAXException
Add the given message to the appropriate contained field in the parent message, which is the last entry in the context stack.

Throws:
org.xml.sax.SAXException