com.ximpleware
Class AutoPilot

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

public class AutoPilot
extends Object

XimpleWare's AutoPilot implementation encapsulating node iterator and XPath.


Field Summary
static int ATTR
           
static int ATTR_NS
           
protected  int[] contextCopy
           
protected  int depth
           
static int DESCENDANT
           
static int DESCENDANT_NODE
           
static int DESCENDANT_NS
           
protected  boolean enableCaching
           
protected  int endIndex
           
static int FOLLOWING
           
static int FOLLOWING_NODE
           
static int FOLLOWING_NS
           
protected  boolean ft
           
protected  int index
           
protected  int iter_type
           
protected  String localName
           
protected  String name
           
static int NAME_SPACE
           
protected  String name2
           
protected  Hashtable nsHash
           
static int PRECEDING
           
static int PRECEDING_NODE
           
static int PRECEDING_NS
           
static int SIMPLE
           
static int SIMPLE_NODE
           
static int SIMPLE_NS
           
protected  int size
           
protected  boolean special
           
protected  int stackSize
           
static int UNDEFINED
           
protected  String URL
           
protected  VTDNav vn
           
protected  Expr xpe
           
 
Constructor Summary
AutoPilot()
          Use this constructor for delayed binding to VTDNav which allows the reuse of XPath expression
AutoPilot(VTDNav v)
          AutoPilot constructor comment.
 
Method Summary
 void bind(VTDNav vnv)
          Bind is to replace rebind() and setVTDNav() It resets the internal state of AutoPilot so one can attach a VTDNav object to the autopilot
protected  boolean checkNsUniqueness(int i)
           
 void clearVariableExprs()
          Remove all declared variable expressions
 void clearXPathNameSpaces()
          Remove all namespaces bindings
 void declareVariableExpr(String varName, String varExpr)
          Register the binding between a variableExpr name and variableExpr expression
 void declareXPathNameSpace(String prefix, String URL)
          This function creates URL ns prefix and is intended to be called prior to selectXPath
 void enableCaching(boolean state)
          set state to false to disable caching, which by default is enabled
 int evalXPath()
          This method returns the next node in the nodeset it returns -1 if there is no more node Afer finishing evaluating, don't forget to reset the xpath
 boolean evalXPathToBoolean()
          evalXPathToBoolean() evaluates the xpath expression to a boolean
 double evalXPathToNumber()
          evalXPathToNumber() evaluates the xpath expression to a double
 String evalXPathToString()
          evalXPathToString() evaluates the xpath expression to a String
 String getExprString()
          Convert the expression to a string For debugging purpose
protected  String getName()
           
 boolean iterate()
          Iterate over all the selected element nodes in document order.
 boolean iterate2()
           
 int iterateAttr()
          This method is meant to be called after calling selectAttr() or selectAttrNs(), it will return the vtd index attribute name or -1 if there is none left
protected  int iterateAttr2()
          This method implements the attribute axis for XPath
protected  int iterateNameSpace()
          This method implements the namespace axis for XPath
 void resetXPath()
          Reset the XPath so the XPath Expression can be reused and revaluated in anther context position
 void selectAttr(String en)
          Select an attribute name for iteration, * choose all attributes of an element
 void selectAttrNS(String ns_URL, String ln)
          Select an attribute name, both local part and namespace URL part
protected  void selectDescendantNode()
           
protected  void selectElement_D(String en)
          Select all descendent elements along the descendent axis, without ns awareness
protected  void selectElement_F(String en)
          Select all elements along the following axis, without ns, null selects every elements and documents
protected  void selectElement_P(String en)
          Select all elements along the preceding axis as defined in XPath
 void selectElement(String en)
          Select the element name before iterating. "*" matches every element Creation date: (12/4/03 5:51:31 PM)
protected  void selectElementNS_D(String ns_URL, String ln)
          Select all descendent elements along the Descendent axis, withns awareness
protected  void selectElementNS_F(String ns_URL, String ln)
          Select all elements along the following axis as defined in XPath The namespace-aware version
protected  void selectElementNS_P(String ns_URL, String ln)
          Select all elements along the preceding axis as defined in XPath This is the namespace aware version
 void selectElementNS(String ns_URL, String ln)
          Select the element name (name space version) before iterating.
