com.ximpleware.extended
Class VTDNavHuge

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

public class VTDNavHuge
extends Object

VTDNavHuge is a cursor-based VTD record navigator supporting extended VTD (256 GB max file size). The core navigation routines are toElement() and toElementNS() push() and pop() allows one to save and restore the location of the cursor String comparsions and primitive data type conversions are done directly from VTD records without intermediatary string creation.


Field Summary
protected  boolean atTerminal
           
protected  int[] context
           
protected  ContextBuffer contextStack2
           
protected  long docLen
           
protected  long docOffset
           
protected  int encoding
           
static int FC
           
static int FIRST_CHILD
           
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
           
protected  ILongBuffer l1Buffer
           
protected  int l1index
           
protected  ILongBuffer l2Buffer
           
protected  int l2index
           
protected  int l2lower
           
protected  int l2upper
           
protected  IIntBuffer l3Buffer
           
protected  int l3index
           
protected  int l3lower
           
protected  int l3upper
           
static int LAST_CHILD
           
static int LC
           
protected  int LN
           
protected static long MASK_TOKEN_FULL_LEN
           
protected  int nestingLevel
           
static int NEXT_SIBLING
           
protected  boolean ns
           
static int NS
           
static int P
           
static int PARENT
           
static int PREV_SIBLING
           
static int PS
           
static int R
           
static int ROOT
           
protected  int rootIndex
           
protected  int[] stackTemp
           
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
           
protected  ILongBuffer vtdBuffer
           
protected  int vtdSize
           
protected  IByteBuffer XMLDoc
           
 
Constructor Summary
protected VTDNavHuge(int RootIndex, int enc, boolean NS, int depth, IByteBuffer x, ILongBuffer vtd, ILongBuffer l1, ILongBuffer l2, IIntBuffer l3, long so, long length)
          Initialize the VTD navigation object.
 
Method Summary
protected  void clearStack2()
          clear the contextStack2 after XPath evaluation
 VTDNavHuge cloneNav()
          Clone the VTDNav instance to get with shared XML, VTD and LC buffers The node position is also copied from the original instance
 int compareRawTokenString(int index, String s)
          New in 2.0 Compare the string against the token at the given index value.
protected  int compareRawTokenString(long offset, int len, String s)
          Lexicographically compare a string against a token with given offset and len, entities doesn't get resolved.
 int compareTokens(int i1, VTDNavHuge vn2, int i2)
          This method compares two VTD tokens of VTDNav objects The behavior of this method is like compare the strings corresponds to i1 and i2, meaning for text or attribute val, entities will be converted into the corresponding char
 int compareTokenString(int index, String s)
          New in 2.0 Compare the string against the token at the given index value.
protected  int compareTokenString(long offset, int len, String s)
           
 boolean contains(int index, String s)
          Test whether a given token contains s. notie that this function directly operates on the byte content of the token to avoid string creation
 VTDNavHuge duplicateNav()
          Duplicate the VTDNavHuge instance with shared XML, VTD and LC buffers This method may be useful for parallel XPath evaluation The node Position is at root element
 boolean endsWith(int index, String s)
          Test the end of token content at index i matches the content of s, notice that this is to save the string allocation cost of using String's built-in endsWidth
protected  boolean getAtTerminal()
          Get the value of atTerminal This function only gets called in XPath eval
 int getAttrCount()
          Return the attribute count of the element at the cursor position.
 int getAttrVal(String an)
          Get the token index of the attribute value given an attribute name.
 int getAttrValNS(String URL, String ln)
          Get the token index of the attribute value of given URL and local name.
 long[] getContentFragment()
          Get content fragment returns a long[2] encoding the offset and length of the byte segment of the content of current element, which is the byte segment between the starting tag and ending tag, null is returned if the current element is an empty element
 int getCurrentDepth()
          Get the depth (>=0) of the current element.
 int getCurrentIndex()
          Get the index value of the current element.
protected  int getCurrentIndex2()
           
 long[] getElementFragment()
          Return the offset (64-bit) and length (64-bit) of an element fragment
 ElementFragmentNsHuge getElementFragmentNs()
           
 int getEncoding()
          Get the encoding of the XML document.
 int getNestingLevel()
          Get the maximum nesting depth of the XML document (>0).
