APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.org.apache.xpath.internal.compiler

public Class OpMap

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.org.apache.xpath.internal.compiler.Compiler
Imports
com.sun.org.apache.xalan.internal.res.XSLMessages, com.sun.org.apache.xml.internal.utils.ObjectVector, com.sun.org.apache.xpath.internal.patterns.NodeTest, com.sun.org.apache.xpath.internal.res.XPATHErrorResources

This class represents the data structure basics of the XPath object.

Field Summary

Modifier and TypeField and Description
pack-priv static final int
protected String
m_currentPattern

The current pattern string, for diagnostics purposes

pack-priv OpMapVector
m_opMap

An operations map is used instead of a proper parse tree.

pack-priv ObjectVector
m_tokenQueue

TokenStack is the queue of used tokens.

public static final int
MAPINDEX_LENGTH

The length is always the opcode position + 1.

pack-priv static final int
MAXTOKENQUEUESIZE

The starting size of the token queue.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
error(String
An error msgkey that corresponds to one of the constants found in com.sun.org.apache.xpath.internal.res.XPATHErrorResources, which is a key for a format string.
msg
,
Object[]
An array of arguments represented in the format string, which may be null.
args
)

Tell the user of an error, and probably throw an exception.

public int

Returns:

The size of the operation.
getArgLength
(int
The position of the operation in the op map.
opPos
)

Get the length of an operation.

public int

Returns:

The length of the step.
getArgLengthOfStep
(int
Position of location step in op map.
opPos
)

Given a location step, get the length of that step.

public static int

Returns:

The position of the first child of the operation.
getFirstChildPos
(int
position of operation.
opPos
)

Go to the first child of a given operation.

public static int

Returns:

The first child position of the step.
getFirstChildPosOfStep
(int
Position of location step in the location map.
opPos
)

Get the first child position of a given location step.

public int

Returns:

