com.ximpleware
Class VTDNav

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

public class VTDNav
extends java.lang.Object

The VTD Navigator allows one to navigate XML document represented in VTD records and Location caches. There is one and only one cursor that you can navigate to any part of the tree. If a method operating on a node doesn't accept the node as input, by default it refers to the cursor element. The hierarchy consists entirely of elements.


Field Summary
protected  boolean atTerminal
           
protected  int[] context
           
protected  com.ximpleware.ContextBuffer contextStack
           
protected  com.ximpleware.ContextBuffer contextStack2
           
protected  int count
           
protected  BookMark currentNode
           
protected  int docLen
           
protected  int docOffset
           
protected  int encoding
           
static int FC
           
protected  FastIntBuffer fib
           
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  FastLongBuffer l1Buffer
           
protected  int l1index
           
protected  FastLongBuffer l2Buffer
           
protected  int l2index
           
protected  int l2lower
           
protected  int l2upper
           
protected  FastIntBuffer l3Buffer
           
protected  int l3index
           
protected  int l3lower
           
protected  int l3upper
           
static int LAST_CHILD
           
static int LC
           
protected  int LN
           
protected  java.lang.String localName
           
protected  int localNameIndex
           
protected static long MASK_TOKEN_DEPTH
           
protected static long MASK_TOKEN_FULL_LEN
           
protected static long MASK_TOKEN_NS_MARK
           
protected static long MASK_TOKEN_OFFSET
           
protected static long MASK_TOKEN_PRE_LEN
           
protected static long MASK_TOKEN_QN_LEN
           
protected static long MASK_TOKEN_TYPE
           
protected  short maxLCDepthPlusOne
           
protected  java.lang.String name
           
protected  int nameIndex
           
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  boolean shallowDepth
           
protected  int[] stackTemp
           
static int STRING_NORMALIZED
           
static int STRING_RAW
           
static int STRING_REGULAR
           
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  java.lang.String URIName
           
protected  FastLongBuffer vtdBuffer
           
protected  int vtdSize
           
protected  com.ximpleware.IByteBuffer XMLDoc
           
static short XPATH_STRING_MODE_LOWERCASE
           
static short XPATH_STRING_MODE_NORMAL
           
static short XPATH_STRING_MODE_UPPERCASE
           
 
Constructor Summary
protected VTDNav()
           
protected VTDNav(int RootIndex, int enc, boolean NS, int depth, com.ximpleware.IByteBuffer x, FastLongBuffer vtd, FastLongBuffer l1, FastLongBuffer l2, FastIntBuffer l3, int so, int length)
          Initialize the VTD navigation object.
 
Method Summary
protected  void clearStack2()
          clear the contextStack2 after XPath evaluation
 VTDNav cloneNav()
          Clone the VTDNav instance to get with shared XML, VTD and LC buffers The node position is also copied from the original instance
protected  int compareNormalizedTokenString2(int offset, int len, java.lang.String s)
           
protected  int compareRawTokenString(int offset, int len, java.lang.String s)
          Lexicographically compare a string against a token with given offset and len, entities doesn't get resolved.
 int compareRawTokenString(int index, java.lang.String s)
          New in 2.0 Compare the string against the token at the given index value.
 int compareTokens(int i1, VTDNav vn2, int i2)
          New in 2.0 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, return 0 if two tokens are the identical when converted to Unicode String using toString() respectively
protected  int compareTokenString(int offset, int len, java.lang.String s)
           
 int compareTokenString(int index, java.lang.String s)
          New in 2.0 Compare the string against the token at the given index value.
 boolean contains(int index, java.lang.String s)
          Test whether a given token contains s.
 void dumpState()
           
 void dumpXML(java.io.OutputStream os)
          Dump the in memory XML text into output stream
 void dumpXML(java.lang.String fileName)
          Dump the in-memory copy of XML text into a file
 VTDNav duplicateNav()
          Duplicate the VTDNav 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, java.lang.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
 void fillXPathString(FastIntBuffer indexBuffer, FastIntBuffer countBuffer)
           
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(java.lang.String an)
          Get the token index of the attribute value given an attribute name.
 int getAttrValNS(java.lang.String URL, java.lang.String ln)
          Get the token index of the attribute value of given URL and local name.
 long getContentFragment()
          Get content fragment returns a long 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, -1 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()
          Get the starting offset and length of an element encoded in a long, upper 32 bits is length; lower 32 bits is offset Unit is in byte.
 ElementFragmentNs getElementFragmentNs()
          getElementFragmentNS returns a ns aware version of the element fragment encapsulated in an ElementFragment object
 int getEncoding()
          Get the encoding of the XML document.
 long getIndexsize()
          Precompute the size of VTD+XML index
 int getNestingLevel()
          Get the maximum nesting depth of the XML document (>0).
 int getNormalizedStringLength(int index)
          Get the string length of a token as if it is converted into a normalized UCS string
 long getOffsetAfterHead()
          Return the charater (not byte) offset after head (the ending bracket of the starting tag, not including an empty element, in which case 0xffffffff 00000000 | len is returned)