protected  long getOffsetAfterHead()
           
 int getRawStringLength(int index)
           
 int getRootIndex()
          Get root index value , which is the index val of document element
 long[] getSiblingElementFragments(int i)
          Return the byte offset and length of up to i sibling fragments.
 int getStringLength(int index)
           
 int getText()
          This method returns of the token index of the type character data or CDATA.
 int getTokenCount()
          Get total number of VTD tokens for the current XML document.
 int getTokenDepth(int index)
          Get the depth value of a token (>=0).
 int getTokenLength(int index)
          Get the token length at the given index value please refer to VTD spec for more details Length is in terms of the UTF char unit For prefixed tokens, it is the qualified name length.
 long getTokenOffset(int index)
          Get the starting offset of the token at the given index.
 int getTokenType(int index)
          Get the token type of the token at the given index value.
 IByteBuffer getXML()
          Get the XML document
 boolean hasAttr(String an)
          Test whether current element has an attribute with the matching name. "*" will match any attribute name, therefore is a test whether there is any attribute at all if namespace is disabled, this function will not distinguish between ns declaration and attribute otherwise, ns tokens are invisible Creation date: (11/16/03 5:50:26 PM)
 boolean hasAttrNS(String URL, String ln)
          Test whether the current element has an attribute with matching namespace URL and localname.
protected  boolean iterate_following(String en, boolean special)
          This function is called by selectElement_F in autoPilot
protected  boolean iterate_followingNS(String URL, String ln)
          This function is called by selectElementNS_F in autoPilot
protected  boolean iterate_preceding(String en, int[] a, boolean special)
          This function is called by selectElement_P in autoPilot
protected  boolean iterate_precedingNS(String URL, String ln, int[] a)
          This function is called by selectElementNS_P in autoPilot
protected  boolean iterate(int dp, String en, boolean special)
          This method is similar to getElementByName in DOM except it doesn't return the nodeset, instead it iterates over those nodes.
protected  boolean iterateNS(int dp, String URL, String ln)
          This method is similar to getElementByName in DOM except it doesn't return the nodeset, instead it iterates over those nodes .
protected  int lookupNS()
          Test whether the URL is defined in the scope.
protected  int lookupNS(long offset, int len)
          This function returns the VTD record index of the namespace that matches the prefix of cursor element
 boolean matchElement(String en)
          Test if the current element matches the given name.
 boolean matchElementNS(String URL, String ln)
          Test whether the current element matches the given namespace URL and localname.
 boolean matchRawTokenString(int index, String s)
          Match the string against the token at the given index value.
 boolean matchTokens(int i1, VTDNavHuge vn2, int i2)
          This method matches two VTD tokens of VTDNav objects
 boolean matchTokenString(int index, String s)
          Match the string against the token at the given index value.
 double parseDouble(int index)
          Convert a vtd token into a double.
 float parseFloat(int index)
          Convert a vtd token into a float.
 int parseInt(int index)
          Convert a vtd token into an int.
protected  int parseInt(int index, int radix)
          Convert a vtd token into an int, with the given radix.
 long parseLong(int index)
          Convert a vtd token into a long.
protected  long parseLong(int index, int radix)
          Convert a vtd token into a long, with the given radix.
 boolean pop()
          Load the context info from ContextBuffer.
protected  boolean pop2()
          Load the context info from contextStack2.
 void push()
          Store the context info into the ContextBuffer.
protected  void push2()
          Store the context info into the contextStack2.
 void sampleState(FastIntBuffer fib)
          This is for debugging purpose
protected  void setAtTerminal(boolean b)
          Set the value of atTerminal This function only gets called in XPath eval when a step calls for @* or child::text()
 boolean startsWith(int index, String s)
          Test the start of token content at index i matches the content of s, notice that this is to save the string allocation cost of using String's built-in startsWidth
 boolean toElement(int direction)
          A generic navigation method.
 boolean toElement(int direction, String en)
          A generic navigation method.
 boolean toElementNS(int direction, String URL, String ln)
          A generic navigation method with namespace support.
 String toNormalizedString(int index)
          This method normalizes a token into a string in a way that resembles DOM.
 String toRawString(int index)
          Convert a token at the given index to a String, (built-in entity and char references not resolved) (entities and char references not expanded).
protected  String toRawString(long os, int len)
           
 String toRawStringLowerCase(int index)
           
protected  String toRawStringLowerCase(long os, int len)
           
 String toRawStringUpperCase(int index)
           
protected  String toRawStringUpperCase(long os, int len)
           
 String toString(int index)
          Convert a token at the given index to a String, (entities and char references resolved).
protected  String toString(long os, int len)
           
 String toStringLowerCase(int index)
          Convert a token at the given index to a String and any upper case character will be converted to lower case, (entities and char references resolved).
protected  String toStringLowerCase(long os, int len)
          Convert the byte content segment (in terms of offset and length) to String, upper case characters are converted to lower case
 String toStringUpperCase(int index)
          Convert a token at the given index to a String and any lower case character will be converted to upper case, (entities and char references resolved).
protected  String toStringUpperCase(long os, int len)
          Convert the byte content segment (in terms of offset and length) to String, lower case characters are converted to upper case
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROOT

