Class OMXMLReader
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.episteme.core.mathematics.loaders.openmath.io.OMXMLReader
- All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler
Constructs an OpenMath Object (OMObject) from the XML-input.
- Version:
- $Revision: 1.2 $
- Author:
- Manfred Riem (mriem@manorrock.org)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intStores if we are inside a foreign object section.protected booleanStores if we should keep the outer OMOBJ.Stores an vector with the last active element as the last in the vector.protected InputSourceStores the input-source.protected OMObjectStores the OMObject for this reader.protected static String[]Stores a static array with all the OpenMath element-names in use. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.OMXMLReader(String fString) Constructor taking a String as the InputSource.OMXMLReader(String newString, boolean newKeep) Constructor taking a String as the InputSource and a boolean indicating if we want to keep the outer OMOBJ.OMXMLReader(InputSource fInputSource) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(char[] fCharacters, int fStart, int fLength) We've encountered a PCDATA section.voidEnd the document.voidendElement(String fNamespaceURI, String fLocalName, String fRawName) End a XML element.Get the OpenMath object.voidignorableWhitespace(char[] tCharacter, int tStart, int tLength) Process ignorable whitespace.voidprocessingInstruction(String fTarget, String fData) Process the processing instruction.Read an OpenMath object.voidsetDocumentLocator(Locator fLocator) Set the document-locator.voidSignals the start of the document.voidstartElement(String fNamespaceURI, String fLocalName, String fRawName, Attributes fAttributes) Start a XML element.Methods inherited from class DefaultHandler
endPrefixMapping, error, fatalError, notationDecl, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDecl, warningMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ContentHandler
declaration
-
Field Details
-
sOMObjects
Stores a static array with all the OpenMath element-names in use. -
mOMObject
Stores the OMObject for this reader. -
mElementStack
-
mInputSource
Stores the input-source. -
keep
protected boolean keepStores if we should keep the outer OMOBJ. -
foreign
protected int foreignStores if we are inside a foreign object section.
Note: if we find another foreign inside the foreign we add to this number to make sure we can handle the endElements correctly.
-
-
Constructor Details
-
OMXMLReader
public OMXMLReader()Constructor. -
OMXMLReader
Constructor.- Parameters:
fInputSource- the InputSource to read from.
-
OMXMLReader
Constructor taking a String as the InputSource.- Parameters:
fString- the string to read from.
-
OMXMLReader
Constructor taking a String as the InputSource and a boolean indicating if we want to keep the outer OMOBJ.- Parameters:
newString- the input sourcenewKeep- the boolean indicating if we keep the OMOBJ
-
-
Method Details
-
characters
We've encountered a PCDATA section.
Check if we have an enclosing OMInteger or OMString and set the data-members accordingly.- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler- Parameters:
fCharacters- the characters to handle.fStart- the start index into the characters array.fLength- the number of characters to read from the start.- Throws:
SAXException- when something is seriously wrong.
-
endDocument
public void endDocument()End the document.- Specified by:
endDocumentin interfaceContentHandler- Overrides:
endDocumentin classDefaultHandler
-
endElement
public void endElement(String fNamespaceURI, String fLocalName, String fRawName) throws SAXException End a XML element.- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler- Parameters:
fNamespaceURI- the URI of the namespace.fLocalName- the locale name of the element.fRawName- the raw name of the element.- Throws:
SAXException- when something is seriously wrong.
-
ignorableWhitespace
public void ignorableWhitespace(char[] tCharacter, int tStart, int tLength) Process ignorable whitespace.- Specified by:
ignorableWhitespacein interfaceContentHandler- Overrides:
ignorableWhitespacein classDefaultHandler- Parameters:
tCharacter- the characters that can be ignored.tStart- the start index into the characters array.tLength- the number of characters to ignore.
-
processingInstruction
Process the processing instruction.- Specified by:
processingInstructionin interfaceContentHandler- Overrides:
processingInstructionin classDefaultHandler- Parameters:
fTarget- the target of the processing instruction.fData- the data of the processing instruction.
-
readObject
Read an OpenMath object.- Returns:
- the OpenMath object to was read.
- Throws:
IOException- when reading failed.
-
getObject
Get the OpenMath object.
Note: if you didn't set this reader up from an input-source nor from a String, you will need this method to get the actual object at the end of reading. This method will only garantuee the proper result if you call it after 'endDocument' has be recognized.- Returns:
- the parsed OMObject or null
-
setDocumentLocator
Set the document-locator.- Specified by:
setDocumentLocatorin interfaceContentHandler- Overrides:
setDocumentLocatorin classDefaultHandler- Parameters:
fLocator- the document locator to use.
-
startDocument
public void startDocument()Signals the start of the document.
We reinitiliaze all the data-structures used during parsing, note that this parser is not reentrant and should only be used sequentially.- Specified by:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin classDefaultHandler
-
startElement
public void startElement(String fNamespaceURI, String fLocalName, String fRawName, Attributes fAttributes) throws SAXException Start a XML element.- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Parameters:
fNamespaceURI- the namespace URI.fLocalName- the local name of the element.fRawName- the raw name of the element.fAttributes- the attributes of the element.- Throws:
SAXException- when something is seriously wrong.
-