protected  long getOffsetBeforeTail()
           
 java.lang.String getPrefixString(int i)
          Return the prefix of a token as a string if the token is of the type of starting tag, attribute name, if the the prefix doesn't exist, a null string is returned; otherwise a null string is returned
 int getRawStringLength(int index)
          Get the string length as if the token is converted into a UCS string (entity not resolved)
 int getRootIndex()
          Get root index value , which is the index val of root element
 long getSiblingElementFragments(int i)
          Return the byte offset and length of up to i sibling fragments.
 int getStringLength(int index)
          getStringLength return the string length of a token as if the token is converted into a string (entity resolved for character data and attr val)
 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.
protected  int getTokenLength2(int index)
           
 int getTokenOffset(int index)
          Get the starting offset (unit in native char) of the token at the given index.
 int getTokenType(int index)
          Get the token type of the token at the given index value.
 com.ximpleware.IByteBuffer getXML()
          Get the XML document
 java.lang.String getXPathStringVal()
           
 java.lang.String getXPathStringVal(short mode)
          Return the String value of an Element Node
protected  java.lang.String getXPathStringVal2(int j, short mode)
           
 boolean hasAttr(java.lang.String an)
          Test whether current element has an attribute with the matching name.
 boolean hasAttrNS(java.lang.String URL, java.lang.String ln)
          Test whether the current element has an attribute with matching namespace URL and localname.
protected  boolean isElement(int index)
          Test the token type, to see if it is a starting tag.
protected  boolean isElementOrDocument(int index)
          Test the token type, to see if it is a starting tag or document token (introduced in 1.0).
protected  boolean iterate_following_node()
           
protected  boolean iterate_following(java.lang.String en, boolean special)
          This function is called by selectElement_F in autoPilot
protected  boolean iterate_followingNS(java.lang.String URL, java.lang.String ln)
          This function is called by selectElementNS_F in autoPilot
protected  boolean iterate_preceding_node(int[] a, int endIndex)
           
protected  boolean iterate_preceding(java.lang.String en, int[] a, int endIndex)
          This function is called by selectElement_P in autoPilot
protected  boolean iterate_precedingNS(java.lang.String URL, java.lang.String ln, int[] a, int endIndex)
          This function is called by selectElementNS_P in autoPilot