public static final int ROOT
See Also:
Constant Field Values

PARENT

public static final int PARENT
See Also:
Constant Field Values

FIRST_CHILD

public static final int FIRST_CHILD
See Also:
Constant Field Values

LAST_CHILD

public static final int LAST_CHILD
See Also:
Constant Field Values

NEXT_SIBLING

public static final int NEXT_SIBLING
See Also:
Constant Field Values

PREV_SIBLING

public static final int PREV_SIBLING
See Also:
Constant Field Values

R

public static final int R
See Also:
Constant Field Values

P

public static final int P
See Also:
Constant Field Values

FC

public static final int FC
See Also:
Constant Field Values

LC

public static final int LC
See Also:
Constant Field Values

NS

public static final int NS
See Also:
Constant Field Values

PS

public static final int PS
See Also:
Constant Field Values

TOKEN_STARTING_TAG

public static final int TOKEN_STARTING_TAG
See Also:
Constant Field Values

TOKEN_ENDING_TAG

public static final int TOKEN_ENDING_TAG
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_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_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_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_CDATA_VAL

public static final int TOKEN_CDATA_VAL
See Also:
Constant Field Values

TOKEN_DTD_VAL

public static final int TOKEN_DTD_VAL
See Also:
Constant Field Values

TOKEN_DOCUMENT

public static final int TOKEN_DOCUMENT
See Also:
Constant Field Values

FORMAT_UTF8

public static final int FORMAT_UTF8
See Also:
Constant Field Values

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_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_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_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

FORMAT_UTF_16LE

public static final int FORMAT_UTF_16LE
See Also:
Constant Field Values

FORMAT_UTF_16BE

public static final int FORMAT_UTF_16BE
See Also:
Constant Field Values

MASK_TOKEN_FULL_LEN

protected static final long MASK_TOKEN_FULL_LEN
See Also:
Constant Field Values

rootIndex

protected int rootIndex

nestingLevel

protected int nestingLevel

context

protected int[] context

atTerminal

protected boolean atTerminal

l2upper

protected int l2upper

l2lower

protected int l2lower

l3upper

protected int l3upper

l3lower

protected int l3lower

l2index

protected int l2index

l3index

protected int l3index

l1index

protected int l1index

vtdBuffer

protected ILongBuffer vtdBuffer

l1Buffer

protected ILongBuffer l1Buffer

l2Buffer

protected ILongBuffer l2Buffer

l3Buffer

protected IIntBuffer l3Buffer

XMLDoc

protected IByteBuffer XMLDoc

contextStack2

protected ContextBuffer contextStack2

LN

protected int LN

encoding

protected int encoding

ns

protected boolean ns

stackTemp

protected int[] stackTemp

docOffset

protected long docOffset

docLen

protected long docLen

vtdSize

protected int vtdSize
Constructor Detail

VTDNavHuge

protected VTDNavHuge(int RootIndex,
                     int enc,
                     boolean NS,
                     int depth,
                     IByteBuffer x,
                     ILongBuffer vtd,
                     ILongBuffer l1,
                     ILongBuffer l2,
                     IIntBuffer l3,
                     long so,
                     long length)
Initialize the VTD navigation object.

Parameters:
RootIndex - int
maxDepth - int
encoding - int
NS - boolean
x - byte[]
vtd - com.ximpleware.extended.ILongBuffer
l1 - com.ximpleware.extended.ILongBuffer
l2 - com.ximpleware.extended.ILongBuffer
l3 - com.ximpleware.extended.IIntBuffer
so - int starting offset of the document(in byte)
length - int length of the document (in byte)
Method Detail

getAttrCount

public int getAttrCount()
Return the attribute count of the element at the cursor position. when ns is false, ns tokens are considered attributes; otherwise, ns tokens are not considered attributes

Returns:
int

getAttrVal

public int getAttrVal(String an)
               throws NavExceptionHuge
Get the token index of the attribute value given an attribute name.

Parameters:
an - java.lang.String
Returns:
int (-1 if no such attribute name exists)
Throws:
NavExceptionHuge - The exception if the underlying byte content contains various errors. Notice that we are being conservative in making little assumption on the correctness of underlying byte content. This is because the VTD etc can be generated by another machine from a load-balancer.
IllegalArguementException - if an is null

getAttrValNS

public int getAttrValNS(String URL,
                        String ln)
                 throws NavExceptionHuge
Get the token index of the attribute value of given URL and local name. If ns is not enabled, the lookup will return -1, indicating a no-found. Also namespace nodes are invisible using this method. One can't use * to indicate any name space because * is ambiguous!!

