BEA Systems, Inc.

WebLogic Server 6.1 API Reference

weblogic.apache.xpath.compiler
Class Compiler

java.lang.Object
  |
  +--weblogic.apache.xpath.compiler.OpMap
        |
        +--weblogic.apache.xpath.compiler.Compiler

public class Compiler
extends OpMap

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.

This class is based on an implementation from the Apache XML Project. In future releases the XML parser, XSLT processor, and associated classes will likely be updated to be based on a later version of the Apache implementations. Since Apache does not guarantee backwards compatibility between versions of their software, we cannot guarantee backwards compatibility of any of the classes contained in the weblogic.apache package or sub-packages.


Fields inherited from class weblogic.apache.xpath.compiler.OpMap
m_currentPattern, m_opMap, m_tokenQueue, m_tokenQueueSize, MAPINDEX_LENGTH
 
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 assert(boolean b, java.lang.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.
 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(int msg, java.lang.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 '!=' operation.
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(int msg, java.lang.Object[] args)
          Warn the user of an problem.
 
Methods inherited from class weblogic.apache.xpath.compiler.OpMap
getArgLength, getArgLengthOfStep, getFirstChildPos, getFirstChildPosOfStep, getFirstPredicateOpPos, getNextOpPos, getNextOpPos, getNextStepPos, getOp, getOpMap, getPatternString, getStepLocalName, getStepNS, getStepTestType, getToken, getTokenQueue, getTokenQueueSize, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Compiler

public 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.

Parameters:
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.

Compiler

public Compiler()
Construct a Compiler instance that has a null error listener and a null source locator.
Method Detail

compile

public Expression compile(int opPos)
                   throws javax.xml.transform.TransformerException
Execute the XPath object from a given opcode position.

Parameters:
xctxt - The execution context.
context - The current source tree context node.
opPos - The current position in the xpath.m_opMap array.
callback - Interface that implements the processLocatedNode method.
callbackInfo - Object that will be passed to the processLocatedNode method.
Returns:
The result of the XPath.
Throws:
javax.xml.transform.TransformerException - if there is a syntax or other error.

or

protected Expression or(int opPos)
                 throws javax.xml.transform.TransformerException
Compile an 'or' operation.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to Or instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

and

protected Expression and(int opPos)
                  throws javax.xml.transform.TransformerException
Compile an 'and' operation.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to And instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

notequals

protected Expression notequals(int opPos)
                        throws javax.xml.transform.TransformerException
Compile a '!=' operation.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to NotEquals instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

equals

protected Expression equals(int opPos)
                     throws javax.xml.transform.TransformerException
Compile a '=' operation.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to Equals instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

lte

protected Expression lte(int opPos)
                  throws javax.xml.transform.TransformerException
Compile a '<=' operation.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to Lte instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

lt

protected Expression lt(int opPos)
                 throws javax.xml.transform.TransformerException
Compile a '<' operation.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to Lt instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

gte

protected Expression gte(int opPos)
                  throws javax.xml.transform.TransformerException
Compile a '>=' operation.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to Gte instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

gt

protected Expression gt(int opPos)
                 throws javax.xml.transform.TransformerException
Compile a '>' operation.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to Gt instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

plus

protected Expression plus(int opPos)
                   throws javax.xml.transform.TransformerException
Compile a '+' operation.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to Plus instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

minus

protected Expression minus(int opPos)
                    throws javax.xml.transform.TransformerException
Compile a '-' operation.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to Minus instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

mult

protected Expression mult(int opPos)
                   throws javax.xml.transform.TransformerException
Compile a '*' operation.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to Mult instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

div

protected Expression div(int opPos)
                  throws javax.xml.transform.TransformerException
Compile a 'div' operation.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to Div instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

mod

protected Expression mod(int opPos)
                  throws javax.xml.transform.TransformerException
Compile a 'mod' operation.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to Mod instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

neg

protected Expression neg(int opPos)
                  throws javax.xml.transform.TransformerException
Compile a unary '-' operation.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to Neg instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

string

protected Expression string(int opPos)
                     throws javax.xml.transform.TransformerException
Compile a 'string(...)' operation.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to String instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

bool

protected Expression bool(int opPos)
                   throws javax.xml.transform.TransformerException
Compile a 'boolean(...)' operation.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to Bool instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

number

protected Expression number(int opPos)
                     throws javax.xml.transform.TransformerException
Compile a 'number(...)' operation.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to Number instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

literal

protected Expression literal(int opPos)
Compile a literal string value.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to XString instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

numberlit

protected Expression numberlit(int opPos)
Compile a literal number value.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to XNumber instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

variable

protected Expression variable(int opPos)
                       throws javax.xml.transform.TransformerException
Compile a variable reference.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to Variable instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

group

protected Expression group(int opPos)
                    throws javax.xml.transform.TransformerException
Compile an expression group.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to the contained expression.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

arg

protected Expression arg(int opPos)
                  throws javax.xml.transform.TransformerException
Compile a function argument.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to the argument expression.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

union

protected Expression union(int opPos)
                    throws javax.xml.transform.TransformerException
Compile a location path union. The UnionPathIterator itself may create LocPathIterator children.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to UnionPathIterator instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

getLocationPathDepth

public int getLocationPathDepth()
Get the level of the location path or union being constructed.

Returns:
0 if it is a top-level path.

locationPath

public Expression locationPath(int opPos)
                        throws javax.xml.transform.TransformerException
Compile a location path. The LocPathIterator itself may create AxesWalker children.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to LocPathIterator instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

predicate

public Expression predicate(int opPos)
                     throws javax.xml.transform.TransformerException
Compile a location step predicate expression.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
the contained predicate expression.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

matchPattern

protected Expression matchPattern(int opPos)
                           throws javax.xml.transform.TransformerException
Compile an entire match pattern expression.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to UnionPattern instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

locationPathPattern

public Expression locationPathPattern(int opPos)
                               throws javax.xml.transform.TransformerException
Compile a location match pattern unit expression.

Parameters:
opPos - The current position in the m_opMap array.
Returns:
reference to StepPattern instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

getWhatToShow

public int getWhatToShow(int opPos)
Get a NodeFilter bit set that tells what to show for a given node test.

Parameters:
opPos - the op map position for the location step.
Returns:
NodeFilter bit set that tells what to show for a given node test.

stepPattern

protected StepPattern stepPattern(int opPos,
                                  int stepCount,
                                  StepPattern ancestorPattern)
                           throws javax.xml.transform.TransformerException
Compile a step pattern unit expression, used for both location paths and match patterns.

Parameters:
opPos - The current position in the m_opMap array.
stepCount - The number of steps to expect.
ancestorPattern - The owning StepPattern, which may be null.
Returns:
reference to StepPattern instance.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

getCompiledPredicates

public Expression[] getCompiledPredicates(int opPos)
                                   throws javax.xml.transform.TransformerException
Compile a zero or more predicates for a given match pattern.

Parameters:
opPos - The position of the first predicate the m_opMap array.
Returns:
reference to array of Expression instances.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

countPredicates

public int countPredicates(int opPos)
                    throws javax.xml.transform.TransformerException
Count the number of predicates in the step.

Parameters:
opPos - The position of the first predicate the m_opMap array.
Returns:
The number of predicates for this step.
Throws:
javax.xml.transform.TransformerException - if a error occurs creating the Expression.

warn

public void warn(int msg,
                 java.lang.Object[] args)
          throws javax.xml.transform.TransformerException
Warn the user of an problem.

Parameters:
msg - An error number that corresponds to one of the numbers 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.
Throws:
javax.xml.transform.TransformerException - if the current ErrorListoner determines to throw an exception.

assert

public void assert(boolean b,
                   java.lang.String msg)
Tell the user of an assertion error, and probably throw an exception.

Parameters:
b - If false, a runtime exception will be thrown.
msg - The assertion message, which should be informative.
Throws:
java.lang.RuntimeException - if the b argument is false.

error

public void error(int msg,
                  java.lang.Object[] args)
           throws javax.xml.transform.TransformerException
Tell the user of an error, and probably throw an exception.

Parameters:
msg - An error number that corresponds to one of the numbers 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.
Throws:
javax.xml.transform.TransformerException - if the current ErrorListoner determines to throw an exception.

getNamespaceContext

public PrefixResolver getNamespaceContext()
Get the current namespace context for the xpath.

Returns:
The current prefix resolver, *may* be null, though hopefully not.

setNamespaceContext

public void setNamespaceContext(PrefixResolver pr)
Set the current namespace context for the xpath.

Parameters:
pr - The resolver for prefixes in the XPath expression.

Documentation is available at
http://download.oracle.com/docs/cd/E13222_01/wls/docs61

WebLogic classes and methods that do not appear in this reference are not public and are not supported.