protected  boolean iterate(int dp, java.lang.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 iterateNode(int dp)
           
protected  boolean iterateNS(int dp, java.lang.String URL, java.lang.String ln)
          This method is similar to getElementByName in DOM except it doesn't return the nodeset, instead it iterates over those nodes .
protected  void loadCurrentNode()
           
protected  int lookupNS()
          Test whether the URL is defined in the scope.
protected  int lookupNS(int offset, int len)
          This function returns the VTD record index of the namespace that matches the prefix of cursor element
 boolean matchElement(java.lang.String en)
          Test if the current element matches the given name.
 boolean matchElementNS(java.lang.String URL, java.lang.String ln)
          Test whether the current element matches the given namespace URL and localname.
protected  boolean matchNormalizedTokenString2(int index, java.lang.String s)
          Match the string against the token at the given index value.
 boolean matchRawTokenString(int index, java.lang.String s)
          Match the string against the token at the given index value.
 boolean matchTokens(int i1, VTDNav vn2, int i2)
          This method matches two VTD tokens of VTDNav objects
 boolean matchTokenString(int index, java.lang.String s)
          Match the string against the token at the given index value.
protected  boolean nodeToElement(int direction)
          the corner case of element to node jump
 boolean overWrite(int index, byte[] ba)
          overWrite is introduced in version 2.0 that allows you to directly overwrite the XML content if the token is long enough If the operation is successful, the new content along with whitespaces will fill the available token space, and there will be no need to regenerate the VTD and LCs !!! The current version (2.0) only allows overwrites on attribute value, character data, and CDATA Consider the XML below: good After overwriting the token "good" with "bad," the new XML looks like: bad as you can see, "goo" is replaced with "bad" character-by-character, and the remaining "d" is replace with a white space
 boolean overWrite(int index, byte[] ba, int offset, int len)
          overWrite is introduced in version 2.0 that allows you to directly overwrite the XML content if the token is long enough If the operation is successful, white spaces will be used to fill the available token space, and there will be no need to regenerate the VTD and LCs The current version (2.0) only allows overwrites on attribute value, character data, and CDATA Consider the XML below: good After overwriting the token "good" with "bad," the new XML looks like: bad as you can see, "goo" is replaced with "bad", and the remaining "d" is replace with a white space
 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.
protected  void recoverNode_l1(int index)
           
protected  void recoverNode_l2(int index)
           
 void recoverNode(int index)
          This method takes a vtd index, and recover its correspondin node position, the index can only be of node type element, document, attribute name, attribute value or character data, or CDATA
protected  void resolveLC_l1()
          Sync level 1 location cache
protected  void resolveLC_l2()
          Sync Level 2 location cache
protected  void resolveLC_l3()
          Sync L3 location Cache
protected  void resolveLC()
          Sync up the current context with location cache.
 void sampleState(FastIntBuffer fib)
           
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()
protected  void setCurrentNode()
           
 boolean startsWith(int index, java.lang.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
protected  void sync(int depth, int index)
          Used by following:: axis
 boolean toElement(int direction)
          A generic navigation method.
 boolean toElement(int direction, java.lang.String en)
          A generic navigation method.
 boolean toElementNS(int direction, java.lang.String URL, java.lang.String ln)
          A generic navigation method with namespace support.
protected  boolean toNode_LastChild()
           
protected  boolean toNode_PrevSibling()
           
protected  boolean toNode(int dir)
           
 java.lang.String toNormalizedString(int index)
          This method normalizes a token into a string value of character data and attr val in a way that resembles DOM.
 java.lang.String toNormalizedString2(int index)
          (New since version 2.9) Shallow Normalization follows the rules below to normalize a token into a string *#xD#xA gets converted to #xA *For a character reference, append the referenced character to the normalized value.
 java.lang.String toNormalizedXPathString(int j)
           
 java.lang.String toRawString(int index)
          Convert a token at the given index to a String, (entities and char references not expanded).
 java.lang.String toRawString(int os, int len)
          Convert a segment of XML bytes a into string, without entity resolution
protected  void toRawString(int os, int len, java.lang.StringBuffer sb)
           
protected  void toRawString(int os, int len, java.lang.StringBuilder sb)
           
protected  void toRawString(java.lang.StringBuilder sb, int index)
           
 java.lang.String toRawStringLowerCase(int index)
          Convert a token at the given index to a String, upper case chars get converted into lower case (entities and char references not expanded).
protected  java.lang.String toRawStringLowerCase(int os, int len)
           
protected  void toRawStringLowerCase(int os, int len, java.lang.StringBuilder sb)
           
 java.lang.String toRawStringUpperCase(int index)
          Convert a token at the given index to a String, lower case chars get converted into upper case (entities and char references not expanded).
protected  java.lang.String toRawStringUpperCase(int os, int len)
           
protected  void toRawStringUpperCase(int os, int len, java.lang.StringBuilder sb)
           
 java.lang.String toString(int index)
          Convert a token at the given index to a String, (entities and char references resolved character data and attr val).
 java.lang.String toString(int os, int len)
          Convert the byte content segment (in terms of offset and length) to String (entities are resolved)
protected  void toString(int os, int len, java.lang.StringBuilder sb)
           
protected  void toString(java.lang.StringBuilder sb, int index)
           
 java.lang.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 for character data and attr val).
protected  java.lang.String toStringLowerCase(int os, int len)
          Convert the byte content segment (in terms of offset and length) to String, upper case characters are converted to lower case
protected  void toStringLowerCase(int os, int len, java.lang.StringBuilder sb)
           
protected  void toStringLowerCase(java.lang.StringBuilder sb, int index)
           
 java.lang.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 character data and attr val).
protected  java.lang.String toStringUpperCase(int os, int len)
          Convert the byte content segment (in terms of offset and length) to String, lower case characters are converted to upper case
protected  void toStringUpperCase(int os, int len, java.lang.StringBuilder sb)
           
