Methods Summary |
---|
public void | error(java.lang.String msg, java.lang.Object[] args)Tell the user of an error, and probably throw an
exception.
java.lang.String fmsg = com.sun.org.apache.xalan.internal.res.XSLMessages.createXPATHMessage(msg, args);
throw new javax.xml.transform.TransformerException(fmsg);
|
public int | getArgLength(int opPos)Get the length of an operation.
return m_opMap.elementAt(opPos + MAPINDEX_LENGTH);
|
public int | getArgLengthOfStep(int opPos)Given a location step, get the length of that step.
return m_opMap.elementAt(opPos + MAPINDEX_LENGTH + 1) - 3;
|
public static int | getFirstChildPos(int opPos)Go to the first child of a given operation.
return opPos + 2;
|
public static int | getFirstChildPosOfStep(int opPos)Get the first child position of a given location step.
return opPos + 3;
|
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);
int stepType = m_opMap.elementAt(opPos);
if ((stepType >= OpCodes.AXES_START_TYPES)
&& (stepType <= OpCodes.AXES_END_TYPES))
{
return opPos + m_opMap.elementAt(opPos + 2);
}
else if ((stepType >= OpCodes.FIRST_NODESET_OP)
&& (stepType <= OpCodes.LAST_NODESET_OP))
{
return opPos + m_opMap.elementAt(opPos + 1);
}
else if(-2 == stepType)
{
return -2;
}
else
{
error(com.sun.org.apache.xpath.internal.res.XPATHErrorResources.ER_UNKNOWN_OPCODE,
new Object[]{ String.valueOf(stepType) }); //"ERROR! Unknown op code: "+m_opMap[opPos]);
return -1;
}
|
public int | getNextOpPos(int opPos)Given an operation position, return the end position, i.e. the
beginning of the next operation.
return opPos + m_opMap.elementAt(opPos + 1);
|
public static int | getNextOpPos(int[] opMap, int opPos)Given an operation position, return the end position, i.e. the
beginning of the next operation.
return opPos + opMap[opPos + 1];
|
public int | getNextStepPos(int opPos)Given a location step position, return the end position, i.e. the
beginning of the next step.
int stepType = getOp(opPos);
if ((stepType >= OpCodes.AXES_START_TYPES)
&& (stepType <= OpCodes.AXES_END_TYPES))
{
return getNextOpPos(opPos);
}
else if ((stepType >= OpCodes.FIRST_NODESET_OP)
&& (stepType <= OpCodes.LAST_NODESET_OP))
{
int newOpPos = getNextOpPos(opPos);
while (OpCodes.OP_PREDICATE == getOp(newOpPos))
{
newOpPos = getNextOpPos(newOpPos);
}
stepType = getOp(newOpPos);
if (!((stepType >= OpCodes.AXES_START_TYPES)
&& (stepType <= OpCodes.AXES_END_TYPES)))
{
return OpCodes.ENDOP;
}
return newOpPos;
}
else
{
throw new RuntimeException(
XSLMessages.createXPATHMessage(XPATHErrorResources.ER_UNKNOWN_STEP, new Object[]{new Integer(stepType).toString()}));
//"Programmer's assertion in getNextStepPos: unknown stepType: " + stepType);
}
|
public int | getOp(int opPos)Given an operation position, return the current op.
return m_opMap.elementAt(opPos);
|
public com.sun.org.apache.xpath.internal.compiler.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.
return m_opMap;
|
public java.lang.String | getPatternString()Return the expression as a string for diagnostics.
return m_currentPattern;
|
public java.lang.String | getStepLocalName(int opPosOfStep)Get the local name of the step.
int argLenOfStep = getArgLengthOfStep(opPosOfStep);
// System.out.println("getStepLocalName.argLenOfStep: "+argLenOfStep);
int index;
switch (argLenOfStep)
{
case 0 :
index = OpCodes.EMPTY;
break;
case 1 :
index = OpCodes.ELEMWILDCARD;
break;
case 2 :
index = m_opMap.elementAt(opPosOfStep + 4);
break;
case 3 :
index = m_opMap.elementAt(opPosOfStep + 5);
break;
default :
index = OpCodes.EMPTY;
break; // Should assert error
}
// int index = (argLenOfStep == 3) ? m_opMap[opPosOfStep+5]
// : ((argLenOfStep == 1) ? -3 : -2);
if (index >= 0)
return (String) m_tokenQueue.elementAt(index).toString();
else if (OpCodes.ELEMWILDCARD == index)
return NodeTest.WILD;
else
return null;
|
public java.lang.String | getStepNS(int opPosOfStep)Get the namespace of the step.
int argLenOfStep = getArgLengthOfStep(opPosOfStep);
// System.out.println("getStepNS.argLenOfStep: "+argLenOfStep);
if (argLenOfStep == 3)
{
int index = m_opMap.elementAt(opPosOfStep + 4);
if (index >= 0)
return (String) m_tokenQueue.elementAt(index);
else if (OpCodes.ELEMWILDCARD == index)
return NodeTest.WILD;
else
return null;
}
else
return null;
|
public int | getStepTestType(int opPosOfStep)Get the test type of the step, i.e. NODETYPE_XXX value.
return m_opMap.elementAt(opPosOfStep + 3); // skip past op, len, len without predicates
|
public java.lang.Object | getToken(int pos)Get the XPath as a list of tokens.
return m_tokenQueue.elementAt(pos);
|
public com.sun.org.apache.xml.internal.utils.ObjectVector | getTokenQueue()Get the XPath as a list of tokens.
return m_tokenQueue;
|
public int | getTokenQueueSize()Get size of the token queue.
return m_tokenQueue.size();
|
public void | setOp(int opPos, int value)Set the op at index to the given int.
m_opMap.setElementAt(value,opPos);
|
void | shrink()Replace the large arrays
with a small array.
int n = m_opMap.elementAt(MAPINDEX_LENGTH);
m_opMap.setToSize(n + 4);
m_opMap.setElementAt(0,n);
m_opMap.setElementAt(0,n+1);
m_opMap.setElementAt(0,n+2);
n = m_tokenQueue.size();
m_tokenQueue.setToSize(n + 4);
m_tokenQueue.setElementAt(null,n);
m_tokenQueue.setElementAt(null,n + 1);
m_tokenQueue.setElementAt(null,n + 2);
|
public java.lang.String | toString()Return the expression as a string for diagnostics.
return m_currentPattern;
|