Class PdbSAXParser

  • All Implemented Interfaces:

    public class PdbSAXParser
    extends Object
    A SAX2 parser for dealing with native PDB files. That is, this class allows native PDB format files to be processed as if they were in PdbXML format, but without an interconversion step. That is, events are generated that call methods on an XML document handler.

    Note this code is experimental, and may change without notice.

    Copyright © 2000 - 2002 Cambridge Antibody Technology.

    Primary author -

    • Simon Brocklehurst (CAT)
    Other authors -
    • Neil Benn (CAT)
    • Derek Crockford (CAT)
    • Tim Dilks (CAT)
    • Colin Hardman (CAT)
    • Stuart Johnston (CAT)
    Cambridge Antibody Technology (CAT), Greg Cox
    • Field Detail

      • tNamespaces

        protected boolean tNamespaces
      • tNamespacePrefixes

        protected boolean tNamespacePrefixes
      • oNamespacePrefix

        protected String oNamespacePrefix
      • oFullNamespacePrefix

        protected String oFullNamespacePrefix
      • iState

        protected int iState
    • Constructor Detail

      • PdbSAXParser

        public PdbSAXParser()
        Sets namespace prefix to "biojava"
    • Method Detail

      • setContentHandler

        public void setContentHandler​(ContentHandler poHandler)
        Allow an application to register a content event handler. If the application does not register a content handler, all content events reported by the SAX parser will be silently ignored.

        Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.

        Specified by:
        setContentHandler in interface XMLReader
        poHandler - a ContentHandler The XML content handler
        NullPointerException - If the handler argument is null
      • getContentHandler

        public ContentHandler getContentHandler()
        Return the content handler.
        Specified by:
        getContentHandler in interface XMLReader
        a ContentHandler The current content handler, or null if none has been registered.
      • setDTDHandler

        public void setDTDHandler​(DTDHandler handler)
        Do-nothing implementation of interface method
        Specified by:
        setDTDHandler in interface XMLReader
      • startElement

        protected void startElement​( poQName,
                                    Attributes atts)
                             throws SAXException
        Utility method to centralize sending of a SAX startElement message to document handler
        poQName - a QName value
        atts - an Attributes value
        SAXException - if an error occurs
      • endElement

        protected void endElement​( poQName)
                           throws SAXException
        Utility method to centralize the sending of a SAX endElement message a document handler.
        poQName - -
        SAXException - thrown if
        thrown - if
      • characters

        protected void characters​(char[] ch,
                                  int start,
                                  int length)
                           throws SAXException
        Utility method to centralize the sending of a SAX characters message a document handler.
        ch - -
        start - -
        length - -
        SAXException - thrown if
        thrown - if
      • getNamespaces

        public boolean getNamespaces()
        Support SAX2 configuration of namespace support of parser.
      • getNamespacePrefixes

        public boolean getNamespacePrefixes()
        Support SAX2 configuration of namespace support of parser.
      • addPrefixMapping

        public void addPrefixMapping​(String poPrefix,
                                     String poURI)
        Adds a namespace prefix to URI mapping as (key,value) pairs. This mapping can be looked up later to get URIs on request using the getURIFromPrefix method.
        poPrefix - a String representation of the namespace prefix
        poURI - a String representation of the URI for the namespace prefix.
      • getURIFromPrefix

        public String getURIFromPrefix​(String poPrefix)
        Gets the URI for a namespace prefix, given that prefix, or null if the prefix is not recognised.
        poPrefix - a String The namespace prefix.
      • setNamespacePrefix

        public void setNamespacePrefix​(String poPrefix)
        poPrefix - a String value
      • getNamespacePrefix

        public String getNamespacePrefix()
        Describe getNamespacePrefix method here.
        a String value
      • prefix

        public String prefix​(String poElementName)
        Given an unprefixed element name, returns a new element name with a namespace prefix
        a String value
      • getContentStream

        protected BufferedReader getContentStream​(InputSource poSource)
        Create a stream from an an InputSource, picking the correct stream according to order of precedance.
        poSource - an InputSource value
        a BufferedReader value
      • changeState

        protected void changeState​(int piState)
        Centralise chaining of iState field to help with debugging. E.g. printing out value etc. All changes to iState should be made through this method.
        piState - an int value