protected  void toStringUpperCase(java.lang.StringBuilder sb, int index)
           
 boolean verifyNodeCorrectness()
          This is for debugging purpose
 void writeIndex(java.io.OutputStream os)
          Write VTDNav's internal structure into an OutputStream
 void writeIndex(java.lang.String fileName)
          Write VTDNav's internal structure into a VTD+XML file
 void writeSeparateIndex(java.io.OutputStream os)
          Write VTDNav's VTD and LCs into an OutputStream (XML not written out)
 void writeSeparateIndex(java.lang.String fileName)
          Write VTDNav's internal structure (VTD and LCs, but not XML) into a file
 boolean XPathStringVal_Contains(int j, java.lang.String s)
           
 boolean XPathStringVal_EndsWith(int j, java.lang.String s)
           
 boolean XPathStringVal_StartsWith(int j, java.lang.String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

atTerminal

protected boolean atTerminal

context

protected int[] context

contextStack

protected com.ximpleware.ContextBuffer contextStack

contextStack2

protected com.ximpleware.ContextBuffer contextStack2

count

protected int count

currentNode

protected BookMark currentNode

docLen

protected int docLen

docOffset

protected int docOffset

encoding

protected int encoding

FC

public static final int FC
See Also:
Constant Field Values

fib

protected FastIntBuffer fib

FIRST_CHILD

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

l1Buffer

protected FastLongBuffer l1Buffer

l1index

protected int l1index

l2Buffer

protected FastLongBuffer l2Buffer

l2index

protected int l2index

l2lower

protected int l2lower

l2upper

protected int l2upper

l3Buffer

protected FastIntBuffer l3Buffer

l3index

protected int l3index

l3lower

protected int l3lower

l3upper

protected int l3upper

LAST_CHILD

public static final int LAST_CHILD
See Also:
Constant Field Values

LC

public static final int LC
See Also:
Constant Field Values

LN

protected int LN

localName

protected java.lang.String localName

localNameIndex

protected int localNameIndex

MASK_TOKEN_DEPTH

protected static final long MASK_TOKEN_DEPTH
See Also:
Constant Field Values

MASK_TOKEN_FULL_LEN

protected static final long MASK_TOKEN_FULL_LEN
See Also:
Constant Field Values

MASK_TOKEN_NS_MARK

protected static final long MASK_TOKEN_NS_MARK
See Also:
Constant Field Values

MASK_TOKEN_OFFSET

protected static long MASK_TOKEN_OFFSET

MASK_TOKEN_PRE_LEN

protected static final long MASK_TOKEN_PRE_LEN
See Also:
Constant Field Values

MASK_TOKEN_QN_LEN

protected static final long MASK_TOKEN_QN_LEN
See Also:
Constant Field Values

MASK_TOKEN_TYPE

protected static final long MASK_TOKEN_TYPE
See Also:
Constant Field Values

maxLCDepthPlusOne

protected short maxLCDepthPlusOne

name

protected java.lang.String name

nameIndex

protected int nameIndex

nestingLevel

protected int nestingLevel

NEXT_SIBLING

public static final int NEXT_SIBLING
See Also:
Constant Field Values

ns

protected boolean ns

NS

public static final int NS
See Also:
Constant Field Values

P

public static final int P
See Also:
Constant Field Values

PARENT

public static final int PARENT
See Also:
Constant Field Values

PREV_SIBLING

public static final int PREV_SIBLING
See Also:
Constant Field Values

PS

public static final int PS
See Also:
Constant Field Values

R

public static final int R
See Also:
Constant Field Values

ROOT

public static final int ROOT
See Also:
Constant Field Values

rootIndex

protected int rootIndex

shallowDepth

protected boolean shallowDepth

stackTemp

protected int[] stackTemp

STRING_NORMALIZED

public static final int STRING_NORMALIZED
See Also:
Constant Field Values

STRING_RAW

public static final int STRING_RAW
See Also:
Constant Field Values

STRING_REGULAR

public static final int STRING_REGULAR
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

URIName

protected java.lang.String URIName

vtdBuffer

protected FastLongBuffer vtdBuffer

vtdSize

protected int vtdSize

XMLDoc

protected com.ximpleware.IByteBuffer XMLDoc

XPATH_STRING_MODE_LOWERCASE

public static final short XPATH_STRING_MODE_LOWERCASE
See Also:
Constant Field Values

XPATH_STRING_MODE_NORMAL

public static final short XPATH_STRING_MODE_NORMAL
See Also:
Constant Field Values

XPATH_STRING_MODE_UPPERCASE

public static final short XPATH_STRING_MODE_UPPERCASE
See Also:
Constant Field Values
Constructor Detail

VTDNav

protected VTDNav()

VTDNav

protected VTDNav(int RootIndex,
                 int enc,
                 boolean NS,
                 int depth,
                 com.ximpleware.IByteBuffer x,
                 FastLongBuffer vtd,
                 FastLongBuffer l1,
                 FastLongBuffer l2,
                 FastIntBuffer l3,
                 int so,
                 int length)
Initialize the VTD navigation object.

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

clearStack2

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


cloneNav

public VTDNav 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:
a new instance of VTDNav

compareNormalizedTokenString2

protected final int compareNormalizedTokenString2(int offset,
                                                  int len,
                                                  java.lang.String s)
                                           throws NavException
Throws:
NavException

compareRawTokenString

protected final int compareRawTokenString(int offset,
                                          int len,
                                          java.lang.String s)
                                   throws NavException
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:
NavException - 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,
                                       java.lang.String s)
                                throws NavException
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:
NavException

compareTokens

