Class SimpleXMLParser

java.lang.Object
com.lowagie.text.xml.simpleparser.SimpleXMLParser

@Deprecated public final class SimpleXMLParser extends Object
Deprecated.
A simple XML and HTML parser. This parser is, like the SAX parser, an event based parser, but with much less functionality.

The parser can:

  • It recognizes the encoding used
  • It recognizes all the elements' start tags and end tags
  • It lists attributes, where attribute values can be enclosed in single or double quotes
  • It recognizes the <[CDATA[ ... ]]> construct
  • It recognizes the standard entities: &amp;, &lt;, &gt;, &quot;, and &apos;, as well as numeric entities
  • It maps lines ending in \r\n and \r to \n on input, in accordance with the XML Specification, Section 2.11
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final int
    Deprecated.
     
    private static final int
    Deprecated.
     
    private static final int
    Deprecated.
     
    (package private) String
    Deprecated.
    the attribute key.
    (package private) Map<String,String>
    Deprecated.
    current attributes
    (package private) String
    Deprecated.
    the attribute value.
    private static final int
    Deprecated.
     
    (package private) int
    Deprecated.
    The current character.
    (package private) int
    Deprecated.
    the column where the current character occurs
    (package private) SimpleXMLDocHandlerComment
    Deprecated.
    The handler to which we are going to forward comments.
    private static final int
    Deprecated.
     
    (package private) SimpleXMLDocHandler
    Deprecated.
    The handler to which we are going to forward document content
    (package private) StringBuffer
    Deprecated.
    current entity (whatever is encountered between & and ;)
    private static final int
    Deprecated.
     
    (package private) boolean
    Deprecated.
    was the last character equivalent to a newline?
    private static final int
    Deprecated.
     
    (package private) boolean
    Deprecated.
    Are we parsing HTML?
    private static final int
    Deprecated.
     
    (package private) int
    Deprecated.
    the line we are currently reading
    (package private) int
    Deprecated.
    Keeps track of the number of tags that are open.
    (package private) boolean
    Deprecated.
    A boolean indicating if the next character should be taken into account if it's a space character.
    private static final int
    Deprecated.
     
    (package private) int
    Deprecated.
    The previous character.
    private static final int
    Deprecated.
     
    (package private) int
    Deprecated.
    the quote character that was used to open the quote.
    private static final int
    Deprecated.
     
    (package private) Stack<Integer>
    Deprecated.
    the state stack
    (package private) int
    Deprecated.
    the current state
    (package private) String
    Deprecated.
    current tagname
    private static final int
    Deprecated.
     
    private static final int
    Deprecated.
     
    (package private) StringBuffer
    Deprecated.
    current text (whatever is encountered between tags)
    private static final int
    Deprecated.
     
    private static final int
    Deprecated.
    possible states
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Deprecated.
    Creates a Simple XML parser object.
  • Method Summary

    Modifier and Type
    Method
    Description
    private static Optional<Charset>
    Deprecated.
    Detect charset from BOM, as per Unicode FAQ.
    private void
    Deprecated.
    Sets the name of the tag.
    private void
    Deprecated.
    Flushes the text that is currently in the buffer.
    private static String
    Deprecated.
     
    private void
    Deprecated.
    Does the actual parsing.
    private void
    Deprecated.
    Initialized the tag name and attributes.
    static void
    parse(SimpleXMLDocHandler doc, SimpleXMLDocHandlerComment comment, Reader r, boolean html)
    Deprecated.
    Parses the XML document firing the events to the handler.
    static void
    Deprecated.
    Parses the XML document firing the events to the handler.
    static void
    Deprecated.
     
    private void
    processTag(boolean start)
    Deprecated.
    processes the tag.
    private int
    Deprecated.
    Gets a state from the stack
    private void
    saveState(int s)
    Deprecated.
    Adds a state to the stack.
    private void
    Deprecated.
    Throws an exception

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • UNKNOWN

      private static final int UNKNOWN
      Deprecated.
      possible states
      See Also:
    • TEXT

      private static final int TEXT
      Deprecated.
      See Also:
    • TAG_ENCOUNTERED

      private static final int TAG_ENCOUNTERED
      Deprecated.
      See Also:
    • EXAMIN_TAG

      private static final int EXAMIN_TAG
      Deprecated.
      See Also:
    • TAG_EXAMINED

      private static final int TAG_EXAMINED
      Deprecated.
      See Also:
    • IN_CLOSETAG

      private static final int IN_CLOSETAG
      Deprecated.
      See Also:
    • SINGLE_TAG

      private static final int SINGLE_TAG
      Deprecated.
      See Also:
    • CDATA

      private static final int CDATA
      Deprecated.
      See Also:
    • COMMENT

      private static final int COMMENT
      Deprecated.
      See Also:
    • PI

      private static final int PI
      Deprecated.
      See Also:
    • ENTITY

      private static final int ENTITY
      Deprecated.
      See Also:
    • QUOTE

      private static final int QUOTE
      Deprecated.
      See Also:
    • ATTRIBUTE_KEY

      private static final int ATTRIBUTE_KEY
      Deprecated.
      See Also:
    • ATTRIBUTE_EQUAL

      private static final int ATTRIBUTE_EQUAL
      Deprecated.
      See Also:
    • ATTRIBUTE_VALUE

      private static final int ATTRIBUTE_VALUE
      Deprecated.
      See Also:
    • stack

      Stack<Integer> stack
      Deprecated.
      the state stack
    • character

      int character
      Deprecated.
      The current character.
    • previousCharacter

      int previousCharacter
      Deprecated.
      The previous character.
    • lines

      int lines
      Deprecated.
      the line we are currently reading
    • columns

      int columns
      Deprecated.
      the column where the current character occurs
    • eol

      boolean eol
      Deprecated.
      was the last character equivalent to a newline?
    • nowhite

      boolean nowhite
      Deprecated.
      A boolean indicating if the next character should be taken into account if it's a space character. When nospace is false, the previous character wasn't whitespace.
      Since:
      2.1.5
    • state

      int state
      Deprecated.
      the current state
    • html

      boolean html
      Deprecated.
      Are we parsing HTML?
    • text

      Deprecated.
      current text (whatever is encountered between tags)
    • entity

      StringBuffer entity
      Deprecated.
      current entity (whatever is encountered between & and ;)
    • tag

      String tag
      Deprecated.
      current tagname
    • attributes

      Map<String,String> attributes
      Deprecated.
      current attributes
    • doc

      Deprecated.
      The handler to which we are going to forward document content
    • comment

      Deprecated.
      The handler to which we are going to forward comments.
    • nested

      int nested
      Deprecated.
      Keeps track of the number of tags that are open.
    • quoteCharacter

      int quoteCharacter
      Deprecated.
      the quote character that was used to open the quote.
    • attributekey

      String attributekey
      Deprecated.
      the attribute key.
    • attributevalue

      String attributevalue
      Deprecated.
      the attribute value.
  • Constructor Details

  • Method Details

    • parse

      public static void parse(SimpleXMLDocHandler doc, SimpleXMLDocHandlerComment comment, Reader r, boolean html) throws IOException
      Deprecated.
      Parses the XML document firing the events to the handler.
      Parameters:
      doc - the document handler
      comment - comment
      r - the document. The encoding is already resolved. The reader is not closed
      html - html
      Throws:
      IOException - on error
    • detectCharsetFromBOM

      private static Optional<Charset> detectCharsetFromBOM(byte[] bom)
      Deprecated.
      Detect charset from BOM, as per Unicode FAQ.
    • parse

      public static void parse(SimpleXMLDocHandler doc, InputStream in) throws IOException
      Deprecated.
      Parses the XML document firing the events to the handler.
      Parameters:
      doc - the document handler
      in - the document. The encoding is deduced from the stream. The stream is not closed
      Throws:
      IOException - on error
    • getDeclaredEncoding

      private static String getDeclaredEncoding(String decl)
      Deprecated.
    • parse

      public static void parse(SimpleXMLDocHandler doc, Reader r) throws IOException
      Deprecated.
      Throws:
      IOException
    • go

      private void go(Reader r) throws IOException
      Deprecated.
      Does the actual parsing. Perform this immediately after creating the parser object.
      Throws:
      IOException
    • restoreState

      private int restoreState()
      Deprecated.
      Gets a state from the stack
      Returns:
      the previous state
    • saveState

      private void saveState(int s)
      Deprecated.
      Adds a state to the stack.
      Parameters:
      s - a state to add to the stack
    • flush

      private void flush()
      Deprecated.
      Flushes the text that is currently in the buffer. The text can be ignored, added to the document as content or as comment,... depending on the current state.
    • initTag

      private void initTag()
      Deprecated.
      Initialized the tag name and attributes.
    • doTag

      private void doTag()
      Deprecated.
      Sets the name of the tag.
    • processTag

      private void processTag(boolean start)
      Deprecated.
      processes the tag.
      Parameters:
      start - if true we are dealing with a tag that has just been opened; if false we are closing a tag.
    • throwException

      private void throwException(String s) throws IOException
      Deprecated.
      Throws an exception
      Throws:
      IOException