Parameters:
URL - java.lang.String (Name space URL)
ln - java.lang.String (local name)
Returns:
int (-1 if no matching attribute found)
Throws:
NavExceptionHuge - The exception if the underlying byte content contains various errors. Notice that we are being conservative in making little assumption on the correctness of underlying byte content. This is because the VTD etc can be generated by another machine from a load-balancer.
IllegalArguementException - if s is null

getCurrentDepth

public final int getCurrentDepth()
Get the depth (>=0) of the current element. Creation date: (11/16/03 6:58:22 PM)

Returns:
int

getCurrentIndex

public final int getCurrentIndex()
Get the index value of the current element. Creation date: (11/16/03 6:40:25 PM)

Returns:
int

getCurrentIndex2

protected final int getCurrentIndex2()

getEncoding

public final int getEncoding()
Get the encoding of the XML document.

Returns:
int

getNestingLevel

public final int getNestingLevel()
Get the maximum nesting depth of the XML document (>0). max depth is nestingLevel -1

Returns:
int

getOffsetAfterHead

protected final long getOffsetAfterHead()
Returns:

getRootIndex

public final int getRootIndex()
Get root index value , which is the index val of document element

Returns:
int

getText

public int getText()
This method returns of the token index of the type character data or CDATA. Notice that it is intended to support data orient XML (not mixed-content XML). return the index of the text token, or -1 if none exists.

Returns:
int

getTokenCount

public final int getTokenCount()
Get total number of VTD tokens for the current XML document.

Returns:
int

getTokenDepth

public final int getTokenDepth(int index)
Get the depth value of a token (>=0).

Parameters:
index - int
Returns:
int

getTokenLength

public int getTokenLength(int index)
Get the token length at the given index value please refer to VTD spec for more details Length is in terms of the UTF char unit For prefixed tokens, it is the qualified name length. When ns is not enabled, return the full name length for attribute name and element name When ns is enabled, return an int with upper 16 bit for prefix length, lower 16 bit for qname length

Parameters:
index - int
Returns:
int

getTokenOffset

public final long getTokenOffset(int index)
Get the starting offset of the token at the given index.

Parameters:
index - int
Returns:
int

getXML

public final IByteBuffer getXML()
Get the XML document

Returns:
IByteBuffer

getTokenType

public final int getTokenType(int index)
Get the token type of the token at the given index value. Creation date: (11/16/03 6:41:51 PM)

Parameters:
index - int
Returns:
int

hasAttr

public final boolean hasAttr(String an)
                      throws NavExceptionHuge
Test whether current element has an attribute with the matching name. "*" will match any attribute name, therefore is a test whether there is any attribute at all if namespace is disabled, this function will not distinguish between ns declaration and attribute otherwise, ns tokens are invisible Creation date: (11/16/03 5:50:26 PM)

Parameters:
an - java.lang.String
Returns:
boolean (true if such an attribute exists)
Throws:
NavExceptionHuge - The exception if the underlying byte content contains various errors. Notice that we are being conservative in making little assumption on the correctness of underlying byte content. This is because the VTD etc can be generated by another machine from a load-balancer.
IllegalArguementException - if an is null

hasAttrNS

public final boolean hasAttrNS(String URL,
                               String ln)
                        throws NavExceptionHuge
Test whether the current element has an attribute with matching namespace URL and localname. If ns is false, return false immediately

Parameters:
URL - java.lang.String (namespace URL)
ln - java.lang.String (localname )
Returns:
boolean
Throws:
NavExceptionHuge - The exception if the underlying byte content contains various errors. Notice that we are being conservative in making little assumption on the correctness of underlying byte content. This is because the VTD can be generated by another machine such as a load-balancer.
IllegalArguementException - if ln is null

iterate_preceding

protected boolean iterate_preceding(String en,
                                    int[] a,
                                    boolean special)
                             throws NavExceptionHuge
This function is called by selectElement_P in autoPilot

Parameters:
en - element Name
a - context of current position
special - whether the test type is node()
Returns:
boolean
Throws:
NavExceptionHuge

iterate_precedingNS

protected boolean iterate_precedingNS(String URL,
                                      String ln,
                                      int[] a)
                               throws NavExceptionHuge
This function is called by selectElementNS_P in autoPilot

Parameters:
URL -
ln -
Returns:
boolean
Throws:
NavExceptionHuge

iterate_following

protected boolean iterate_following(String en,
                                    boolean special)
                             throws NavExceptionHuge
This function is called by selectElement_F in autoPilot

Parameters:
en - ElementName
special - whether it is a node()
Returns:
boolean
Throws:
NavExceptionHuge

iterate_followingNS

protected boolean iterate_followingNS(String URL,
                                      String ln)
                               throws NavExceptionHuge
This function is called by selectElementNS_F in autoPilot

Parameters:
URL -
ln -
Returns:
boolean
Throws:
NavExceptionHuge

