int op = getOp(opPos); expr = compile(opPos + 2); break; case OpCodes.OP_OR : expr = or(opPos); break; case OpCodes.OP_AND : expr = and(opPos); break; case OpCodes.OP_NOTEQUALS : expr = notequals(opPos); break; case OpCodes.OP_EQUALS : expr = equals(opPos); break; case OpCodes.OP_LTE : expr = lte(opPos); break; case OpCodes.OP_LT : expr = lt(opPos); break; case OpCodes.OP_GTE : expr = gte(opPos); break; case OpCodes.OP_GT : expr = gt(opPos); break; case OpCodes.OP_PLUS : expr = plus(opPos); break; case OpCodes.OP_MINUS : expr = minus(opPos); break; case OpCodes.OP_MULT : expr = mult(opPos); break; case OpCodes.OP_DIV : expr = div(opPos); break; case OpCodes.OP_MOD : expr = mod(opPos); break;
/** * Compile an 'or' operation. * * @param opPos The current position in the m_opMap array. * * @return reference to {@link org.apache.xpath.operations.Or} instance. * * @throws TransformerException if a error occurs creating the Expression. */ protected Expression or(int opPos) throws TransformerException { return compileOperation(new Or(), opPos); }
/** * Compile a zero or more predicates for a given match pattern. * * @param opPos The position of the first predicate the m_opMap array. * * @return reference to array of {@link org.apache.xpath.Expression} instances. * * @throws TransformerException if a error occurs creating the Expression. */ public Expression[] getCompiledPredicates(int opPos) throws TransformerException { int count = countPredicates(opPos); if (count > 0) { Expression[] predicates = new Expression[count]; compilePredicates(opPos, predicates); return predicates; } return null; }
/** * Bottle-neck compilation of an operation with left and right operands. * * @param operation non-null reference to parent operation. * @param opPos The op map position of the parent operation. * * @return reference to {@link org.apache.xpath.operations.Operation} instance. * * @throws TransformerException if there is a syntax or other error. */ private Expression compileOperation(Operation operation, int opPos) throws TransformerException { int leftPos = getFirstChildPos(opPos); int rightPos = getNextOpPos(leftPos); operation.setLeftRight(compile(leftPos), compile(rightPos)); return operation; }
/** * Bottle-neck compilation of a unary operation. * * @param unary The parent unary operation. * @param opPos The position in the op map of the parent operation. * * @return The unary argument. * * @throws TransformerException if syntax or other error occurs. */ private Expression compileUnary(UnaryOperation unary, int opPos) throws TransformerException { int rightPos = getFirstChildPos(opPos); unary.setRight(compile(rightPos)); return unary; }
int stepType = getOp(opPos); int endStep = getNextOpPos(opPos); System.out.println("MATCH_FUNCTION: "+m_currentPattern); addMagicSelf = false; argLen = getOp(opPos + OpMap.MAPINDEX_LENGTH); pattern = new FunctionPattern(compileFunction(opPos), Axis.PARENT, Axis.CHILD); break; case OpCodes.FROM_ROOT : System.out.println("FROM_ROOT, "+m_currentPattern); addMagicSelf = false; argLen = getArgLengthOfStep(opPos); opPos = getFirstChildPosOfStep(opPos); pattern = new StepPattern(DTMFilter.SHOW_DOCUMENT | DTMFilter.SHOW_DOCUMENT_FRAGMENT, case OpCodes.MATCH_ATTRIBUTE : if(DEBUG) System.out.println("MATCH_ATTRIBUTE: "+getStepLocalName(startOpPos)+", "+m_currentPattern); argLen = getArgLengthOfStep(opPos); opPos = getFirstChildPosOfStep(opPos); pattern = new StepPattern(DTMFilter.SHOW_ATTRIBUTE, getStepNS(startOpPos), getStepLocalName(startOpPos), Axis.PARENT, Axis.ATTRIBUTE); break; case OpCodes.MATCH_ANY_ANCESTOR :
int endExtFunc = opPos + getOp(opPos + 1) - 1; opPos = getFirstChildPos(opPos); java.lang.String ns = (java.lang.String) getTokenQueue().elementAt(getOp(opPos)); (java.lang.String) getTokenQueue().elementAt(getOp(opPos)); Function extension = new FuncExtFunction(ns, funcName, String.valueOf(getNextMethodId())); int nextOpPos = getNextOpPos(opPos); extension.setArg(this.compile(opPos), i);
int i; for (i = 0; getOp(nextOpPos) == OpCodes.OP_LOCATIONPATHPATTERN; i++) nextOpPos = getNextOpPos(nextOpPos); return compile(opPos); for (i = 0; getOp(opPos) == OpCodes.OP_LOCATIONPATHPATTERN; i++) nextOpPos = getNextOpPos(opPos); patterns[i] = (StepPattern) compile(opPos); opPos = nextOpPos;
/** * Compile a unary '-' operation. * * @param opPos The current position in the m_opMap array. * * @return reference to {@link org.apache.xpath.operations.Neg} instance. * * @throws TransformerException if a error occurs creating the Expression. */ protected Expression neg(int opPos) throws TransformerException { return compileUnary(new Neg(), opPos); }
/** * Compile a location step predicate expression. * * @param opPos The current position in the m_opMap array. * * @return the contained predicate expression. * * @throws TransformerException if a error occurs creating the Expression. */ public Expression predicate(int opPos) throws TransformerException { return compile(opPos + 2); }
int stepType = getOp(opPos); int endStep = getNextOpPos(opPos); System.out.println("MATCH_FUNCTION: "+m_currentPattern); addMagicSelf = false; argLen = getOp(opPos + OpMap.MAPINDEX_LENGTH); pattern = new FunctionPattern(compileFunction(opPos), Axis.PARENT, Axis.CHILD); break; case OpCodes.FROM_ROOT : System.out.println("FROM_ROOT, "+m_currentPattern); addMagicSelf = false; argLen = getArgLengthOfStep(opPos); opPos = getFirstChildPosOfStep(opPos); pattern = new StepPattern(DTMFilter.SHOW_DOCUMENT | DTMFilter.SHOW_DOCUMENT_FRAGMENT, case OpCodes.MATCH_ATTRIBUTE : if(DEBUG) System.out.println("MATCH_ATTRIBUTE: "+getStepLocalName(startOpPos)+", "+m_currentPattern); argLen = getArgLengthOfStep(opPos); opPos = getFirstChildPosOfStep(opPos); pattern = new StepPattern(DTMFilter.SHOW_ATTRIBUTE, getStepNS(startOpPos), getStepLocalName(startOpPos), Axis.PARENT, Axis.ATTRIBUTE); break; case OpCodes.MATCH_ANY_ANCESTOR :
int endExtFunc = opPos + getOp(opPos + 1) - 1; opPos = getFirstChildPos(opPos); java.lang.String ns = (java.lang.String) getTokenQueue().elementAt(getOp(opPos)); (java.lang.String) getTokenQueue().elementAt(getOp(opPos)); Function extension = new FuncExtFunction(ns, funcName, String.valueOf(getNextMethodId())); int nextOpPos = getNextOpPos(opPos); extension.setArg(this.compile(opPos), i);
/** * Bottle-neck compilation of an operation with left and right operands. * * @param operation non-null reference to parent operation. * @param opPos The op map position of the parent operation. * * @return reference to {@link org.apache.xpath.operations.Operation} instance. * * @throws TransformerException if there is a syntax or other error. */ private Expression compileOperation(Operation operation, int opPos) throws TransformerException { int leftPos = getFirstChildPos(opPos); int rightPos = getNextOpPos(leftPos); operation.setLeftRight(compile(leftPos), compile(rightPos)); return operation; }
int i; for (i = 0; getOp(nextOpPos) == OpCodes.OP_LOCATIONPATHPATTERN; i++) nextOpPos = getNextOpPos(nextOpPos); return compile(opPos); for (i = 0; getOp(opPos) == OpCodes.OP_LOCATIONPATHPATTERN; i++) nextOpPos = getNextOpPos(opPos); patterns[i] = (StepPattern) compile(opPos); opPos = nextOpPos;
/** * Compile a 'number(...)' operation. * * @param opPos The current position in the m_opMap array. * * @return reference to {@link org.apache.xpath.operations.Number} instance. * * @throws TransformerException if a error occurs creating the Expression. */ protected Expression number(int opPos) throws TransformerException { return compileUnary(new org.apache.xpath.operations.Number(), opPos); }
/** * Compile a function argument. * * @param opPos The current position in the m_opMap array. * * @return reference to the argument expression. * * @throws TransformerException if a error occurs creating the Expression. */ protected Expression arg(int opPos) throws TransformerException { // no-op return compile(opPos + 2); }
/** * Bottle-neck compilation of a unary operation. * * @param unary The parent unary operation. * @param opPos The position in the op map of the parent operation. * * @return The unary argument. * * @throws TransformerException if syntax or other error occurs. */ private Expression compileUnary(UnaryOperation unary, int opPos) throws TransformerException { int rightPos = getFirstChildPos(opPos); unary.setRight(compile(rightPos)); return unary; }
int op = getOp(opPos); expr = compile(opPos + 2); break; case OpCodes.OP_OR : expr = or(opPos); break; case OpCodes.OP_AND : expr = and(opPos); break; case OpCodes.OP_NOTEQUALS : expr = notequals(opPos); break; case OpCodes.OP_EQUALS : expr = equals(opPos); break; case OpCodes.OP_LTE : expr = lte(opPos); break; case OpCodes.OP_LT : expr = lt(opPos); break; case OpCodes.OP_GTE : expr = gte(opPos); break; case OpCodes.OP_GT : expr = gt(opPos); break; case OpCodes.OP_PLUS : expr = plus(opPos); break; case OpCodes.OP_MINUS : expr = minus(opPos); break; case OpCodes.OP_MULT : expr = mult(opPos); break; case OpCodes.OP_DIV : expr = div(opPos); break; case OpCodes.OP_MOD : expr = mod(opPos); break;