Module org.jpo

Class SaxEventHandler

java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.jpo.datamodel.SaxEventHandler
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class SaxEventHandler extends DefaultHandler
A xml parser to load the collections.
  • Field Details

  • Constructor Details

    • SaxEventHandler

      public SaxEventHandler(SortableDefaultMutableTreeNode startNode, LabelFrame loadProgressGui, StringBuilder lowresUrls)
      Constructs the Sax XML parser
      Parameters:
      startNode - The starting node
      loadProgressGui - the progress GUI to update
      lowresUrls - the lowresUrls to pick up on
  • Method Details

    • startElement

      public void startElement(String namespaceURI, String lName, String qName, Attributes attrs)
      method that gets invoked by the parser when a new element is discovered
      Specified by:
      startElement in interface ContentHandler
      Overrides:
      startElement in class DefaultHandler
      Parameters:
      namespaceURI - Namespace
      lName - local name
      qName - qualified name
      attrs - attributes
    • endElement

      public void endElement(String namespaceURI, String sName, String qName)
      method that gets invoked by the parser when an end element is discovered; used here to go back to the parent group if a <group> tag is found.
      Specified by:
      endElement in interface ContentHandler
      Overrides:
      endElement in class DefaultHandler
      Parameters:
      namespaceURI - the URI
      sName - the simple name
      qName - the qualified name
    • characters

      public void characters(char[] buf, int offset, int len)
      method invoked by the parser when characters are read between tags. The variable interpretChars is set so that the characters can be put in the right place
      Specified by:
      characters in interface ContentHandler
      Overrides:
      characters in class DefaultHandler
      Parameters:
      buf - The buffer
      offset - Start offset
      len - Length
    • resolveEntity

      public InputSource resolveEntity(String publicId, String systemId) throws IOException
      try to resolve where the file belongs
      Specified by:
      resolveEntity in interface EntityResolver
      Overrides:
      resolveEntity in class DefaultHandler
      Parameters:
      publicId - public id
      systemId - system id
      Returns:
      the dtd as an input source
      Throws:
      IOException
    • getCollectionDtdInputSource

      public static InputSource getCollectionDtdInputSource() throws IOException
      Returns the collection.dtd definition as an InputSource.
      Returns:
      The collection. dtd file
      Throws:
      IOException - If something went wrong