org.apache.xpath.compiler
Class Compiler
An instance of this class compiles an XPath string expression into
a Expression object. This class compiles the string into a sequence
of operation codes (op map) and then builds from that into an Expression
tree.
Compiler() - Construct a Compiler instance that has a null error listener and a
null source locator.
|
Compiler(ErrorListener errorHandler, SourceLocator locator) - Construct a Compiler object with a specific ErrorListener and
SourceLocator where the expression is located.
|
error , getArgLength , getArgLengthOfStep , getFirstChildPos , getFirstChildPosOfStep , getFirstPredicateOpPos , getNextOpPos , getNextOpPos , getNextStepPos , getOp , getOpMap , getPatternString , getStepLocalName , getStepNS , getStepTestType , getToken , getTokenQueue , getTokenQueueSize , setOp , toString |
Compiler
public Compiler()
Construct a Compiler instance that has a null error listener and a
null source locator.
Compiler
public Compiler(ErrorListener errorHandler,
SourceLocator locator)
Construct a Compiler object with a specific ErrorListener and
SourceLocator where the expression is located.
errorHandler
- Error listener where messages will be sent, or null
if messages should be sent to System err.locator
- The location object where the expression lives, which
may be null, but which, if not null, must be valid over
the long haul, in other words, it will not be cloned.
assertion
public void assertion(boolean b,
String msg)
Tell the user of an assertion error, and probably throw an
exception.
b
- If false, a runtime exception will be thrown.msg
- The assertion message, which should be informative.
compile
public Expression compile(int opPos)
throws TransformerException
Execute the XPath object from a given opcode position.
opPos
- The current position in the xpath.m_opMap array.
countPredicates
public int countPredicates(int opPos)
throws TransformerException
Count the number of predicates in the step.
opPos
- The position of the first predicate the m_opMap array.
- The number of predicates for this step.
error
public void error(String msg,
Object[] args)
throws TransformerException
Tell the user of an error, and probably throw an
exception.
- error in interface OpMap
msg
- An error msgkey that corresponds to one of the constants found
in XPATHErrorResources
, which is
a key for a format string.args
- An array of arguments represented in the format string, which
may be null.
getCompiledPredicates
public Expression[] getCompiledPredicates(int opPos)
throws TransformerException
Compile a zero or more predicates for a given match pattern.
opPos
- The position of the first predicate the m_opMap array.
getLocationPathDepth
public int getLocationPathDepth()
Get the level of the location path or union being constructed.
- 0 if it is a top-level path.
getNamespaceContext
public PrefixResolver getNamespaceContext()
Get the current namespace context for the xpath.
- The current prefix resolver, *may* be null, though hopefully not.
getWhatToShow
public int getWhatToShow(int opPos)
Get a org.w3c.dom.traversal.NodeFilter
bit set that tells what
to show for a given node test.
opPos
- the op map position for the location step.
org.w3c.dom.traversal.NodeFilter
bit set that tells what
to show for a given node test.
locationPath
public Expression locationPath(int opPos)
throws TransformerException
Compile a location path. The LocPathIterator itself may create
AxesWalker
children.
opPos
- The current position in the m_opMap array.
locationPathPattern
public Expression locationPathPattern(int opPos)
throws TransformerException
Compile a location match pattern unit expression.
opPos
- The current position in the m_opMap array.
predicate
public Expression predicate(int opPos)
throws TransformerException
Compile a location step predicate expression.
opPos
- The current position in the m_opMap array.
- the contained predicate expression.
setNamespaceContext
public void setNamespaceContext(PrefixResolver pr)
Set the current namespace context for the xpath.
pr
- The resolver for prefixes in the XPath expression.
warn
public void warn(String msg,
Object[] args)
throws TransformerException
Warn the user of an problem.
msg
- An error msgkey that corresponds to one of the constants found
in XPATHErrorResources
, which is
a key for a format string.args
- An array of arguments represented in the format string, which
may be null.
Copyright B) 2004 Apache XML Project. All Rights Reserved.