com.ximpleware
Class VTDGen

java.lang.Object
  extended by com.ximpleware.VTDGen

public class VTDGen
extends java.lang.Object

VTD Generator implementation. Current support built-in entities only It parses DTD, but doesn't resolve declared entities


Field Summary
 long[] attr_name_array
           
static int FORMAT_ASCII
           
static int FORMAT_ISO_8859_1
           
static int FORMAT_ISO_8859_10
           
static int FORMAT_ISO_8859_11
           
static int FORMAT_ISO_8859_12
           
static int FORMAT_ISO_8859_13
           
static int FORMAT_ISO_8859_14
           
static int FORMAT_ISO_8859_15
           
static int FORMAT_ISO_8859_16
           
static int FORMAT_ISO_8859_2
           
static int FORMAT_ISO_8859_3
           
static int FORMAT_ISO_8859_4
           
static int FORMAT_ISO_8859_5
           
static int FORMAT_ISO_8859_6
           
static int FORMAT_ISO_8859_7
           
static int FORMAT_ISO_8859_8
           
static int FORMAT_ISO_8859_9
           
static int FORMAT_UTF_16BE
           
static int FORMAT_UTF_16LE
           
static int FORMAT_UTF8
           
static int FORMAT_WIN_1250
           
static int FORMAT_WIN_1251
           
static int FORMAT_WIN_1252
           
static int FORMAT_WIN_1253
           
static int FORMAT_WIN_1254
           
static int FORMAT_WIN_1255
           
static int FORMAT_WIN_1256
           
static int FORMAT_WIN_1257
           
static int FORMAT_WIN_1258
           
static int MAX_DEPTH
           
static int MAX_PREFIX_LENGTH
           
static int MAX_QNAME_LENGTH
           
static int MAX_TOKEN_LENGTH
           
static int TOKEN_ATTR_NAME
           
static int TOKEN_ATTR_NS
           
static int TOKEN_ATTR_VAL
           
static int TOKEN_CDATA_VAL
           
static int TOKEN_CHARACTER_DATA
           
static int TOKEN_COMMENT
           
static int TOKEN_DEC_ATTR_NAME
           
static int TOKEN_DEC_ATTR_VAL
           
static int TOKEN_DOCUMENT
           
static int TOKEN_DTD_VAL
           
static int TOKEN_ENDING_TAG
           
static int TOKEN_PI_NAME
           
static int TOKEN_PI_VAL
           
static int TOKEN_STARTING_TAG
           
 
Constructor Summary
VTDGen()
          VTDGen constructor method.
 
Method Summary
 void clear()
          Clear internal states so VTDGEn can process the next file.
 long getIndexSize()
          Precompute the size of VTD+XML index
 VTDNav getNav()
          This method returns the VTDNav object after parsing, it also cleans internal state so VTDGen can process the next file.
 VTDNav loadIndex(byte[] ba)
          This method loads the VTD+XML from a byte array
 VTDNav loadIndex(java.io.InputStream is)
          This method loads the VTD+XML from an input stream
 VTDNav loadIndex(java.lang.String fileName)
          This method loads the VTD+XML from a file
 VTDNav loadSeparateIndex(java.lang.String XMLFileName, java.lang.String VTDIndexName)
          Load the separate VTD index and XmL file.
 void parse(boolean NS)
          Generating VTD tokens and Location cache info.
 boolean parseFile(java.lang.String fileName, boolean ns)
          This method parses the XML file and returns a boolean indicating if it is successful or not.
 boolean parseHttpUrl(java.lang.String url, boolean ns)
          This method retrieves an XML document from the net using HTTP request If the returned content type is "application xml" then it will proceed with the parsing.
 void setDoc_BR(byte[] ba)
          The buffer-reuse version of setDoc The concept is to reuse LC and VTD buffer for XML parsing, instead of allocating every time
 void setDoc_BR(byte[] ba, int os, int len)
          The buffer-reuse version of setDoc The concept is to reuse LC and VTD buffer for XML parsing, instead of allocating every time
 void setDoc(byte[] ba)
          Set the XMLDoc container.
 void setDoc(byte[] ba, int os, int len)
          Set the XMLDoc container.
 void writeIndex(java.io.OutputStream os)
          This method writes the VTD+XML into an outputStream
 void writeIndex(java.lang.String fileName)
          This method writes the VTD+XML file into a file of the given name
 void writeSeparateIndex(java.io.OutputStream os)
          This method writes the VTDs and LCs into an outputStream
 void writeSeparateIndex(java.lang.String fileName)
          This method writes the VTDs and LCs into a file of the given name XML is not part of the index please refer to VTD-XML web site for the spec and explanation
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

attr_name_array

public long[] attr_name_array

FORMAT_ASCII

public static final int FORMAT_ASCII
See Also:
Constant Field Values

FORMAT_ISO_8859_1

public static final int FORMAT_ISO_8859_1
See Also:
Constant Field Values

FORMAT_ISO_8859_10