position of predicate in FROM_stepType structure.
getFirstPredicateOpPos
(int
position of FROM_stepType op.
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.

public int

Returns:

position of next operation in m_opMap.
getNextOpPos
(int
An op position of an operation for which there is a size entry following.
opPos
)

Given an operation position, return the end position, i.e. the beginning of the next operation.

public static int

Returns:

position of next operation in m_opMap.
getNextOpPos
(int[]
The operations map.
opMap
,
int
index to operation, for which there is a size entry following.
opPos
)

Given an operation position, return the end position, i.e. the beginning of the next operation.

public int

Returns:

the position of the next location step.
getNextStepPos
(int
the position of a location step.
opPos
)

Given a location step position, return the end position, i.e. the beginning of the next step.

public int

Returns:

the op that corresponds to the opPos argument.
getOp
(int
index into op map.
opPos
)

Given an operation position, return the current op.

public OpMapVector

Returns:

An IntVector that is the opcode list that describes the XPath operations.
getOpMap
()

Get the opcode list that describes the XPath operations.

public String

Returns:

The expression string.
getPatternString
()

Return the expression as a string for diagnostics.

public String

Returns:

OpCodes.EMPTY, OpCodes.ELEMWILDCARD, or the local name.
getStepLocalName
(int
The position of the FROM_XXX step.
opPosOfStep
)

Get the local name of the step.

public String

Returns:

The step's namespace, NodeTest.WILD, or null for null namespace.
getStepNS
(int
The position of the FROM_XXX step.
opPosOfStep
)

Get the namespace of the step.

public int

Returns:

NODETYPE_XXX value.
getStepTestType
(int
The position of the FROM_XXX step.
opPosOfStep
)

Get the test type of the step, i.e. NODETYPE_XXX value.

public Object

Returns:

The token, normally a string.
getToken
(int
index into token queue.
pos
)

Get the XPath as a list of tokens.

public ObjectVector

Returns:

ObjectVector of tokens.
getTokenQueue
()

Get the XPath as a list of tokens.

public int

Returns:

The size of the token queue.
getTokenQueueSize
()

Get size of the token queue.

public void
setOp(int
index into op map.
opPos
,
int
Value to set
value
)

Set the op at index to the given int.

pack-priv void
shrink()

Replace the large arrays with a small array.

public String

Returns:

The expression string.
toString
()

Overrides java.lang.Object.toString.

Return the expression as a string for diagnostics.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

BLOCKTOKENQUEUESIZEback to summary
pack-priv static final int BLOCKTOKENQUEUESIZE
m_currentPatternback to summary
protected String m_currentPattern

The current pattern string, for diagnostics purposes

m_opMapback to summary
pack-priv OpMapVector m_opMap

An operations map is used instead of a proper parse tree. 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.

m_tokenQueueback to summary
pack-priv ObjectVector m_tokenQueue

TokenStack is the queue of used tokens. The current token is the token at the end of the m_tokenQueue. The idea is that the queue can be marked and a sequence of tokens can be reused.

MAPINDEX_LENGTHback to summary
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.

MAXTOKENQUEUESIZEback to summary
pack-priv static final int MAXTOKENQUEUESIZE

The starting size of the token queue.

Constructor Detail

OpMapback to summary
public OpMap()

Method Detail

errorback to summary
public void error(String msg, Object[] args) throws TransformerException

Tell the user of an error, and probably throw an exception.

Parameters
msg:String

An error msgkey that corresponds to one of the constants found in com.sun.org.apache.xpath.internal.res.XPATHErrorResources, which is a key for a format string.

args:Object[]

An array of arguments represented in the format string, which may be null.

Exceptions
TransformerException:
if the current ErrorListoner determines to throw an exception.
getArgLengthback to summary
public int getArgLength(int opPos)

Get the length of an operation.

Parameters
opPos:int

The position of the operation in the op map.

Returns:int

The size of the operation.

getArgLengthOfStepback to summary
public int getArgLengthOfStep(int opPos)

Given a location step, get the length of that step.

Parameters
opPos:int

Position of location step in op map.

Returns:int

The length of the step.

getFirstChildPosback to summary
public static int getFirstChildPos(int opPos)

Go to the first child of a given operation.

Parameters
opPos:int

position of operation.

Returns:int

The position of the first child of the operation.

getFirstChildPosOfStepback to summary
public static int getFirstChildPosOfStep(int opPos)

Get the first child position of a given location step.

Parameters
opPos:int

Position of location step in the location map.

Returns:int

The first child position of the step.

getFirstPredicateOpPosback to summary
public int getFirstPredicateOpPos(int opPos) throws TransformerException

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:int

position of FROM_stepType op.

Returns:int

position of predicate in FROM_stepType structure.

getNextOpPosback to summary
public int getNextOpPos(int opPos)

Given an operation position, return the end position, i.e. the beginning of the next operation.

Parameters
opPos:int

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

Returns:int

position of next operation in m_opMap.

getNextOpPosback to summary
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:int[]

The operations map.

opPos:int

index to operation, for which there is a size entry following.

Returns:int

position of next operation in m_opMap.

getNextStepPosback to summary
public int getNextStepPos(int opPos)

Given a location step position, return the end position, i.e. the beginning of the next step.

Parameters
opPos:int

the position of a location step.

Returns:int

the position of the next location step.

getOpback to summary
public int getOp(int opPos)

Given an operation position, return the current op.

Parameters
opPos:int

index into op map.

Returns:int

the op that corresponds to the opPos argument.

getOpMapback to summary
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:OpMapVector

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

getPatternStringback to summary
public String getPatternString()

Return the expression as a string for diagnostics.

Returns:String

The expression string.

getStepLocalNameback to summary
public String getStepLocalName(int opPosOfStep)

Get the local name of the step.

Parameters
opPosOfStep:int

The position of the FROM_XXX step.

Returns:String

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

getStepNSback to summary
public String getStepNS(int opPosOfStep)

Get the namespace of the step.

Parameters
opPosOfStep:int

The position of the FROM_XXX step.

Returns:String

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

getStepTestTypeback to summary
public int getStepTestType(int opPosOfStep)

Get the test type of the step, i.e. NODETYPE_XXX value.

Parameters
opPosOfStep:int

The position of the FROM_XXX step.

Returns:int

NODETYPE_XXX value.

getTokenback to summary
public Object getToken(int pos)

Get the XPath as a list of tokens.

Parameters
pos:int

index into token queue.

Returns:Object

The token, normally a string.

getTokenQueueback to summary
public ObjectVector getTokenQueue()

Get the XPath as a list of tokens.

Returns:ObjectVector

ObjectVector of tokens.

getTokenQueueSizeback to summary
public int getTokenQueueSize()

Get size of the token queue.

Returns:int

The size of the token queue.

setOpback to summary
public void setOp(int opPos, int value)

Set the op at index to the given int.

Parameters
opPos:int

index into op map.

value:int

Value to set

shrinkback to summary
pack-priv void shrink()

Replace the large arrays with a small array.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Return the expression as a string for diagnostics.

Returns:String

The expression string.