Class SAXRecorder

java.lang.Object
com.topologi.diffx.load.SAXRecorder
All Implemented Interfaces:
Recorder, XMLRecorder

public final class SAXRecorder extends Object implements 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
  • Field Details

    • reader

      private static XMLReader reader
      The XML reader.
    • DEFAULT_XML_READER

      private static final String DEFAULT_XML_READER
      The default XML reader in use.
    • readerClassName

      private static String readerClassName
      The XML reader class in use (set to the deafult XML reader).
    • newReader

      private static boolean newReader
      Indicates whether a new reader instance should be created because the specified class name has changed.
    • config

      private DiffXConfig config
      The DiffX configuration to use
    • sequence

      protected transient EventSequence sequence
      The sequence of event for this recorder.
  • Constructor Details

    • SAXRecorder

      public SAXRecorder()
  • Method Details

    • process

      public EventSequence process(File file) throws LoadingException, IOException
      Runs the recorder on the specified file.

      This method will count on the InputSource to guess the correct encoding.

      Specified by:
      process in interface Recorder
      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

      public EventSequence process(String xml) throws LoadingException, IOException
      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:
      process in interface Recorder
      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:
      process in interface XMLRecorder
      Parameters:
      is - The input source.
      Returns:
      The recorded sequence of events.
      Throws:
      LoadingException - If thrown whilst parsing.
      IOException - Should I/O error occur.
    • getConfig

      public DiffXConfig getConfig()
      Returns the configuration used by this recorder.
      Returns:
      the configuration used by this recorder.
    • setConfig

      public void setConfig(DiffXConfig config)
      Sets the configuration used by this recorder.
      Parameters:
      config - The configuration used by this recorder.
    • getXMLReaderClass

      public static String getXMLReaderClass()
      Returns the name XMLReader class used by the SAXRecorders.
      Returns:
      the name XMLReader class used by the SAXRecorders.
    • setXMLReaderClass

      public static void setXMLReaderClass(String className)
      Sets the name of the XML reader class to use.

      Use null to 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; or null to reset the XML reader.
    • init

      private static void init() throws LoadingException
      Initialises the XML reader using the defined class name.
      Throws:
      LoadingException - If one of the features could not be set.