com.japisoft.fastparser
Class Parser

java.lang.Object
  |
  +--com.japisoft.fastparser.Parser

public class Parser
extends java.lang.Object

Main Parser class. This parser works with several modes:
CONTINUE_PARSING_MODE : Ignore parsing error (for odd XML document / HTML document )
LOW_PARSING_MODE : Don't check for closing tag : for well-formed document
MEDIUM_PARSING_MODE : The default mode
HIGH_PARSING_MODE : Not supported in this version

Since:
1.0
Author:
(c) 2002-2003 JAPISoft
See Also:
NodeFactory, DocumentBuilder

Field Summary
static int CONTINUE_PARSING_MODE
          Continue parsing even with xml error
 int ERROR_STATE
           
static int HIGH_PARSING_MODE
          Validate the document : not available
static int LOW_PARSING_MODE
          Don't check for closing node : only for well formed document
static int MEDIUM_PARSING_MODE
          Default mode for parsing
 int STATE_COUNT
           
 int STATE_INIT
           
 
Constructor Summary
Parser()
           
 
Method Summary
 void bufferingMode(boolean buffering)
          if true it will bufferize the input stream before parsing. it costs ressource for low memory device and very fast input stream.
 void cdataEnabled(boolean enabled)
          Support for CDATA Section : By default this is enabled
protected  java.io.InputStream createBuffer(java.io.InputStream input)
          Store in memory the current input stream, this is called after the setInputStream method
protected  void fireItemFound(int state, java.lang.String item)
           
 Document getDocument()
           
 DocumentBuilder getDocumentBuilder()
           
 NodeFactory getNodeFactory()
           
 int getParsingMode()
           
 boolean hasBufferingMode()
           
 void interruptParsing()
          Interrupt the current parsing, this is useful for asynchronous parsing usage
 boolean isCdataEnabled()
           
 boolean isMandatoryProlog()
           
 boolean isPreserveWhiteSpace()
          Deprecated.  
static void main(java.lang.String[] args)
           
 void parse()
          Parse the current document
 void preserveComment(boolean comment)
          Save XML comment : by default this is disabled
 void preserveWhiteSpace(boolean ws)
          Deprecated.  
protected  java.io.InputStream readerToInputStream(java.io.Reader r)
          Convertissor from Reader to InputStream
 void setDocumentBuilder(DocumentBuilder db)
          Reset the builder for the document
 void setInputStream(java.io.InputStream input)
          Set the input stream of the document to parse.
 void setMandatoryProlog(boolean prolog)
          Set the prolog mandatory, but default to true
 void setNodeFactory(NodeFactory nf)
          Update the factory for building node
 void setParsingMode(int mode)
          Reset the parsing mode: this choice can impact on the parser velocity.
 void setText(java.lang.String text)
          Reset the document to parsed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR_STATE

public final int ERROR_STATE
See Also:
Constant Field Values

STATE_COUNT

public final int STATE_COUNT
See Also:
Constant Field Values

STATE_INIT

public final int STATE_INIT
See Also:
Constant Field Values

CONTINUE_PARSING_MODE

public static final int CONTINUE_PARSING_MODE
Continue parsing even with xml error

See Also:
Constant Field Values

LOW_PARSING_MODE

public static final int LOW_PARSING_MODE
Don't check for closing node : only for well formed document

See Also:
Constant Field Values

MEDIUM_PARSING_MODE

public static final int MEDIUM_PARSING_MODE
Default mode for parsing

See Also:
Constant Field Values

HIGH_PARSING_MODE

public static final int HIGH_PARSING_MODE
Validate the document : not available

See Also:
Constant Field Values
Constructor Detail

Parser

public Parser()
Method Detail

setNodeFactory

public void setNodeFactory(NodeFactory nf)
Update the factory for building node


getNodeFactory

public NodeFactory getNodeFactory()
Returns:
the factory for building node

setDocumentBuilder

public void setDocumentBuilder(DocumentBuilder db)
Reset the builder for the document


getDocumentBuilder

public DocumentBuilder getDocumentBuilder()
Returns:
the document builder

getDocument

public Document getDocument()
Returns:
the parsed document

cdataEnabled

public void cdataEnabled(boolean enabled)
Support for CDATA Section : By default this is enabled


isCdataEnabled

public boolean isCdataEnabled()
Returns:
is CDATA secion is enabled or not

preserveComment

public void preserveComment(boolean comment)
Save XML comment : by default this is disabled


setInputStream

public void setInputStream(java.io.InputStream input)
Set the input stream of the document to parse. This input will be closed automatically.


bufferingMode

public void bufferingMode(boolean buffering)
if true it will bufferize the input stream before parsing. it costs ressource for low memory device and very fast input stream. By default to true


hasBufferingMode

public boolean hasBufferingMode()

setText

public void setText(java.lang.String text)
Reset the document to parsed


setMandatoryProlog

public void setMandatoryProlog(boolean prolog)
Set the prolog mandatory, but default to true


isMandatoryProlog

public boolean isMandatoryProlog()
Returns:
true is the XML prolog is mandatory

preserveWhiteSpace

public void preserveWhiteSpace(boolean ws)
Deprecated.  

Eliminate extra white space between tag. By default to false


isPreserveWhiteSpace

public boolean isPreserveWhiteSpace()
Deprecated.  

Returns:
eliminate extra white space between tag. By default to false

interruptParsing

public void interruptParsing()
Interrupt the current parsing, this is useful for asynchronous parsing usage


setParsingMode

public void setParsingMode(int mode)
Reset the parsing mode: this choice can impact on the parser velocity.

Parameters:
mode - CONTINUE_PARSING_MODE for ignoring xml error, LOW_PARSING_MODE for not checking closing tag : always for well formed document, MEDIUM_PARSING_MODE by default, HIGH_PARSING_MODE not available

getParsingMode

public int getParsingMode()
Returns:
the current parsing mode

parse

public void parse()
           throws ParseException
Parse the current document

ParseException

fireItemFound

protected void fireItemFound(int state,
                             java.lang.String item)
                      throws ParseException
ParseException

readerToInputStream

protected java.io.InputStream readerToInputStream(java.io.Reader r)
                                           throws java.io.IOException
Convertissor from Reader to InputStream

java.io.IOException

createBuffer

protected java.io.InputStream createBuffer(java.io.InputStream input)
                                    throws java.io.IOException
Store in memory the current input stream, this is called after the setInputStream method

java.io.IOException

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
java.lang.Exception