Class SGMLParser


  • public final class SGMLParser
    extends java.lang.Object
    A rudimentary SGML parser with something like a SAX-api.
    Version:
    1.0
    Author:
    Ernst Reissner
    • Constructor Detail

      • SGMLParser

        public SGMLParser()
        Creates a new SGMLParser with the default handlers for content and exceptions.
    • Method Detail

      • parse

        void parse​(org.xml.sax.InputSource src)
            throws java.io.IOException,
                   org.xml.sax.SAXException
        Parses the InputSource given but delegates everything inside a tag or a processing instruction to parseTagOrPI().
        Parameters:
        src - an InputSource.
        Throws:
        java.io.IOException - if an error occurs
        org.xml.sax.SAXException - if an error occurs
      • parse

        public void parse​(java.io.Reader reader)
                   throws java.io.IOException,
                          org.xml.sax.SAXException
        Parses the given InputStream.
        Parameters:
        reader - an Reader sequentializing an SGML document.
        Throws:
        java.io.IOException - if an error reading the stream occurs.
        org.xml.sax.SAXException - if an error with the sgml-syntax occurs.
      • parseText

        private int parseText()
                       throws java.io.IOException,
                              org.xml.sax.SAXException
        Parses everything outside a tag, a processing instruction, ... everything within brackets < and >. ***** Missing: distinction between notification of characters and whitespace. ****
        Throws:
        java.io.IOException - if an error reading the stream occurs.
        org.xml.sax.SAXException - if an error with the sgml-syntax occurs.
        See Also:
        parseTagOrPI()
      • parseEndTag

        void parseEndTag()
                  throws java.io.IOException,
                         org.xml.sax.SAXException
        Parses an end-tag notifying the underlying handler.
        Throws:
        java.io.IOException - if an error reading the stream occurs.
        org.xml.sax.SAXException - if an error with the sgml-syntax occurs.
      • parseStartOrStartEndTag

        void parseStartOrStartEndTag()
                              throws java.io.IOException,
                                     org.xml.sax.SAXException
        Parses a start-tag or, for xml, an empty tag.
        Throws:
        java.io.IOException - if an error reading the stream occurs.
        org.xml.sax.SAXException - if an error with the sgml-syntax occurs.
      • parseTagOrPI

        private int parseTagOrPI()
                          throws java.io.IOException,
                                 org.xml.sax.SAXException
        Parses everything within a tag, a processing instruction, ... everything within brackets < and >.
        Throws:
        java.io.IOException
        org.xml.sax.SAXException
        See Also:
        parseText()
      • setContentHandler

        public void setContentHandler​(org.xml.sax.ContentHandler contentHandler)
        Parameters:
        contentHandler - a ContentHandler.
      • getContentHandler

        public org.xml.sax.ContentHandler getContentHandler()
        Returns:
        the ContentHandler contentHandler.
      • parseXML

        public boolean parseXML​(boolean xml)
        Sets whether this parser is used as an xml-parser. If this is false, which is the default, it s an html-parser.
        Parameters:
        xml - a boolean value signifying whether this parser will be used as an xml-parser in the sequel.
        Returns:
        a boolean value signifying whether before invoking this method this parser was used as an xml-parser
      • isXMLParser

        public boolean isXMLParser()