public static final int FORMAT_ISO_8859_10
See Also:
Constant Field Values

FORMAT_ISO_8859_11

public static final int FORMAT_ISO_8859_11
See Also:
Constant Field Values

FORMAT_ISO_8859_12

public static final int FORMAT_ISO_8859_12
See Also:
Constant Field Values

FORMAT_ISO_8859_13

public static final int FORMAT_ISO_8859_13
See Also:
Constant Field Values

FORMAT_ISO_8859_14

public static final int FORMAT_ISO_8859_14
See Also:
Constant Field Values

FORMAT_ISO_8859_15

public static final int FORMAT_ISO_8859_15
See Also:
Constant Field Values

FORMAT_ISO_8859_16

public static final int FORMAT_ISO_8859_16
See Also:
Constant Field Values

FORMAT_ISO_8859_2

public static final int FORMAT_ISO_8859_2
See Also:
Constant Field Values

FORMAT_ISO_8859_3

public static final int FORMAT_ISO_8859_3
See Also:
Constant Field Values

FORMAT_ISO_8859_4

public static final int FORMAT_ISO_8859_4
See Also:
Constant Field Values

FORMAT_ISO_8859_5

public static final int FORMAT_ISO_8859_5
See Also:
Constant Field Values

FORMAT_ISO_8859_6

public static final int FORMAT_ISO_8859_6
See Also:
Constant Field Values

FORMAT_ISO_8859_7

public static final int FORMAT_ISO_8859_7
See Also:
Constant Field Values

FORMAT_ISO_8859_8

public static final int FORMAT_ISO_8859_8
See Also:
Constant Field Values

FORMAT_ISO_8859_9

public static final int FORMAT_ISO_8859_9
See Also:
Constant Field Values

FORMAT_UTF_16BE

public static final int FORMAT_UTF_16BE
See Also:
Constant Field Values

FORMAT_UTF_16LE

public static final int FORMAT_UTF_16LE
See Also:
Constant Field Values

FORMAT_UTF8

public static final int FORMAT_UTF8
See Also:
Constant Field Values

FORMAT_WIN_1250

public static final int FORMAT_WIN_1250
See Also:
Constant Field Values

FORMAT_WIN_1251

public static final int FORMAT_WIN_1251
See Also:
Constant Field Values

FORMAT_WIN_1252

public static final int FORMAT_WIN_1252
See Also:
Constant Field Values

FORMAT_WIN_1253

public static final int FORMAT_WIN_1253
See Also:
Constant Field Values

FORMAT_WIN_1254

public static final int FORMAT_WIN_1254
See Also:
Constant Field Values

FORMAT_WIN_1255

public static final int FORMAT_WIN_1255
See Also:
Constant Field Values

FORMAT_WIN_1256

public static final int FORMAT_WIN_1256
See Also:
Constant Field Values

FORMAT_WIN_1257

public static final int FORMAT_WIN_1257
See Also:
Constant Field Values

FORMAT_WIN_1258

public static final int FORMAT_WIN_1258
See Also:
Constant Field Values

MAX_DEPTH

public static final int MAX_DEPTH
See Also:
Constant Field Values

MAX_PREFIX_LENGTH

public static final int MAX_PREFIX_LENGTH
See Also:
Constant Field Values

MAX_QNAME_LENGTH

public static final int MAX_QNAME_LENGTH
See Also:
Constant Field Values

MAX_TOKEN_LENGTH

public static final int MAX_TOKEN_LENGTH
See Also:
Constant Field Values

TOKEN_ATTR_NAME

public static final int TOKEN_ATTR_NAME
See Also:
Constant Field Values

TOKEN_ATTR_NS

public static final int TOKEN_ATTR_NS
See Also:
Constant Field Values

TOKEN_ATTR_VAL

public static final int TOKEN_ATTR_VAL
See Also:
Constant Field Values

TOKEN_CDATA_VAL

public static final int TOKEN_CDATA_VAL
See Also:
Constant Field Values

TOKEN_CHARACTER_DATA

public static final int TOKEN_CHARACTER_DATA
See Also:
Constant Field Values

TOKEN_COMMENT

public static final int TOKEN_COMMENT
See Also:
Constant Field Values

TOKEN_DEC_ATTR_NAME

public static final int TOKEN_DEC_ATTR_NAME
See Also:
Constant Field Values

TOKEN_DEC_ATTR_VAL

public static final int TOKEN_DEC_ATTR_VAL
See Also:
Constant Field Values

TOKEN_DOCUMENT

public static final int TOKEN_DOCUMENT
See Also:
Constant Field Values

TOKEN_DTD_VAL

public static final int TOKEN_DTD_VAL
See Also:
Constant Field Values

TOKEN_ENDING_TAG

public static final int TOKEN_ENDING_TAG
See Also:
Constant Field Values

TOKEN_PI_NAME

public static final int TOKEN_PI_NAME
See Also:
Constant Field Values

TOKEN_PI_VAL

public static final int TOKEN_PI_VAL
See Also:
Constant Field Values