iterate

protected boolean iterate(int dp,
                          String en,
                          boolean special)
                   throws NavExceptionHuge
This method is similar to getElementByName in DOM except it doesn't return the nodeset, instead it iterates over those nodes. Notice that this method is called by the "iterate" method in the Autopilot class. "*" will match any element Creation date: (12/2/03 2:31:20 PM)

Parameters:
dp - int (The depth of the starting position before iterating)
en - java.lang.String
Returns:
boolean
Throws:
NavExceptionHuge - The exception is signaled if the underlying byte content contains various errors. Notice that we are being conservative in making little assumption on the correctness of underlying byte content. This is because VTD records can be generated by another machine from a load-balancer. null element name allowed represent node()in XPath;

iterateNS

protected final boolean iterateNS(int dp,
                                  String URL,
                                  String ln)
                           throws NavExceptionHuge
This method is similar to getElementByName in DOM except it doesn't return the nodeset, instead it iterates over those nodes . When URL is "*" it will match any namespace if ns is false, return false immediately

Parameters:
dp - int (The depth of the starting position before iterating)
URL - java.lang.String
ln - java.lang.String
Returns:
boolean
Throws:
NavExceptionHuge - The exception if the underlying byte content contains various errors. Notice that we are being conservative in making little assumption on the correctness of underlying byte content. This is because VTD records can be generated by another machine from a load-balancer..
IllegalArguementException - if ln is null example int depth = nv.getCurrentDepth() while(iterateNS(depth, "www.url.com","node_name")){ push(); // store the current position //move position safely pop(); // load the position }

matchElement

public final boolean matchElement(String en)
                           throws NavExceptionHuge
Test if the current element matches the given name. Creation date: (11/26/03 2:09:43 PM)

Parameters:
en - java.lang.String
Returns:
boolean
Throws:
NavExceptionHuge - If the underlying raw char representation has errors.

matchElementNS

public boolean matchElementNS(String URL,
                              String ln)
                       throws NavExceptionHuge
Test whether the current element matches the given namespace URL and localname. URL, when set to "*", matches any namespace (including null), when set to null, defines a "always-no-match" ln is the localname that, when set to *, matches any localname

Parameters:
URL - java.lang.String
ln - java.lang.String
Returns:
boolean
Throws:
NavExceptionHuge - When there is any encoding conversion error or unknown entity.
IllegalArgumentException - if ln == null

compareTokenString

protected int compareTokenString(long offset,
                                 int len,
                                 String s)
                          throws NavExceptionHuge
Throws:
NavExceptionHuge

contains

public final boolean contains(int index,
                              String s)
                       throws NavExceptionHuge
Test whether a given token contains s. notie that this function directly operates on the byte content of the token to avoid string creation

Parameters:
index -
s -
Returns:
Throws:
NavExceptionHuge

compareRawTokenString

protected int compareRawTokenString(long offset,
                                    int len,
                                    String s)
                             throws NavExceptionHuge
Lexicographically compare a string against a token with given offset and len, entities doesn't get resolved.

Parameters:
offset - int
len - int
s - java.lang.String
Returns:
int (0 if they are equal, 1 if greater, else -1)
Throws:
NavExceptionHuge - The exception if the underlying byte content contains various errors. Notice that we are being conservative in making little assumption on the correctness of underlying byte content. This is because the VTD can be generated by another machine such as a load-balancer.

compareRawTokenString

public final int compareRawTokenString(int index,
                                       String s)
                                throws NavExceptionHuge
New in 2.0 Compare the string against the token at the given index value. When a token is an attribute name or starting tag, qualified name is what gets compared against This method has to take care of the underlying encoding conversion but it doesn't resolve entity reference in the underlying document The behavior is the same as calling toRawString on index, then compare to s

Parameters:
index -
s -
Returns:
the result of lexical comparison
Throws:
NavExceptionHuge

matchRawTokenString

public final boolean matchRawTokenString(int index,
                                         String s)
                                  throws NavExceptionHuge
Match the string against the token at the given index value. When a token is an attribute name or starting tag, qualified name is what gets matched against This method has to take care of the underlying encoding conversion but it doesn't resolve entity reference in the underlying document

Parameters:
index - int (index into the VTD token buffer)
s - java.lang.String
Returns:
boolean
Throws:
NavExceptionHuge - When if the underlying byte content contains various errors. Notice that we are being conservative in making little assumption on the correctness of underlying byte content. This is because the VTD can be generated by another machine such as a load-balancer.

compareTokenString

public int compareTokenString(int index,
                              String s)
                       throws NavExceptionHuge
New in 2.0 Compare the string against the token at the given index value. When a token is an attribute name or starting tag, qualified name is what gets matched against This method has to take care of the underlying encoding conversion as well as entity reference comparison

Parameters:
index -
s -
Returns:
int
Throws:
NavExceptionHuge

matchTokenString

public final boolean matchTokenString(int index,
                                      String s)
                               throws NavExceptionHuge
Match the string against the token at the given index value. When a token is an attribute name or starting tag, qualified name is what gets matched against This method has to take care of the underlying encoding conversion as well as entity reference comparison

Parameters:
index - int
s - java.lang.String
Returns:
boolean
Throws:
NavExceptionHuge - When if the underlying byte content contains various errors. Notice that we are being conservative in making little assumption on the correctness of underlying byte content. This is because the VTD can be generated by another machine such as a load-balancer.

parseDouble

public double parseDouble(int index)
                   throws NavExceptionHuge
Convert a vtd token into a double. Creation date: (12/8/03 2:28:31 PM)

Returns:
double
Throws:
NavExceptionHuge - The exception if the underlying byte content contains various errors. Notice that we are being conservative in making little assumption on the correctness of underlying byte content. This is because the VTD can be generated by another machine such as a load-balancer.

parseFloat

public float parseFloat(int index)
                 throws NavExceptionHuge
Convert a vtd token into a float. we assume token type to be attr val or character data Creation date: (12/8/03 2:28:18 PM)

Returns:
float
Throws:
NavExceptionHuge - The exception if the underlying byte content contains various errors. Notice that we are being conservative in making little assumption on the correctness of underlying byte content. This is because the VTD can be generated by another machine such as a load-balancer.

parseInt

public int parseInt(int index)
             throws NavExceptionHuge
Convert a vtd token into an int. This method will automatically strip off the leading and trailing we assume token type to be attr val or character data zero, unlike Integer.parseInt(int index) Creation date: (12/8/03 2:32:22 PM)

Parameters:
index - int
Returns:
int
Throws:
NavExceptionHuge - The exception if the underlying byte content contains various errors. Notice that we are being conservative in making little assumption on the correctness of underlying byte content. This is because the VTD can be generated by another machine such as a load-balancer.

parseInt

protected int parseInt(int index,
                       int radix)
                throws NavExceptionHuge
Convert a vtd token into an int, with the given radix. we assume token type to be attr val or character data the first char can be either '+' or '-' Creation date: (12/16/03 1:21:20 PM)

Parameters:
index - int
radix - int
Returns:
int
Throws:
NavExceptionHuge - The exception if the underlying byte content contains various errors. Notice that we are being conservative in making little assumption on the correctness of underlying byte content. This is because the VTD can be generated by another machine such as a load-balancer.

parseLong

public long parseLong(int index)
               throws NavExceptionHuge
Convert a vtd token into a long. we assume token type to be attr val or character data Creation date: (12/8/03 2:32:59 PM)

Parameters:
index - int
Returns:
long
Throws:
NavExceptionHuge - The exception if the underlying byte content contains various errors. Notice that we are being conservative in making little assumption on the correctness of underlying byte content. This is because the VTD can be generated by another machine such as a load-balancer.

parseLong

protected long parseLong(int index,
                         int radix)
                  throws NavExceptionHuge
Convert a vtd token into a long, with the given radix. the first char can be either '+' or '-', leading and trailing will be stripped we assume token type to be attr val or character data Creation date: (12/17/03 1:51:06 PM)

Parameters:
index - int
radix - int
Returns:
long
Throws:
NavExceptionHuge - The exception if the underlying byte content contains various errors. Notice that we are being conservative in making little assumption on the correctness of underlying byte content. This is because the VTD can be generated by another machine such as a load-balancer.

pop

public final boolean pop()
Load the context info from ContextBuffer. Info saved including LC and current state of the context

Returns:
boolean

pop2

protected final boolean pop2()
Load the context info from contextStack2. This method is dedicated for XPath evaluation.

Returns:
status of pop2

push

public final void push()
Store the context info into the ContextBuffer. Info saved including LC and current state of the context Creation date: (11/16/03 7:00:27 PM)


push2

protected final void push2()
Store the context info into the contextStack2. This method is reserved for XPath Evaluation


clearStack2

protected final void clearStack2()
clear the contextStack2 after XPath evaluation


lookupNS

protected final int lookupNS()
                      throws NavExceptionHuge
Test whether the URL is defined in the scope. Null is allowed to indicate the name space is undefined. Creation date: (11/16/03 7:54:01 PM)

Parameters:
URL - java.lang.String
Throws:
NavExceptionHuge - When there is any encoding conversion error or unknown entity.

lookupNS

protected int lookupNS(long offset,
                       int len)
This function returns the VTD record index of the namespace that matches the prefix of cursor element

Parameters:
URL -
Returns:
int

toElement

public boolean toElement(int direction)
                  throws NavExceptionHuge
A generic navigation method. Move the current to the element according to the direction constants If no such element, no position change and return false. Creation date: (12/2/03 1:43:50 PM) Legal direction constants are
                           ROOT               0 
               PARENT                 1 
               FIRST_CHILD            2 
               LAST_CHILD             3 
                       NEXT_SIBLING       4 
               PREV_SIBLING       5 

Parameters:
direction - int
Returns:
boolean
Throws:
NavExceptionHuge - When direction value is illegal.

toElement

public boolean toElement(int direction,
                         String en)
                  throws NavExceptionHuge
A generic navigation method. Move the current to the element according to the direction constants and the element name If no such element, no position change and return false. "*" matches any element Creation date: (12/2/03 1:43:50 PM) Legal direction constants are
          ROOT            0  
          PARENT          1  
          FIRST_CHILD     2  
          LAST_CHILD      3  
          NEXT_SIBLING    4  
          PREV_SIBLING    5  

for ROOT and PARENT, element name will be ignored.

Parameters:
direction - int
en - String
Returns:
boolean
Throws:
NavExceptionHuge - When direction value is illegal. Or there are errors in underlying byte representation of the document
IllegalArguementException - if en is null

toElementNS

public boolean toElementNS(int direction,
                           String URL,
                           String ln)
                    throws NavExceptionHuge
A generic navigation method with namespace support. Move the current to the element according to the direction constants and the prefix and local names If no such element, no position change and return false. URL * matches any namespace, including undefined namespaces a null URL means hte namespace prefix is undefined for the element ln * matches any localname Creation date: (12/2/03 1:43:50 PM) Legal direction constants are
          ROOT            0  
          PARENT          1  
          FIRST_CHILD     2  
          LAST_CHILD      3  
          NEXT_SIBLING    4  
          PREV_SIBLING    5  

for ROOT and PARENT, element name will be ignored. If not ns enabled, return false immediately with no position change.

Parameters:
direction - int
URL - String
ln - String
Returns:
boolean
Throws:
NavExceptionHuge - When direction value is illegal. Or there are errors in underlying byte representation of the document

toNormalizedString

public String toNormalizedString(int index)
                          throws NavExceptionHuge
This method normalizes a token into a string in a way that resembles DOM. The leading and trailing white space characters will be stripped. The entity and character references will be resolved Multiple whitespaces char will be collapsed into one. Whitespaces via entities will nonetheless be preserved. Creation date: (12/8/03 1:57:10 PM)

Parameters:
index - int
Returns:
java.lang.String
Throws:
NavExceptionHuge - When the encoding has errors

toRawString

public String toRawString(int index)
                   throws NavExceptionHuge
Convert a token at the given index to a String, (built-in entity and char references not resolved) (entities and char references not expanded). Creation date: (11/16/03 7:28:49 PM)

Parameters:
index - int
Returns:
java.lang.String
Throws:
NavExceptionHuge - When the encoding has errors

toRawString

protected String toRawString(long os,
                             int len)
                      throws NavExceptionHuge
Throws:
NavExceptionHuge

toRawStringLowerCase

public final String toRawStringLowerCase(int index)
                                  throws NavExceptionHuge
Throws:
NavExceptionHuge

toRawStringUpperCase

public final String toRawStringUpperCase(int index)
                                  throws NavExceptionHuge
Parameters:
index -
Returns:
Throws:
NavException
NavExceptionHuge

toRawStringLowerCase

protected final String toRawStringLowerCase(long os,
                                            int len)
                                     throws NavExceptionHuge
Throws:
NavExceptionHuge

toRawStringUpperCase

protected final String toRawStringUpperCase(long os,
                                            int len)
                                     throws NavExceptionHuge
Throws:
NavExceptionHuge

toString

public String toString(int index)
                throws NavExceptionHuge
Convert a token at the given index to a String, (entities and char references resolved). An attribute name or an element name will get the UCS2 string of qualified name Creation date: (11/16/03 7:27:19 PM)

Parameters:
index -
Returns:
java.lang.String
Throws:
NavExceptionHuge

toString

protected String toString(long os,
                          int len)
                   throws NavExceptionHuge
Throws:
NavExceptionHuge

matchTokens

public final boolean matchTokens(int i1,
                                 VTDNavHuge vn2,
                                 int i2)
                          throws NavExceptionHuge
This method matches two VTD tokens of VTDNav objects

Parameters:
i1 -
vn2 -
i2 -
Returns:
boolean true if two tokens are lexically identical
Throws:
NavExceptionHuge

setAtTerminal

protected final void setAtTerminal(boolean b)
Set the value of atTerminal This function only gets called in XPath eval when a step calls for @* or child::text()

Parameters:
b -

getAtTerminal

protected final boolean getAtTerminal()
Get the value of atTerminal This function only gets called in XPath eval

Returns:
boolean

sampleState

public void sampleState(FastIntBuffer fib)
This is for debugging purpose

Parameters:
fib -

getStringLength

public final int getStringLength(int index)
                          throws NavExceptionHuge
Throws:
NavExceptionHuge

getRawStringLength

public final int getRawStringLength(int index)
                             throws NavExceptionHuge
Throws:
NavExceptionHuge

compareTokens

public int compareTokens(int i1,
                         VTDNavHuge vn2,
                         int i2)
                  throws NavExceptionHuge
This method compares two VTD tokens of VTDNav objects The behavior of this method is like compare the strings corresponds to i1 and i2, meaning for text or attribute val, entities will be converted into the corresponding char

Parameters:
i1 -
vn2 -
i2 -
Returns:
-1,0, or 1
Throws:
NavExceptionHuge

startsWith

public final boolean startsWith(int index,
                                String s)
                         throws NavExceptionHuge
Test the start of token content at index i matches the content of s, notice that this is to save the string allocation cost of using String's built-in startsWidth

Parameters:
index -
s -
Returns:
Throws:
NavExceptionHuge

endsWith

public final boolean endsWith(int index,
                              String s)
                       throws NavExceptionHuge
Test the end of token content at index i matches the content of s, notice that this is to save the string allocation cost of using String's built-in endsWidth

Parameters:
i -
Returns:
Throws:
NavExceptionHuge

toStringLowerCase

public String toStringLowerCase(int index)
                         throws NavExceptionHuge
Convert a token at the given index to a String and any upper case character will be converted to lower case, (entities and char references resolved). An attribute name or an element name will get the UCS2 string of qualified name

Parameters:
index -
Returns:
Throws:
NavExceptionHuge

toStringLowerCase

protected final String toStringLowerCase(long os,
                                         int len)
                                  throws NavExceptionHuge
Convert the byte content segment (in terms of offset and length) to String, upper case characters are converted to lower case

Parameters:
os - the offset of the segment
len - the length of the segment
Returns:
the corresponding string value
Throws:
NavExceptionHuge

toStringUpperCase

public String toStringUpperCase(int index)
                         throws NavExceptionHuge
Convert a token at the given index to a String and any lower case character will be converted to upper case, (entities and char references resolved). An attribute name or an element name will get the UCS2 string of qualified name

Parameters:
index -
Returns:
Throws:
NavExceptionHuge

toStringUpperCase

protected final String toStringUpperCase(long os,
                                         int len)
                                  throws NavExceptionHuge
Convert the byte content segment (in terms of offset and length) to String, lower case characters are converted to upper case

Parameters:
os - the offset of the segment
len - the length of the segment
Returns:
the corresponding string value
Throws:
NavExceptionHuge

getElementFragment

public long[] getElementFragment()
                          throws NavExceptionHuge
Return the offset (64-bit) and length (64-bit) of an element fragment

Returns:
a long[2], result[0]=offset, result[1]=length
Throws:
NavExceptionHuge

getContentFragment

public long[] getContentFragment()
                          throws NavExceptionHuge
Get content fragment returns a long[2] encoding the offset and length of the byte segment of the content of current element, which is the byte segment between the starting tag and ending tag, null is returned if the current element is an empty element

Returns:
long[2] whose upper 64 bite is length, lower 64 bit is offset
Throws:
NavExceptionHuge

getElementFragmentNs

public ElementFragmentNsHuge getElementFragmentNs()
                                           throws NavExceptionHuge
Throws:
NavExceptionHuge

duplicateNav

public final VTDNavHuge duplicateNav()
Duplicate the VTDNavHuge instance with shared XML, VTD and LC buffers This method may be useful for parallel XPath evaluation The node Position is at root element

Returns:
a VTDNavHuge instance

cloneNav

public final VTDNavHuge cloneNav()
Clone the VTDNav instance to get with shared XML, VTD and LC buffers The node position is also copied from the original instance

Returns:

getSiblingElementFragments

public long[] getSiblingElementFragments(int i)
                                  throws NavExceptionHuge
Return the byte offset and length of up to i sibling fragments. If there is a i+1 sibling element, the cursor element would move to it; otherwise, there is no cursor movement. If the cursor isn't positioned at an element (due to XPath evaluation), then -1 will be returned

Parameters:
i - number of silbing elements including the cursor element
Returns:
a long[2] encoding byte offset (lower 64 bits), length ( upper 64 bits) of those fragments
Throws:
NavExceptionHuge


Copyright © 2013. All Rights Reserved.