public final int compareTokens(int i1,
                               VTDNav vn2,
                               int i2)
                        throws NavException
New in 2.0 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, return 0 if two tokens are the identical when converted to Unicode String using toString() respectively

Parameters:
i1 -
vn2 -
i2 -
Returns:
-1,0 (when equal), or 1
Throws:
NavException

compareTokenString

protected final int compareTokenString(int offset,
                                       int len,
                                       java.lang.String s)
                                throws NavException
Throws:
NavException

compareTokenString

public final int compareTokenString(int index,
                                    java.lang.String s)
                             throws NavException
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:
NavException

contains

public final boolean contains(int index,
                              java.lang.String s)
                       throws NavException
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:
NavException

dumpState

public void dumpState()

dumpXML

public void dumpXML(java.io.OutputStream os)
             throws java.io.IOException
Dump the in memory XML text into output stream

Parameters:
os -
Throws:
java.io.IOException

dumpXML

public void dumpXML(java.lang.String fileName)
             throws java.io.IOException
Dump the in-memory copy of XML text into a file

Parameters:
fileName -
Throws:
java.io.IOException

duplicateNav

public VTDNav duplicateNav()
Duplicate the VTDNav 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 VTDNav instance

endsWith

public final boolean endsWith(int index,
                              java.lang.String s)
                       throws NavException
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:
NavException

fillXPathString

public final void fillXPathString(FastIntBuffer indexBuffer,
                                  FastIntBuffer countBuffer)
                           throws NavException
Throws:
NavException

getAtTerminal

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

Returns:
boolean

getAttrCount

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

Returns:
int

getAttrVal

public int getAttrVal(java.lang.String an)
               throws NavException
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:
NavException - 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(java.lang.String URL,
                        java.lang.String ln)
                 throws NavException
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:
NavException - 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

getContentFragment

public long getContentFragment()
                        throws NavException
Get content fragment returns a long 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, -1 is returned if the current element is an empty element

Returns:
long whose upper 32 bite is length, lower 32 bit is offset
Throws:
NavException

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()

getElementFragment

public long getElementFragment()
                        throws NavException
Get the starting offset and length of an element encoded in a long, upper 32 bits is length; lower 32 bits is offset Unit is in byte. Creation date: (3/15/04 1:47:55 PM)

Throws:
NavException

getElementFragmentNs

public ElementFragmentNs getElementFragmentNs()
                                       throws NavException
getElementFragmentNS returns a ns aware version of the element fragment encapsulated in an ElementFragment object

Returns:
an ElementFragment object
Throws:
NavException

getEncoding

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

Returns:
int

getIndexsize

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

Returns:
size of the index

getNestingLevel

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

Returns:
int

getNormalizedStringLength

public final int getNormalizedStringLength(int index)
                                    throws NavException
Get the string length of a token as if it is converted into a normalized UCS string

Parameters:
index -
Returns:
the string length
Throws:
NavException

getOffsetAfterHead

public final long getOffsetAfterHead()
Return the charater (not byte) offset after head (the ending bracket of the starting tag, not including an empty element, in which case 0xffffffff 00000000 | len is returned)

Returns:

getOffsetBeforeTail

protected final long getOffsetBeforeTail()
                                  throws NavException
Throws:
NavException

getPrefixString

public java.lang.String getPrefixString(int i)
                                 throws NavException
Return the prefix of a token as a string if the token is of the type of starting tag, attribute name, if the the prefix doesn't exist, a null string is returned; otherwise a null string is returned

Parameters:
i - VTD index of a token
Returns:
Throws:
NavException

getRawStringLength

public final int getRawStringLength(int index)
                             throws NavException
Get the string length as if the token is converted into a UCS string (entity not resolved)

Parameters:
index -
Returns:
Throws:
NavException

getRootIndex

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

Returns:
int

getSiblingElementFragments

public long getSiblingElementFragments(int i)
                                throws NavException
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 encoding byte offset (bit 31 to bit 0), length (bit 62 to bit 32) of those fragments
Throws:
NavException

getStringLength

public final int getStringLength(int index)
                          throws NavException
getStringLength return the string length of a token as if the token is converted into a string (entity resolved for character data and attr val)

Parameters:
index -
Returns:
the string length as if the token is converted to a UCS string (entity resolved)
Throws:
NavException

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

getTokenLength2

protected final int getTokenLength2(int index)

getTokenOffset

public final int getTokenOffset(int index)
Get the starting offset (unit in native char) of the token at the given index.

Parameters:
index - int
Returns:
int

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

getXML

public final com.ximpleware.IByteBuffer getXML()
Get the XML document

Returns:
IByteBuffer

getXPathStringVal

public final java.lang.String getXPathStringVal()
                                         throws NavException
Throws:
NavException

getXPathStringVal