TOKEN_STARTING_TAG

public static final int TOKEN_STARTING_TAG
See Also:
Constant Field Values
Constructor Detail

VTDGen

public VTDGen()
VTDGen constructor method.

Method Detail

clear

public void clear()
Clear internal states so VTDGEn can process the next file.


getIndexSize

public long getIndexSize()
Precompute the size of VTD+XML index

Returns:
size of the index

getNav

public VTDNav getNav()
This method returns the VTDNav object after parsing, it also cleans internal state so VTDGen can process the next file.

Returns:
com.ximpleware.VTDNav

loadIndex

public VTDNav loadIndex(byte[] ba)
                 throws java.io.IOException,
                        IndexReadException
This method loads the VTD+XML from a byte array

Parameters:
ba -
Returns:
VTDNav
Throws:
java.io.IOException
IndexReadException

loadIndex

public VTDNav loadIndex(java.io.InputStream is)
                 throws java.io.IOException,
                        IndexReadException
This method loads the VTD+XML from an input stream

Parameters:
is -
Returns:
VTDNav
Throws:
java.io.IOException
IndexReadException

loadIndex

public VTDNav loadIndex(java.lang.String fileName)
                 throws java.io.IOException,
                        IndexReadException
This method loads the VTD+XML from a file

Parameters:
fileName -
Returns:
VTDNav
Throws:
java.io.IOException
IndexReadException

loadSeparateIndex

public VTDNav loadSeparateIndex(java.lang.String XMLFileName,
                                java.lang.String VTDIndexName)
                         throws java.io.IOException,
                                IndexReadException
Load the separate VTD index and XmL file. Refer to persistence model of separate vtd index for more details

Parameters:
XMLFileName - name of xml file
VTDIndexName - name of the vtd index file
Returns:
VTDNav object
Throws:
java.io.IOException
IndexReadException

parse

public void parse(boolean NS)
           throws com.ximpleware.EncodingException,
                  com.ximpleware.EOFException,
                  com.ximpleware.EntityException,
                  ParseException
Generating VTD tokens and Location cache info.

Parameters:
NS - boolean Enable namespace or not
Throws:
ParseException - Super class for any exceptions during parsing.
EOFException - End of file exception.
EntityException - Entity resolution exception.
EncodingException - UTF/native encoding exception.

parseFile

public boolean parseFile(java.lang.String fileName,
                         boolean ns)
This method parses the XML file and returns a boolean indicating if it is successful or not.

Parameters:
fileName -
ns - namespace aware or not
Returns:
boolean indicating whether the parseFile is a success

parseHttpUrl

public boolean parseHttpUrl(java.lang.String url,
                            boolean ns)
This method retrieves an XML document from the net using HTTP request If the returned content type is "application xml" then it will proceed with the parsing. Also notice that the content size can't be zero or negative, it must be a positive integer matching the size of the document no exception is thrown in the case of failure, this method will simply return false

Parameters:
url -
Returns:
boolean (status of parsing the XML referenced by the HTTP request)

setDoc_BR

public void setDoc_BR(byte[] ba)
The buffer-reuse version of setDoc The concept is to reuse LC and VTD buffer for XML parsing, instead of allocating every time

Parameters:
ba -

setDoc_BR

public void setDoc_BR(byte[] ba,
                      int os,
                      int len)
The buffer-reuse version of setDoc The concept is to reuse LC and VTD buffer for XML parsing, instead of allocating every time

Parameters:
ba - byte[]
os - int (in byte)
len - int (in byte)

setDoc

public void setDoc(byte[] ba)
Set the XMLDoc container.

Parameters:
ba - byte[]

setDoc

public void setDoc(byte[] ba,
                   int os,
                   int len)
Set the XMLDoc container. Also set the offset and len of the document with respect to the container.

Parameters:
ba - byte[]
os - int (in byte)
len - int (in byte)

writeIndex

public void writeIndex(java.io.OutputStream os)
                throws java.io.IOException,
                       IndexWriteException
This method writes the VTD+XML into an outputStream

Parameters:
os -
Throws:
java.io.IOException
IndexWriteException

writeIndex

public void writeIndex(java.lang.String fileName)
                throws java.io.IOException,
                       IndexWriteException
This method writes the VTD+XML file into a file of the given name

Parameters:
fileName -
Throws:
java.io.IOException
IndexWriteException

writeSeparateIndex

public void writeSeparateIndex(java.io.OutputStream os)
                        throws java.io.IOException,
                               IndexWriteException
This method writes the VTDs and LCs into an outputStream

Parameters:
os -
Throws:
java.io.IOException
IndexWriteException

writeSeparateIndex

public void writeSeparateIndex(java.lang.String fileName)
                        throws java.io.IOException,
                               IndexWriteException
This method writes the VTDs and LCs into a file of the given name XML is not part of the index please refer to VTD-XML web site for the spec and explanation

Parameters:
fileName -
Throws:
java.io.IOException
IndexWriteException