/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: OpMap.java,v 1.1.2.1 2005/08/01 01:30:31 jeffsuttor Exp $
*/
/**
* This class represents the data structure basics of the XPath
* object.
*/
public class OpMap
{
/**
* The current pattern string, for diagnostics purposes
*/
/**
* Return the expression as a string for diagnostics.
*
* @return The expression string.
*/
{
return m_currentPattern;
}
/**
* Return the expression as a string for diagnostics.
*
* @return The expression string.
*/
{
return m_currentPattern;
}
/**
* The starting size of the token queue.
*/
/*
* Amount to grow token queue when it becomes full
*/
/**
* 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.
*/
/**
* Get the XPath as a list of tokens.
*
* @return ObjectVector of tokens.
*/
{
return m_tokenQueue;
}
/**
* Get the XPath as a list of tokens.
*
* @param pos index into token queue.
*
* @return The token, normally a string.
*/
{
}
/**
* The current size of the token queue.
*/
// public int m_tokenQueueSize = 0;
/**
* Get size of the token queue.
*
* @return The size of the token queue.
*/
public int getTokenQueueSize()
{
return m_tokenQueue.size();
}
/**
* 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.
*/
/**
* 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 An IntVector that is the opcode list that describes the XPath operations.
*/
{
return m_opMap;
}
// Position indexes
/**
* The length is always the opcode position + 1.
* Length is always expressed as the opcode+length bytes,
* so it is always 2 or greater.
*/
/**
* Replace the large arrays
* with a small array.
*/
void shrink()
{
n = m_tokenQueue.size();
}
/**
* Given an operation position, return the current op.
*
* @param opPos index into op map.
* @return the op that corresponds to the opPos argument.
*/
{
}
/**
* Set the op at index to the given int.
*
* @param opPos index into op map.
* @param value Value to set
*/
{
}
/**
* Given an operation position, return the end position, i.e. the
* beginning of the next operation.
*
* @param opPos An op position of an operation for which there is a size
* entry following.
* @return position of next operation in m_opMap.
*/
{
}
/**
* Given a location step position, return the end position, i.e. the
* beginning of the next step.
*
* @param opPos the position of a location step.
* @return the position of the next location step.
*/
{
{
return getNextOpPos(opPos);
}
{
{
}
{
}
return newOpPos;
}
else
{
throw new RuntimeException(
XSLMessages.createXPATHMessage(XPATHErrorResources.ER_UNKNOWN_STEP, new Object[]{String.valueOf(stepType)}));
//"Programmer's assertion in getNextStepPos: unknown stepType: " + stepType);
}
}
/**
* Given an operation position, return the end position, i.e. the
* beginning of the next operation.
*
* @param opMap The operations map.
* @param opPos index to operation, for which there is a size entry following.
* @return position of next operation in m_opMap.
*/
{
}
/**
* 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);
*
* @param opPos position of FROM_stepType op.
* @return position of predicate in FROM_stepType structure.
*/
{
{
}
{
}
else if(-2 == stepType)
{
return -2;
}
else
{
return -1;
}
}
/**
* Tell the user of an error, and probably throw an
* exception.
*
* @param msg An error msgkey that corresponds to one of the constants found
* in {@link com.sun.org.apache.xpath.internal.res.XPATHErrorResources}, which is
* a key for a format string.
* @param 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.
*/
{
java.lang.String fmsg = com.sun.org.apache.xalan.internal.res.XSLMessages.createXPATHMessage(msg, args);
}
/**
* Go to the first child of a given operation.
*
* @param opPos position of operation.
*
* @return The position of the first child of the operation.
*/
{
return opPos + 2;
}
/**
* Get the length of an operation.
*
* @param opPos The position of the operation in the op map.
*
* @return The size of the operation.
*/
{
}
/**
* Given a location step, get the length of that step.
*
* @param opPos Position of location step in op map.
*
* @return The length of the step.
*/
{
}
/**
* Get the first child position of a given location step.
*
* @param opPos Position of location step in the location map.
*
* @return The first child position of the step.
*/
{
return opPos + 3;
}
/**
* Get the test type of the step, i.e. NODETYPE_XXX value.
*
* @param opPosOfStep The position of the FROM_XXX step.
*
* @return NODETYPE_XXX value.
*/
{
}
/**
* Get the namespace of the step.
*
* @param opPosOfStep The position of the FROM_XXX step.
*
* @return The step's namespace, NodeTest.WILD, or null for null namespace.
*/
{
// System.out.println("getStepNS.argLenOfStep: "+argLenOfStep);
if (argLenOfStep == 3)
{
if (index >= 0)
else
return null;
}
else
return null;
}
/**
* Get the local name of the step.
* @param opPosOfStep The position of the FROM_XXX step.
*
* @return OpCodes.EMPTY, OpCodes.ELEMWILDCARD, or the local name.
*/
{
// System.out.println("getStepLocalName.argLenOfStep: "+argLenOfStep);
int index;
switch (argLenOfStep)
{
case 0 :
break;
case 1 :
break;
case 2 :
break;
case 3 :
break;
default :
break; // Should assert error
}
// int index = (argLenOfStep == 3) ? m_opMap[opPosOfStep+5]
// : ((argLenOfStep == 1) ? -3 : -2);
if (index >= 0)
else
return null;
}
}