public final java.lang.String getXPathStringVal(short mode)
                                         throws NavException
Return the String value of an Element Node

Parameters:
mode -
Returns:
Throws:
NavException

getXPathStringVal2

protected final java.lang.String getXPathStringVal2(int j,
                                                    short mode)
                                             throws NavException
Throws:
NavException

hasAttr

public final boolean hasAttr(java.lang.String an)
                      throws NavException
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:
NavException - 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(java.lang.String URL,
                               java.lang.String ln)
                        throws NavException
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:
NavException - 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

isElement

protected final boolean isElement(int index)
Test the token type, to see if it is a starting tag.

Parameters:
index - int
Returns:
boolean

isElementOrDocument

protected final boolean isElementOrDocument(int index)
Test the token type, to see if it is a starting tag or document token (introduced in 1.0).

Parameters:
index - int
Returns:
boolean

iterate_following_node

protected boolean iterate_following_node()
                                  throws NavException
Throws:
NavException

iterate_following

protected boolean iterate_following(java.lang.String en,
                                    boolean special)
                             throws NavException
This function is called by selectElement_F in autoPilot

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

iterate_followingNS

protected boolean iterate_followingNS(java.lang.String URL,
                                      java.lang.String ln)
                               throws NavException
This function is called by selectElementNS_F in autoPilot

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

iterate_preceding_node

protected boolean iterate_preceding_node(int[] a,
                                         int endIndex)
                                  throws NavException
Throws:
NavException

iterate_preceding

protected boolean iterate_preceding(java.lang.String en,
                                    int[] a,
                                    int endIndex)
                             throws NavException
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:
NavException

iterate_precedingNS

protected boolean iterate_precedingNS(java.lang.String URL,
                                      java.lang.String ln,
                                      int[] a,
                                      int endIndex)
                               throws NavException
This function is called by selectElementNS_P in autoPilot

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

iterate

protected boolean iterate(int dp,
                          java.lang.String en,
                          boolean special)
                   throws NavException
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:
NavException - 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;

iterateNode

protected boolean iterateNode(int dp)
                       throws NavException
Throws:
NavException

iterateNS

protected boolean iterateNS(int dp,
                            java.lang.String URL,
                            java.lang.String ln)
                     throws NavException
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:
NavException - 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 }

loadCurrentNode

protected void loadCurrentNode()

lookupNS

protected final int lookupNS()
                      throws NavException
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:
NavException - When there is any encoding conversion error or unknown entity.

lookupNS

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

Parameters:
URL -
Returns:
int

matchElement

public final boolean matchElement(java.lang.String en)
                           throws NavException
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:
NavException - If the underlying raw char representation has errors.

matchElementNS

public final boolean matchElementNS(java.lang.String URL,
                                    java.lang.String ln)
                             throws NavException
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:
NavException - When there is any encoding conversion error or unknown entity.

matchNormalizedTokenString2

protected final boolean matchNormalizedTokenString2(int index,
                                                    java.lang.String s)
                                             throws NavException
Match the string against the token at the given index value. The token will be interpreted as if it is normalized (i.e. all white space char (\r\n\a ) is replaced by a white space, char entities and entity references will be replaced by their correspondin char see xml 1.0 spec interpretation of attribute value normalization)

Parameters:
index -
s -
Returns:
Throws:
NavException

matchRawTokenString

public final boolean matchRawTokenString(int index,
                                         java.lang.String s)
                                  throws NavException
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:
NavException - 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.

matchTokens

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

Parameters:
i1 - index of the first token
vn2 - the second VTDNav instance
i2 - index of the second token
Returns:
boolean true if two tokens are lexically identical
Throws:
NavException

matchTokenString

public final boolean matchTokenString(int index,
                                      java.lang.String s)
                               throws NavException
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:
NavException - 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.

nodeToElement

protected boolean nodeToElement(int direction)
the corner case of element to node jump

Parameters:
direction -
Returns:

overWrite

public final boolean overWrite(int index,
                               byte[] ba)
overWrite is introduced in version 2.0 that allows you to directly overwrite the XML content if the token is long enough If the operation is successful, the new content along with whitespaces will fill the available token space, and there will be no need to regenerate the VTD and LCs !!! The current version (2.0) only allows overwrites on attribute value, character data, and CDATA Consider the XML below: good After overwriting the token "good" with "bad," the new XML looks like: bad as you can see, "goo" is replaced with "bad" character-by-character, and the remaining "d" is replace with a white space

Parameters:
index -
ba - the byte array contains the new content to be overwritten
Returns:
boolean as the status of the overwrite operation

overWrite

public boolean overWrite(int index,
                         byte[] ba,
                         int offset,
                         int len)
