org.apache.xpath.compiler

Class OpMap

public class OpMap extends Object

This class represents the data structure basics of the XPath object.
Field Summary
static intMAPINDEX_LENGTH
The length is always the opcode position + 1.
Method Summary
voiderror(String msg, Object[] args)
Tell the user of an error, and probably throw an exception.
intgetArgLength(int opPos)
Get the length of an operation.
intgetArgLengthOfStep(int opPos)
Given a location step, get the length of that step.
static intgetFirstChildPos(int opPos)
Go to the first child of a given operation.
static intgetFirstChildPosOfStep(int opPos)
Get the first child position of a given location step.
intgetFirstPredicateOpPos(int opPos)
Given an FROM_stepType position, return the position of the first predicate, if there is one, or else this will point to the end of the FROM_stepType.
intgetNextOpPos(int opPos)
Given an operation position, return the end position, i.e. the beginning of the next operation.
static intgetNextOpPos(int[] opMap, int opPos)
Given an operation position, return the end position, i.e. the beginning of the next operation.
intgetNextStepPos(int opPos)
Given a location step position, return the end position, i.e. the beginning of the next step.
intgetOp(int opPos)
Given an operation position, return the current op.
OpMapVectorgetOpMap()
Get the opcode list that describes the XPath operations.
StringgetPatternString()
Return the expression as a string for diagnostics.
StringgetStepLocalName(int opPosOfStep)
Get the local name of the step.
StringgetStepNS(int opPosOfStep)
Get the namespace of the step.
intgetStepTestType(int opPosOfStep)
Get the test type of the step, i.e.
ObjectgetToken(int pos)
Get the XPath as a list of tokens.
ObjectVectorgetTokenQueue()
Get the XPath as a list of tokens.
intgetTokenQueueSize()
Get size of the token queue.
voidsetOp(int opPos, int value)
Set the op at index to the given int.
StringtoString()
Return the expression as a string for diagnostics.

Field Detail

MAPINDEX_LENGTH

public static final int MAPINDEX_LENGTH
The length is always the opcode position + 1. Length is always expressed as the opcode+length bytes, so it is always 2 or greater.

Method Detail

error

public void error(String msg, Object[] args)
Tell the user of an error, and probably throw an exception.

Parameters: msg An error msgkey that corresponds to one of the constants found in {@link org.apache.xpath.res.XPATHErrorResources}, which is a key for a format string. args An array of arguments represented in the format string, which may be null.

Throws: TransformerException if the current ErrorListoner determines to throw an exception.

getArgLength

public int getArgLength(int opPos)
Get the length of an operation.

Parameters: opPos The position of the operation in the op map.

Returns: The size of the operation.

getArgLengthOfStep

public int getArgLengthOfStep(int opPos)
Given a location step, get the length of that step.

Parameters: opPos Position of location step in op map.

Returns: The length of the step.

getFirstChildPos

public static int getFirstChildPos(int opPos)
Go to the first child of a given operation.

Parameters: opPos position of operation.

Returns: The position of the first child of the operation.

getFirstChildPosOfStep

public static int getFirstChildPosOfStep(int opPos)
Get the first child position of a given location step.

Parameters: opPos Position of location step in the location map.

Returns: The first child position of the step.

getFirstPredicateOpPos

public int getFirstPredicateOpPos(int opPos)
Given an FROM_stepType position, return the position of the first predicate, if there is one, or else this will point to the end of the FROM_stepType. Example: int posOfPredicate = xpath.getNextOpPos(stepPos); boolean hasPredicates = OpCodes.OP_PREDICATE == xpath.getOp(posOfPredicate);

Parameters: opPos position of FROM_stepType op.

Returns: position of predicate in FROM_stepType structure.

getNextOpPos

public int getNextOpPos(int opPos)
Given an operation position, return the end position, i.e. the beginning of the next operation.

Parameters: opPos An op position of an operation for which there is a size entry following.

Returns: position of next operation in m_opMap.

getNextOpPos

public static int getNextOpPos(int[] opMap, int opPos)
Given an operation position, return the end position, i.e. the beginning of the next operation.

Parameters: opMap The operations map. opPos index to operation, for which there is a size entry following.

Returns: position of next operation in m_opMap.

getNextStepPos

public int getNextStepPos(int opPos)
Given a location step position, return the end position, i.e. the beginning of the next step.

Parameters: opPos the position of a location step.

Returns: the position of the next location step.

getOp

public int getOp(int opPos)
Given an operation position, return the current op.

Parameters: opPos index into op map.

Returns: the op that corresponds to the opPos argument.

getOpMap

public OpMapVector getOpMap()
Get the opcode list that describes the XPath operations. It contains operations codes and indexes into the m_tokenQueue. I use an array instead of a full parse tree in order to cut down on the number of objects created.

Returns: An IntVector that is the opcode list that describes the XPath operations.

getPatternString

public String getPatternString()
Return the expression as a string for diagnostics.

Returns: The expression string.

getStepLocalName

public String getStepLocalName(int opPosOfStep)
Get the local name of the step.

Parameters: opPosOfStep The position of the FROM_XXX step.

Returns: OpCodes.EMPTY, OpCodes.ELEMWILDCARD, or the local name.

getStepNS

public String getStepNS(int opPosOfStep)
Get the namespace of the step.

Parameters: opPosOfStep The position of the FROM_XXX step.

Returns: The step's namespace, NodeTest.WILD, or null for null namespace.

getStepTestType

public int getStepTestType(int opPosOfStep)
Get the test type of the step, i.e. NODETYPE_XXX value.

Parameters: opPosOfStep The position of the FROM_XXX step.

Returns: NODETYPE_XXX value.

getToken

public Object getToken(int pos)
Get the XPath as a list of tokens.

Parameters: pos index into token queue.

Returns: The token, normally a string.

getTokenQueue

public ObjectVector getTokenQueue()
Get the XPath as a list of tokens.

Returns: ObjectVector of tokens.

getTokenQueueSize

public int getTokenQueueSize()
Get size of the token queue.

Returns: The size of the token queue.

setOp

public void setOp(int opPos, int value)
Set the op at index to the given int.

Parameters: opPos index into op map. value Value to set

toString

public String toString()
Return the expression as a string for diagnostics.

Returns: The expression string.

Copyright B) 2005 Apache XML Project. All Rights Reserved.