protected  void selectFollowingNode()
           
protected  void selectNameSpace(String en)
          Select the name space nodes as defined in XPath
protected  void selectNode()
           
protected  void selectPrecedingNode()
           
 void selectXPath(String s)
          This method selects the string representing XPath expression Usually evalXPath is called afterwards
protected  void setSpecial(boolean b)
          Setspecial is used by XPath evaluator to distinguish between node() and * node() corresponding to b= true;
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

depth

protected int depth

iter_type

protected int iter_type

vn

protected VTDNav vn

index

protected int index

endIndex

protected int endIndex

ft

protected boolean ft

special

protected boolean special

name

protected String name

name2

protected String name2

localName

protected String localName

URL

protected String URL

size

protected int size

xpe

protected Expr xpe

contextCopy

protected int[] contextCopy

stackSize

protected int stackSize

nsHash

protected Hashtable nsHash

enableCaching

protected boolean enableCaching

UNDEFINED

public static final int UNDEFINED
See Also:
Constant Field Values

SIMPLE

public static final int SIMPLE
See Also:
Constant Field Values

SIMPLE_NS

public static final int SIMPLE_NS
See Also:
Constant Field Values

DESCENDANT

public static final int DESCENDANT
See Also:
Constant Field Values

DESCENDANT_NS

public static final int DESCENDANT_NS
See Also:
Constant Field Values

FOLLOWING

public static final int FOLLOWING
See Also:
Constant Field Values

FOLLOWING_NS

public static final int FOLLOWING_NS
See Also:
Constant Field Values

PRECEDING

public static final int PRECEDING
See Also:
Constant Field Values

PRECEDING_NS

public static final int PRECEDING_NS
See Also:
Constant Field Values

ATTR

public static final int ATTR
See Also:
Constant Field Values

ATTR_NS

public static final int ATTR_NS
See Also:
Constant Field Values

NAME_SPACE

public static final int NAME_SPACE
See Also:
Constant Field Values

SIMPLE_NODE

public static final int SIMPLE_NODE
See Also:
Constant Field Values

DESCENDANT_NODE

public static final int DESCENDANT_NODE
See Also:
Constant Field Values

FOLLOWING_NODE

public static final int FOLLOWING_NODE
See Also:
Constant Field Values

PRECEDING_NODE

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

AutoPilot

public AutoPilot(VTDNav v)
AutoPilot constructor comment.

Throws:
IllegalArgumentException - If the VTDNav object is null

AutoPilot

public AutoPilot()
Use this constructor for delayed binding to VTDNav which allows the reuse of XPath expression

Method Detail

getName

protected String getName()

declareXPathNameSpace

public final void declareXPathNameSpace(String prefix,
                                        String URL)
This function creates URL ns prefix and is intended to be called prior to selectXPath

Parameters:
prefix -
URL -

bind

public void bind(VTDNav vnv)
Bind is to replace rebind() and setVTDNav() It resets the internal state of AutoPilot so one can attach a VTDNav object to the autopilot

Parameters:
vnv -

declareVariableExpr

public void declareVariableExpr(String varName,
                                String varExpr)
                         throws XPathParseException
Register the binding between a variableExpr name and variableExpr expression

Parameters:
varName -
varExpr -
Throws:
XPathParseException

clearVariableExprs

public final void clearVariableExprs()
Remove all declared variable expressions


clearXPathNameSpaces

public final void clearXPathNameSpaces()
Remove all namespaces bindings


iterate2

public boolean iterate2()
                 throws PilotException,
                        NavException
Throws:
PilotException
NavException

iterate

public boolean iterate()
                throws PilotException,
                       NavException
Iterate over all the selected element nodes in document order. Null element name allowed, corresponding to node() in xpath Creation date: (12/4/03 5:25:42 PM)

Returns:
boolean
Throws:
NavException - See description in method toElement() in VTDNav class.
PilotException

iterateNameSpace

protected int iterateNameSpace()
                        throws PilotException,
                               NavException
This method implements the namespace axis for XPath

Returns:
Throws:
PilotException
NavException

checkNsUniqueness