overWrite is introduced in version 2.0 that allows you to directly overwrite the XML content if the token is long enough If the operation is successful, white spaces will be used to fill the available token space, and there will be no need to regenerate the VTD and LCs The current version (2.0) only allows overwrites on attribute value, character data, and CDATA Consider the XML below: good After overwriting the token "good" with "bad," the new XML looks like: bad as you can see, "goo" is replaced with "bad", and the remaining "d" is replace with a white space

Parameters:
index - the VTD record to which the change will be applied
ba - the byte array contains the new content to be overwritten
offset -
len -
Returns:
boolean as the status of the overwrite operation

parseDouble

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

Returns:
double
Throws:
NavException - 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 NavException
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:
NavException - 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 NavException
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:
NavException - 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 NavException
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:
NavException - 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 NavException
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:
NavException - 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 NavException
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:
NavException - 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 boolean pop()
Load the context info from ContextBuffer. Info saved including LC and current state of the context

Returns:
boolean

pop2

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

Returns:
status of pop2

push

public 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 void push2()
Store the context info into the contextStack2. This method is reserved for XPath Evaluation


recoverNode_l1

protected final void recoverNode_l1(int index)

recoverNode_l2

protected final void recoverNode_l2(int index)

recoverNode

public void recoverNode(int index)
                 throws NavException
This method takes a vtd index, and recover its correspondin node position, the index can only be of node type element, document, attribute name, attribute value or character data, or CDATA

Parameters:
index -
Throws:
NavException

resolveLC_l1

protected void resolveLC_l1()
Sync level 1 location cache


resolveLC_l2

protected void resolveLC_l2()
Sync Level 2 location cache


resolveLC_l3

protected void resolveLC_l3()
Sync L3 location Cache


resolveLC

protected void resolveLC()
Sync up the current context with location cache. This operation includes finding out l1index, l2index, l3index and restores upper and lower bound info To improve efficieny this method employs some heuristic search algorithm. The result is that it is quite close to direct access. Creation date: (11/16/03 7:44:53 PM)


sampleState

public void sampleState(FastIntBuffer fib)

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 -

setCurrentNode

protected void setCurrentNode()

startsWith

public final boolean startsWith(int index,
                                java.lang.String s)
                         throws NavException
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:
i -
s -
Returns:
Throws:
NavException

sync

protected void sync(int depth,
                    int index)
Used by following:: axis

Parameters:
depth -
index -

toElement

public boolean toElement(int direction)
                  throws NavException
A generic navigation method. Move the cursor 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:
NavException - When direction value is illegal.

toElement

public boolean toElement(int direction,
                         java.lang.String en)
                  throws NavException
A generic navigation method. Move the cursor 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:
NavException - 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,
                           java.lang.String URL,
                           java.lang.String ln)
                    throws NavException
A generic navigation method with namespace support. Move the cursor 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:
NavException - When direction value is illegal. Or there are errors in underlying byte representation of the document

toNode_LastChild

protected boolean toNode_LastChild()

toNode_PrevSibling

protected boolean toNode_PrevSibling()

toNode

protected boolean toNode(int dir)
                  throws NavException
Throws:
NavException

toNormalizedString

public java.lang.String toNormalizedString(int index)
                                    throws NavException
This method normalizes a token into a string value of character data and attr val 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:
NavException - When the encoding has errors

toNormalizedString2

public java.lang.String toNormalizedString2(int index)
                                     throws NavException
(New since version 2.9) Shallow Normalization follows the rules below to normalize a token into a string *#xD#xA gets converted to #xA *For a character reference, append the referenced character to the normalized value. *For an entity reference, recursively apply step 3 of this algorithm to the replacement text of the entity. *For a white space character (#x20, #xD, #xA, #x9), append a space character (#x20) to the normalized value. *For another character, append the character to the normalized value.

Parameters:
index -
Returns:
Throws:
NavException

toNormalizedXPathString

public final java.lang.String toNormalizedXPathString(int j)
                                               throws NavException
Throws:
NavException

toRawString

public final java.lang.String toRawString(int index)
                                   throws NavException
Convert a token at the given index to a String, (entities and char references not expanded). Creation date: (11/16/03 7:28:49 PM)

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

toRawString

public final java.lang.String toRawString(int os,
                                          int len)
                                   throws NavException
Convert a segment of XML bytes a into string, without entity resolution

Parameters:
os - (in terms of chars not bytes)
len - (in terms of chars not bytes)
Returns:
Throws:
NavException

toRawString

protected final void toRawString(int os,
                                 int len,
                                 java.lang.StringBuffer sb)
                          throws NavException
Throws:
NavException

toRawString

protected final void toRawString(int os,
                                 int len,
                                 java.lang.StringBuilder sb)
                          throws NavException
Throws:
NavException

toRawString

