use of org.apache.xpath.operations.Variable in project robovm by robovm.
the class Compiler method variable.
/**
* Compile a variable reference.
*
* @param opPos The current position in the m_opMap array.
*
* @return reference to {@link org.apache.xpath.operations.Variable} instance.
*
* @throws TransformerException if a error occurs creating the Expression.
*/
protected Expression variable(int opPos) throws TransformerException {
Variable var = new Variable();
opPos = getFirstChildPos(opPos);
int nsPos = getOp(opPos);
java.lang.String namespace = (OpCodes.EMPTY == nsPos) ? null : (java.lang.String) getTokenQueue().elementAt(nsPos);
java.lang.String localname = (java.lang.String) getTokenQueue().elementAt(getOp(opPos + 1));
QName qname = new QName(namespace, localname);
var.setQName(qname);
return var;
}
use of org.apache.xpath.operations.Variable in project j2objc by google.
the class RedundentExprEliminator method changePartToRef.
/**
* Change a given number of steps to a single variable reference.
*
* @param uniquePseudoVarName The name of the variable reference.
* @param wi The walking iterator that is to be changed.
* @param numSteps The number of steps to be changed.
* @param isGlobal true if this will be a global reference.
*/
protected LocPathIterator changePartToRef(final QName uniquePseudoVarName, WalkingIterator wi, final int numSteps, final boolean isGlobal) {
Variable var = new Variable();
var.setQName(uniquePseudoVarName);
var.setIsGlobal(isGlobal);
if (isGlobal) {
ElemTemplateElement elem = getElemFromExpression(wi);
StylesheetRoot root = elem.getStylesheetRoot();
Vector vars = root.getVariablesAndParamsComposed();
var.setIndex(vars.size() - 1);
}
// Walk to the first walker after the one's we are replacing.
AxesWalker walker = wi.getFirstWalker();
for (int i = 0; i < numSteps; i++) {
assertion(null != walker, "Walker should not be null!");
walker = walker.getNextWalker();
}
if (null != walker) {
FilterExprWalker few = new FilterExprWalker(wi);
few.setInnerExpression(var);
few.exprSetParent(wi);
few.setNextWalker(walker);
walker.setPrevWalker(few);
wi.setFirstWalker(few);
return wi;
} else {
FilterExprIteratorSimple feis = new FilterExprIteratorSimple(var);
feis.exprSetParent(wi.exprGetParent());
return feis;
}
}
use of org.apache.xpath.operations.Variable in project j2objc by google.
the class Compiler method variable.
/**
* Compile a variable reference.
*
* @param opPos The current position in the m_opMap array.
*
* @return reference to {@link org.apache.xpath.operations.Variable} instance.
*
* @throws TransformerException if a error occurs creating the Expression.
*/
protected Expression variable(int opPos) throws TransformerException {
Variable var = new Variable();
opPos = getFirstChildPos(opPos);
int nsPos = getOp(opPos);
java.lang.String namespace = (OpCodes.EMPTY == nsPos) ? null : (java.lang.String) getTokenQueue().elementAt(nsPos);
java.lang.String localname = (java.lang.String) getTokenQueue().elementAt(getOp(opPos + 1));
QName qname = new QName(namespace, localname);
var.setQName(qname);
return var;
}
use of org.apache.xpath.operations.Variable in project robovm by robovm.
the class RedundentExprEliminator method changePartToRef.
/**
* Change a given number of steps to a single variable reference.
*
* @param uniquePseudoVarName The name of the variable reference.
* @param wi The walking iterator that is to be changed.
* @param numSteps The number of steps to be changed.
* @param isGlobal true if this will be a global reference.
*/
protected LocPathIterator changePartToRef(final QName uniquePseudoVarName, WalkingIterator wi, final int numSteps, final boolean isGlobal) {
Variable var = new Variable();
var.setQName(uniquePseudoVarName);
var.setIsGlobal(isGlobal);
if (isGlobal) {
ElemTemplateElement elem = getElemFromExpression(wi);
StylesheetRoot root = elem.getStylesheetRoot();
Vector vars = root.getVariablesAndParamsComposed();
var.setIndex(vars.size() - 1);
}
// Walk to the first walker after the one's we are replacing.
AxesWalker walker = wi.getFirstWalker();
for (int i = 0; i < numSteps; i++) {
assertion(null != walker, "Walker should not be null!");
walker = walker.getNextWalker();
}
if (null != walker) {
FilterExprWalker few = new FilterExprWalker(wi);
few.setInnerExpression(var);
few.exprSetParent(wi);
few.setNextWalker(walker);
walker.setPrevWalker(few);
wi.setFirstWalker(few);
return wi;
} else {
FilterExprIteratorSimple feis = new FilterExprIteratorSimple(var);
feis.exprSetParent(wi.exprGetParent());
return feis;
}
}
use of org.apache.xpath.operations.Variable in project robovm by robovm.
the class RedundentExprEliminator method changeToVarRef.
/**
* Change the expression owned by the owner argument to a variable reference
* of the given name.
*
* Warning: For global vars, this function relies on the variable declaration
* to which it refers having been added just prior to this function being called,
* so that the reference index can be determined from the size of the global variables
* list minus one.
*
* @param varName The name of the variable which will be referenced.
* @param owner The owner of the expression which will be replaced by a variable ref.
* @param paths The paths list that the iterator came from, mainly to determine
* if this is a local or global reduction.
* @param psuedoVarRecipient The element within whose scope the variable is
* being inserted, possibly a StylesheetRoot.
*/
protected void changeToVarRef(QName varName, ExpressionOwner owner, Vector paths, ElemTemplateElement psuedoVarRecipient) {
Variable varRef = (paths == m_absPaths) ? new VariableSafeAbsRef() : new Variable();
varRef.setQName(varName);
if (paths == m_absPaths) {
StylesheetRoot root = (StylesheetRoot) psuedoVarRecipient;
Vector globalVars = root.getVariablesAndParamsComposed();
// Assume this operation is occuring just after the decl has
// been added.
varRef.setIndex(globalVars.size() - 1);
varRef.setIsGlobal(true);
}
owner.setExpression(varRef);
}
Aggregations