protected boolean checkNsUniqueness(int i)
                             throws NavException
Throws:
NavException

iterateAttr2

protected int iterateAttr2()
                    throws PilotException,
                           NavException
This method implements the attribute axis for XPath

Returns:
the integer of the selected VTD index for attribute name
Throws:
PilotException
NavException

iterateAttr

public int iterateAttr()
                throws PilotException,
                       NavException
This method is meant to be called after calling selectAttr() or selectAttrNs(), it will return the vtd index attribute name or -1 if there is none left

Returns:
vtd index attribute name or -1 if there is none left
Throws:
PilotException
NavException

selectNode

protected final void selectNode()

selectPrecedingNode

protected final void selectPrecedingNode()

selectFollowingNode

protected final void selectFollowingNode()

selectDescendantNode

protected final void selectDescendantNode()

selectElement

public void selectElement(String en)
Select the element name before iterating. "*" matches every element Creation date: (12/4/03 5:51:31 PM)

Parameters:
en - java.lang.String

selectElementNS

public void selectElementNS(String ns_URL,
                            String ln)
Select the element name (name space version) before iterating. URL, if set to *, matches every namespace URL, if set to null, indicates the namespace is undefined. localname, if set to *, matches any localname Creation date: (12/4/03 6:05:19 PM)

Parameters:
ns_URL - String
ln - String

selectElement_D

protected void selectElement_D(String en)
Select all descendent elements along the descendent axis, without ns awareness

Parameters:
en -

selectElementNS_D

protected void selectElementNS_D(String ns_URL,
                                 String ln)
Select all descendent elements along the Descendent axis, withns awareness

Parameters:
ns_URL -
ln -

selectElement_F

protected void selectElement_F(String en)
Select all elements along the following axis, without ns, null selects every elements and documents

Parameters:
en -

selectElementNS_F

protected void selectElementNS_F(String ns_URL,
                                 String ln)
Select all elements along the following axis as defined in XPath The namespace-aware version

Parameters:
en -

selectElement_P

protected void selectElement_P(String en)
Select all elements along the preceding axis as defined in XPath

Parameters:
en -

selectElementNS_P

protected void selectElementNS_P(String ns_URL,
                                 String ln)
Select all elements along the preceding axis as defined in XPath This is the namespace aware version

Parameters:
ns_URL -
ln -

selectNameSpace

protected void selectNameSpace(String en)
Select the name space nodes as defined in XPath

Parameters:
en -

selectAttr

public void selectAttr(String en)
Select an attribute name for iteration, * choose all attributes of an element

Parameters:
en -

selectAttrNS

public final void selectAttrNS(String ns_URL,
                               String ln)
Select an attribute name, both local part and namespace URL part

Parameters:
ns_URL -
ln -

selectXPath

public void selectXPath(String s)
                 throws XPathParseException
This method selects the string representing XPath expression Usually evalXPath is called afterwards

Parameters:
s -
Throws:
XPathParseException

resetXPath

public final void resetXPath()
Reset the XPath so the XPath Expression can be reused and revaluated in anther context position


evalXPathToNumber

public final double evalXPathToNumber()
evalXPathToNumber() evaluates the xpath expression to a double

Returns:
double

evalXPathToString

public final String evalXPathToString()
evalXPathToString() evaluates the xpath expression to a String

Returns:
String

evalXPathToBoolean

public final boolean evalXPathToBoolean()
evalXPathToBoolean() evaluates the xpath expression to a boolean

Returns:
boolean

evalXPath

public int evalXPath()
              throws XPathEvalException,
                     NavException
This method returns the next node in the nodeset it returns -1 if there is no more node Afer finishing evaluating, don't forget to reset the xpath

Returns:
int corresponding to the VTD index
Throws:
XPathEvalException
NavException

setSpecial

protected final void setSpecial(boolean b)
Setspecial is used by XPath evaluator to distinguish between node() and * node() corresponding to b= true;

Parameters:
b -

getExprString

public final String getExprString()
Convert the expression to a string For debugging purpose

Returns:
String

enableCaching

public final void enableCaching(boolean state)
set state to false to disable caching, which by default is enabled

Parameters:
state -


Copyright © 2013. All Rights Reserved.