|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.xpath.compiler.OpMap org.apache.xpath.compiler.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.
Field Summary | |
private static boolean |
DEBUG
|
private int |
locPathDepth
|
private PrefixResolver |
m_currentPrefixResolver
The current prefixResolver for the execution context. |
(package private) javax.xml.transform.ErrorListener |
m_errorHandler
The error listener where errors will be sent. |
(package private) javax.xml.transform.SourceLocator |
m_locator
The source locator for the expression being compiled. |
Fields inherited from class org.apache.xpath.compiler.OpMap |
BLOCKTOKENQUEUESIZE, m_currentPattern, m_opMap, m_tokenQueue, MAPINDEX_LENGTH, MAXTOKENQUEUESIZE |
Constructor Summary | |
Compiler()
Construct a Compiler instance that has a null error listener and a null source locator. |
|
Compiler(javax.xml.transform.ErrorListener errorHandler,
javax.xml.transform.SourceLocator locator)
Construct a Compiler object with a specific ErrorListener and SourceLocator where the expression is located. |
Method Summary | |
protected Expression |
and(int opPos)
Compile an 'and' operation. |
protected Expression |
arg(int opPos)
Compile a function argument. |
void |
assertion(boolean b,
String msg)
Tell the user of an assertion error, and probably throw an exception. |
protected Expression |
bool(int opPos)
Compile a 'boolean(...)' operation. |
Expression |
compile(int opPos)
Execute the XPath object from a given opcode position. |
private Expression |
compileExtension(int opPos)
Compile an extension function. |
(package private) Expression |
compileFunction(int opPos)
Compile a built-in XPath function. |
private Expression |
compileOperation(Operation operation,
int opPos)
Bottle-neck compilation of an operation with left and right operands. |
private void |
compilePredicates(int opPos,
Expression[] predicates)
Compiles predicates in the step. |
private Expression |
compileUnary(UnaryOperation unary,
int opPos)
Bottle-neck compilation of a unary operation. |
int |
countPredicates(int opPos)
Count the number of predicates in the step. |
protected Expression |
div(int opPos)
Compile a 'div' operation. |
protected Expression |
equals(int opPos)
Compile a '=' operation. |
void |
error(String msg,
Object[] args)
Tell the user of an error, and probably throw an exception. |
Expression[] |
getCompiledPredicates(int opPos)
Compile a zero or more predicates for a given match pattern. |
int |
getLocationPathDepth()
Get the level of the location path or union being constructed. |
PrefixResolver |
getNamespaceContext()
Get the current namespace context for the xpath. |
int |
getWhatToShow(int opPos)
Get a NodeFilter bit set that tells what
to show for a given node test. |
protected Expression |
group(int opPos)
Compile an expression group. |
protected Expression |
gt(int opPos)
Compile a '>' operation. |
protected Expression |
gte(int opPos)
Compile a '>=' operation. |
protected Expression |
literal(int opPos)
Compile a literal string value. |
Expression |
locationPath(int opPos)
Compile a location path. |
Expression |
locationPathPattern(int opPos)
Compile a location match pattern unit expression. |
protected Expression |
lt(int opPos)
Compile a '<' operation. |
protected Expression |
lte(int opPos)
Compile a '<=' operation. |
protected Expression |
matchPattern(int opPos)
Compile an entire match pattern expression. |
protected Expression |
minus(int opPos)
Compile a '-' operation. |
protected Expression |
mod(int opPos)
Compile a 'mod' operation. |
protected Expression |
mult(int opPos)
Compile a '*' operation. |
protected Expression |
neg(int opPos)
Compile a unary '-' operation. |
protected Expression |
notequals(int opPos)
Compile a '! |
protected Expression |
number(int opPos)
Compile a 'number(...)' operation. |
protected Expression |
numberlit(int opPos)
Compile a literal number value. |
protected Expression |
or(int opPos)
Compile an 'or' operation. |
protected Expression |
plus(int opPos)
Compile a '+' operation. |
Expression |
predicate(int opPos)
Compile a location step predicate expression. |
void |
setNamespaceContext(PrefixResolver pr)
Set the current namespace context for the xpath. |
protected StepPattern |
stepPattern(int opPos,
int stepCount,
StepPattern ancestorPattern)
Compile a step pattern unit expression, used for both location paths and match patterns. |
protected Expression |
string(int opPos)
Compile a 'string(...)' operation. |
protected Expression |
union(int opPos)
Compile a location path union. |
protected Expression |
variable(int opPos)
Compile a variable reference. |
void |
warn(String msg,
Object[] args)
Warn the user of an problem. |
Methods inherited from class org.apache.xpath.compiler.OpMap |
getArgLength, getArgLengthOfStep, getFirstChildPos, getFirstChildPosOfStep, getFirstPredicateOpPos, getNextOpPos, getNextOpPos, getNextStepPos, getOp, getOpMap, getPatternString, getStepLocalName, getStepNS, getStepTestType, getToken, getTokenQueue, getTokenQueueSize, setOp, shrink, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private int locPathDepth
private static final boolean DEBUG
private PrefixResolver m_currentPrefixResolver
javax.xml.transform.ErrorListener m_errorHandler
javax.xml.transform.SourceLocator m_locator
Constructor Detail |
public Compiler(javax.xml.transform.ErrorListener errorHandler, javax.xml.transform.SourceLocator locator)
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.public Compiler()
Method Detail |
public Expression compile(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the xpath.m_opMap array.
javax.xml.transform.TransformerException
- if there is a syntax or other error.private Expression compileOperation(Operation operation, int opPos) throws javax.xml.transform.TransformerException
operation
- non-null reference to parent operation.opPos
- The op map position of the parent operation.
Operation
instance.
javax.xml.transform.TransformerException
- if there is a syntax or other error.private Expression compileUnary(UnaryOperation unary, int opPos) throws javax.xml.transform.TransformerException
unary
- The parent unary operation.opPos
- The position in the op map of the parent operation.
javax.xml.transform.TransformerException
- if syntax or other error occurs.protected Expression or(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
Or
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.protected Expression and(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
And
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.protected Expression notequals(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
NotEquals
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.protected Expression equals(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
Equals
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.protected Expression lte(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
Lte
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.protected Expression lt(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
Lt
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.protected Expression gte(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
Gte
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.protected Expression gt(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
Gt
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.protected Expression plus(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
Plus
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.protected Expression minus(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
Minus
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.protected Expression mult(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
Mult
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.protected Expression div(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
Div
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.protected Expression mod(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
Mod
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.protected Expression neg(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
Neg
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.protected Expression string(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
String
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.protected Expression bool(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
Bool
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.protected Expression number(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
Number
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.protected Expression literal(int opPos)
opPos
- The current position in the m_opMap array.
XString
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.protected Expression numberlit(int opPos)
opPos
- The current position in the m_opMap array.
XNumber
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.protected Expression variable(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
Variable
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.protected Expression group(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.protected Expression arg(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.protected Expression union(int opPos) throws javax.xml.transform.TransformerException
LocPathIterator
children.
opPos
- The current position in the m_opMap array.
LocPathIterator
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.public int getLocationPathDepth()
public Expression locationPath(int opPos) throws javax.xml.transform.TransformerException
AxesWalker
children.
opPos
- The current position in the m_opMap array.
LocPathIterator
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.public Expression predicate(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.protected Expression matchPattern(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
UnionPattern
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.public Expression locationPathPattern(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
StepPattern
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.public int getWhatToShow(int opPos)
NodeFilter
bit set that tells what
to show for a given node test.
opPos
- the op map position for the location step.
NodeFilter
bit set that tells what
to show for a given node test.protected StepPattern stepPattern(int opPos, int stepCount, StepPattern ancestorPattern) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.stepCount
- The number of steps to expect.ancestorPattern
- The owning StepPattern, which may be null.
StepPattern
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.public Expression[] getCompiledPredicates(int opPos) throws javax.xml.transform.TransformerException
opPos
- The position of the first predicate the m_opMap array.
Expression
instances.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.public int countPredicates(int opPos) throws javax.xml.transform.TransformerException
opPos
- The position of the first predicate the m_opMap array.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.private void compilePredicates(int opPos, Expression[] predicates) throws javax.xml.transform.TransformerException
opPos
- The position of the first predicate the m_opMap array.predicates
- An empty pre-determined array of
Expression
s, that will be filled in.
javax.xml.transform.TransformerException
Expression compileFunction(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
Function
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.private Expression compileExtension(int opPos) throws javax.xml.transform.TransformerException
opPos
- The current position in the m_opMap array.
FuncExtFunction
instance.
javax.xml.transform.TransformerException
- if a error occurs creating the Expression.public void warn(String msg, Object[] args) throws javax.xml.transform.TransformerException
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.
javax.xml.transform.TransformerException
- if the current ErrorListoner determines to
throw an exception.public void assertion(boolean b, String msg)
b
- If false, a runtime exception will be thrown.msg
- The assertion message, which should be informative.
RuntimeException
- if the b argument is false.public void error(String msg, Object[] args) throws javax.xml.transform.TransformerException
error
in class 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.
javax.xml.transform.TransformerException
- if the current ErrorListoner determines to
throw an exception.public PrefixResolver getNamespaceContext()
public void setNamespaceContext(PrefixResolver pr)
pr
- The resolver for prefixes in the XPath expression.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |