Package com.topologi.diffx.load
Class SAXRecorder
java.lang.Object
com.topologi.diffx.load.SAXRecorder
- All Implemented Interfaces:
Recorder,XMLRecorder
Records the SAX events in an
EventSequence.
It is possible to specify the name of the XML reader implementation class.
By default this class will try to use the Crimson parser
org.apache.crimson.parser.XMLReaderImpl.
The XML reader implementation must support the following features settings
http://xml.org/sax/features/validation => false http://xml.org/sax/features/namespaces => true | false http://xml.org/sax/features/namespace-prefixes => true | false
- Version:
- 17 October 2006
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classA tight error handler that will throw an exception for any error type.private final classA SAX2 handler that records XML events. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate DiffXConfigThe DiffX configuration to useprivate static final StringThe default XML reader in use.private static booleanIndicates whether a new reader instance should be created because the specified class name has changed.private static XMLReaderThe XML reader.private static StringThe XML reader class in use (set to the deafult XML reader).protected EventSequenceThe sequence of event for this recorder. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the configuration used by this recorder.static StringReturns the name XMLReader class used by the SAXRecorders.private static voidinit()Initialises the XML reader using the defined class name.Runs the recorder on the specified file.Runs the recorder on the specified string.process(InputSource is) Runs the recorder on the specified input source.voidsetConfig(DiffXConfig config) Sets the configuration used by this recorder.static voidsetXMLReaderClass(String className) Sets the name of the XML reader class to use.
-
Field Details
-
reader
The XML reader. -
DEFAULT_XML_READER
The default XML reader in use. -
readerClassName
The XML reader class in use (set to the deafult XML reader). -
newReader
private static boolean newReaderIndicates whether a new reader instance should be created because the specified class name has changed. -
config
The DiffX configuration to use -
sequence
The sequence of event for this recorder.
-
-
Constructor Details
-
SAXRecorder
public SAXRecorder()
-
-
Method Details
-
process
Runs the recorder on the specified file.This method will count on the
InputSourceto guess the correct encoding.- Specified by:
processin interfaceRecorder- Parameters:
file- The file to process.- Returns:
- The recorded sequence of events.
- Throws:
LoadingException- If thrown while parsing.IOException- Should I/O error occur.
-
process
Runs the recorder on the specified string.This method is provided for convenience. It is best to only use this method for short strings.
- Specified by:
processin interfaceRecorder- Parameters:
xml- The XML string to process.- Returns:
- The recorded sequence of events.
- Throws:
LoadingException- If thrown while parsing.IOException- Should I/O error occur.
-
process
Runs the recorder on the specified input source.- Specified by:
processin interfaceXMLRecorder- Parameters:
is- The input source.- Returns:
- The recorded sequence of events.
- Throws:
LoadingException- If thrown whilst parsing.IOException- Should I/O error occur.
-
getConfig
Returns the configuration used by this recorder.- Returns:
- the configuration used by this recorder.
-
setConfig
Sets the configuration used by this recorder.- Parameters:
config- The configuration used by this recorder.
-
getXMLReaderClass
Returns the name XMLReader class used by the SAXRecorders.- Returns:
- the name XMLReader class used by the SAXRecorders.
-
setXMLReaderClass
Sets the name of the XML reader class to use.Use
nullto reset the XML reader class and use the default XML reader.A new reader will be created only if the specified class is different from the current one.
- Parameters:
className- The name of the XML reader class to use; ornullto reset the XML reader.
-
init
Initialises the XML reader using the defined class name.- Throws:
LoadingException- If one of the features could not be set.
-