Class SaxHandlerImpl
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.episteme.natural.chemistry.loaders.cml.cmlimpl.SaxHandlerImpl
- All Implemented Interfaces:
SaxHandler, ContentHandler, DTDHandler, EntityResolver, ErrorHandler
manages callbacks from SAX2 handler
- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Constructor Summary
ConstructorsConstructorDescriptionSaxHandlerImpl(AbstractCMLDocument d, boolean debug) Creates a new SaxHandlerImpl object. -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(char[] ch, int start, int length) SAX callback for character data.voidclose()Closes the handler and releases all resources.protected voidOutputs a debug message if debugging is enabled.voidSAX callback for the end of the document.voidendElement(String uri, String localName, String qName) SAX callback for the end of an element.voidSAX callback for recoverable parse errors.voidSAX callback for fatal parse errors.voidflush()Flushes any buffered output.booleangetDebug()Returns the current debug status.Returns a vector of error messages encountered during parsing.booleanReturns true if any errors were encountered during parsing.voidignorableWhitespace(char[] ch, int start, int length) SAX callback for ignorable whitespace.static voidTest main method for parsing experiments.voidprocessingInstruction(String target, String data) SAX callback for processing instructions.voidPublishes a log record.voidsetDebug(boolean debug) Enables or disables debugging output.voidsetIgnoreWhite(boolean ignoreWhite) Sets whether to ignore ignorable whitespace during parsing.voidSAX callback for the start of the document.voidstartElement(String uri, String localName, String qName, Attributes attributes) SAX callback for the start of an element.voidstartPrefixMapping(String prefix, String uri) SAX callback for the start of a prefix mapping.voidunparsedEntityDecl(String name, String publicId, String systemId, String notationName) SAX callback for unparsed entity declarations.voidSAX callback for parse warnings.Methods inherited from class DefaultHandler
endPrefixMapping, notationDecl, resolveEntity, setDocumentLocator, skippedEntityMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ContentHandler
declaration, endPrefixMapping, setDocumentLocator, skippedEntityMethods inherited from interface DTDHandler
notationDeclMethods inherited from interface EntityResolver
resolveEntity
-
Constructor Details
-
SaxHandlerImpl
Creates a new SaxHandlerImpl object.- Parameters:
d- the document to populatedebug- true to enable debugging output
-
-
Method Details
-
setIgnoreWhite
public void setIgnoreWhite(boolean ignoreWhite) Sets whether to ignore ignorable whitespace during parsing.- Specified by:
setIgnoreWhitein interfaceSaxHandler- Parameters:
ignoreWhite- true to ignore whitespace, false otherwise
-
hasErrors
public boolean hasErrors()Returns true if any errors were encountered during parsing.- Specified by:
hasErrorsin interfaceSaxHandler- Returns:
- true if errors occurred, false otherwise
-
getErrorVector
Returns a vector of error messages encountered during parsing.- Specified by:
getErrorVectorin interfaceSaxHandler- Returns:
- a vector of error strings
-
setDebug
public void setDebug(boolean debug) Enables or disables debugging output.- Parameters:
debug- true to enable, false to disable
-
getDebug
public boolean getDebug()Returns the current debug status.- Specified by:
getDebugin interfaceSaxHandler- Returns:
- true if debug is on
-
publish
Publishes a log record. Currently commented out but originally intended to print level and message.- Parameters:
record- the log record to publish
-
flush
public void flush()Flushes any buffered output. -
close
public void close()Closes the handler and releases all resources. -
debug
Outputs a debug message if debugging is enabled.- Parameters:
s- the debug message
-
characters
public void characters(char[] ch, int start, int length) SAX callback for character data.- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler- Parameters:
ch- the character arraystart- the start positionlength- the number of characters
-
endDocument
public void endDocument()SAX callback for the end of the document.- Specified by:
endDocumentin interfaceContentHandler- Overrides:
endDocumentin classDefaultHandler
-
endElement
SAX callback for the end of an element.- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler- Parameters:
uri- the namespace URIlocalName- the local nameqName- the qualified name
-
error
SAX callback for recoverable parse errors.- Specified by:
errorin interfaceErrorHandler- Overrides:
errorin classDefaultHandler- Parameters:
e- the SAX parse exception
-
fatalError
SAX callback for fatal parse errors.- Specified by:
fatalErrorin interfaceErrorHandler- Overrides:
fatalErrorin classDefaultHandler- Parameters:
e- the fatal SAX parse exception
-
ignorableWhitespace
public void ignorableWhitespace(char[] ch, int start, int length) SAX callback for ignorable whitespace.- Specified by:
ignorableWhitespacein interfaceContentHandler- Overrides:
ignorableWhitespacein classDefaultHandler- Parameters:
ch- the character arraystart- the start positionlength- the number of characters
-
processingInstruction
SAX callback for processing instructions.- Specified by:
processingInstructionin interfaceContentHandler- Overrides:
processingInstructionin classDefaultHandler- Parameters:
target- the target stringdata- the data string
-
startDocument
public void startDocument()SAX callback for the start of the document.- Specified by:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin classDefaultHandler
-
startElement
SAX callback for the start of an element.- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Parameters:
uri- the namespace URIlocalName- the local nameqName- the qualified nameattributes- the element attributes
-
startPrefixMapping
SAX callback for the start of a prefix mapping.- Specified by:
startPrefixMappingin interfaceContentHandler- Overrides:
startPrefixMappingin classDefaultHandler- Parameters:
prefix- the namespace prefixuri- the namespace URI
-
unparsedEntityDecl
SAX callback for unparsed entity declarations.- Specified by:
unparsedEntityDeclin interfaceDTDHandler- Overrides:
unparsedEntityDeclin classDefaultHandler- Parameters:
name- the entity namepublicId- the public identifiersystemId- the system identifiernotationName- the name of the notation
-
warning
SAX callback for parse warnings.- Specified by:
warningin interfaceErrorHandler- Overrides:
warningin classDefaultHandler- Parameters:
e- the SAX parse warning
-
main
-