Search in sources :

Example 1 with FilterExprIteratorSimple

use of org.apache.xpath.axes.FilterExprIteratorSimple 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;
    }
}
Also used : Variable(org.apache.xpath.operations.Variable) FilterExprWalker(org.apache.xpath.axes.FilterExprWalker) AxesWalker(org.apache.xpath.axes.AxesWalker) FilterExprIteratorSimple(org.apache.xpath.axes.FilterExprIteratorSimple) Vector(java.util.Vector)

Example 2 with FilterExprIteratorSimple

use of org.apache.xpath.axes.FilterExprIteratorSimple 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;
    }
}
Also used : Variable(org.apache.xpath.operations.Variable) FilterExprWalker(org.apache.xpath.axes.FilterExprWalker) AxesWalker(org.apache.xpath.axes.AxesWalker) FilterExprIteratorSimple(org.apache.xpath.axes.FilterExprIteratorSimple) Vector(java.util.Vector)

Aggregations

Vector (java.util.Vector)2 AxesWalker (org.apache.xpath.axes.AxesWalker)2 FilterExprIteratorSimple (org.apache.xpath.axes.FilterExprIteratorSimple)2 FilterExprWalker (org.apache.xpath.axes.FilterExprWalker)2 Variable (org.apache.xpath.operations.Variable)2