protected final void toRawString(java.lang.StringBuilder sb,
                                 int index)
                          throws NavException
Throws:
NavException

toRawStringLowerCase

public final java.lang.String toRawStringLowerCase(int index)
                                            throws NavException
Convert a token at the given index to a String, upper case chars get converted into lower case (entities and char references not expanded).

Parameters:
index -
Returns:
Throws:
NavException

toRawStringLowerCase

protected final java.lang.String toRawStringLowerCase(int os,
                                                      int len)
                                               throws NavException
Throws:
NavException

toRawStringLowerCase

protected final void toRawStringLowerCase(int os,
                                          int len,
                                          java.lang.StringBuilder sb)
                                   throws NavException
Throws:
NavException

toRawStringUpperCase

public final java.lang.String toRawStringUpperCase(int index)
                                            throws NavException
Convert a token at the given index to a String, lower case chars get converted into upper case (entities and char references not expanded).

Parameters:
index -
Returns:
Throws:
NavException

toRawStringUpperCase

protected final java.lang.String toRawStringUpperCase(int os,
                                                      int len)
                                               throws NavException
Throws:
NavException

toRawStringUpperCase

protected final void toRawStringUpperCase(int os,
                                          int len,
                                          java.lang.StringBuilder sb)
                                   throws NavException
Throws:
NavException

toString

public java.lang.String toString(int index)
                          throws NavException
Convert a token at the given index to a String, (entities and char references resolved character data and attr val). 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:
NavException

toString

public final java.lang.String toString(int os,
                                       int len)
                                throws NavException
Convert the byte content segment (in terms of offset and length) to String (entities are resolved)

Parameters:
os - the char offset of the segment (not byte)
len - the length of the segment in char (not byte)
Returns:
the corresponding string value
Throws:
NavException

toString

protected final void toString(int os,
                              int len,
                              java.lang.StringBuilder sb)
                       throws NavException
Throws:
NavException

toString

protected final void toString(java.lang.StringBuilder sb,
                              int index)
                       throws NavException
Throws:
NavException

toStringLowerCase

public java.lang.String toStringLowerCase(int index)
                                   throws NavException
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 for character data and attr val).

Parameters:
index -
Returns:
Throws:
NavException

toStringLowerCase

protected final java.lang.String toStringLowerCase(int os,
                                                   int len)
                                            throws NavException
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:
NavException

toStringLowerCase

protected final void toStringLowerCase(int os,
                                       int len,
                                       java.lang.StringBuilder sb)
                                throws NavException
Throws:
NavException

toStringLowerCase

protected final void toStringLowerCase(java.lang.StringBuilder sb,
                                       int index)
                                throws NavException
Throws:
NavException

toStringUpperCase

public java.lang.String toStringUpperCase(int index)
                                   throws NavException
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 character data and attr val).

Parameters:
index -
Returns:
Throws:
NavException

toStringUpperCase

protected final java.lang.String toStringUpperCase(int os,
                                                   int len)
                                            throws NavException
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:
NavException

toStringUpperCase

protected final void toStringUpperCase(int os,
                                       int len,
                                       java.lang.StringBuilder sb)
                                throws NavException
Throws:
NavException

toStringUpperCase

protected final void toStringUpperCase(java.lang.StringBuilder sb,
                                       int index)
                                throws NavException
Throws:
NavException

verifyNodeCorrectness

public boolean verifyNodeCorrectness()
This is for debugging purpose

Parameters:
fib -

writeIndex

public void writeIndex(java.io.OutputStream os)
                throws IndexWriteException,
                       java.io.IOException
Write VTDNav's internal structure into an OutputStream

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

writeIndex

public void writeIndex(java.lang.String fileName)
                throws java.io.IOException,
                       IndexWriteException
Write VTDNav's internal structure into a VTD+XML file

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

writeSeparateIndex

public void writeSeparateIndex(java.io.OutputStream os)
                        throws IndexWriteException,
                               java.io.IOException
Write VTDNav's VTD and LCs into an OutputStream (XML not written out)

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

writeSeparateIndex

public void writeSeparateIndex(java.lang.String fileName)
                        throws java.io.IOException,
                               IndexWriteException
Write VTDNav's internal structure (VTD and LCs, but not XML) into a file

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

XPathStringVal_Contains

public final boolean XPathStringVal_Contains(int j,
                                             java.lang.String s)
                                      throws NavException
Throws:
NavException

XPathStringVal_EndsWith

public final boolean XPathStringVal_EndsWith(int j,
                                             java.lang.String s)
                                      throws NavException
Throws:
NavException

XPathStringVal_StartsWith

public final boolean XPathStringVal_StartsWith(int j,
                                               java.lang.String s)
                                        throws NavException
Throws:
NavException