当前位置: 首页>>代码示例>>Java>>正文


Java Type.NodeSet方法代码示例

本文整理汇总了Java中com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type.NodeSet方法的典型用法代码示例。如果您正苦于以下问题:Java Type.NodeSet方法的具体用法?Java Type.NodeSet怎么用?Java Type.NodeSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type的用法示例。


在下文中一共展示了Type.NodeSet方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
 * Type check a FilterParentPath. If the filter is not a node-set add a
 * cast to node-set only if it is of reference type. This type coercion
 * is needed for expressions like $x where $x is a parameter reference.
 * All optimizations are turned off before type checking underlying
 * predicates.
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    Type ptype = _primary.typeCheck(stable);
    boolean canOptimize = _primary instanceof KeyCall;

    if (ptype instanceof NodeSetType == false) {
        if (ptype instanceof ReferenceType)  {
            _primary = new CastExpr(_primary, Type.NodeSet);
        }
        else {
            throw new TypeCheckError(this);
        }
    }

    // Type check predicates and turn all optimizations off if appropriate
    int n = _predicates.size();
    for (int i = 0; i < n; i++) {
        Predicate pred = (Predicate) _predicates.elementAt(i);

        if (!canOptimize) {
            pred.dontOptimize();
        }
        pred.typeCheck(stable);
    }
    return _type = Type.NodeSet;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:FilterExpr.java

示例2: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    if (_select != null) {
        _type = _select.typeCheck(stable);
        if (_type instanceof NodeType || _type instanceof ReferenceType) {
            _select = new CastExpr(_select, Type.NodeSet);
            _type = Type.NodeSet;
        }
        if (_type instanceof NodeSetType||_type instanceof ResultTreeType) {
            typeCheckContents(stable); // with-params
            return Type.Void;
        }
        throw new TypeCheckError(this);
    }
    else {
        typeCheckContents(stable);          // with-params
        return Type.Void;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:ApplyTemplates.java

示例3: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    final int length = _components.length;
    for (int i = 0; i < length; i++) {
        if (_components[i].typeCheck(stable) != Type.NodeSet) {
            _components[i] = new CastExpr(_components[i], Type.NodeSet);
        }
    }
    return _type = Type.NodeSet;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:UnionPathExpr.java

示例4: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    if (_path != null) {
        final Type ptype = _path.typeCheck(stable);
        if (ptype instanceof NodeType) {            // promote to node-set
            _path = new CastExpr(_path, Type.NodeSet);
        }
    }
    return _type = Type.NodeSet;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:AbsoluteLocationPath.java

示例5: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    if (hasPredicates()) {
        // Type check all the predicates (e -> position() = e)
        final int n = _predicates.size();
        for (int i = 0; i < n; i++) {
            final Predicate pred = (Predicate)_predicates.elementAt(i);
            pred.typeCheck(stable);
        }
    }
    return Type.NodeSet;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:ProcessingInstructionPattern.java

示例6: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    stype = _step.typeCheck(stable);
    _path.typeCheck(stable);

    if (_axisMismatch) enableNodeOrdering();

    return _type = Type.NodeSet;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:ParentLocationPath.java

示例7: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
 * Type check a FilterParentPath. If the filter is not a node-set add a
 * cast to node-set only if it is of reference type. This type coercion is
 * needed for expressions like $x/LINE where $x is a parameter reference.
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    final Type ftype = _filterExpr.typeCheck(stable);
    if (ftype instanceof NodeSetType == false) {
        if (ftype instanceof ReferenceType)  {
            _filterExpr = new CastExpr(_filterExpr, Type.NodeSet);
        }
        /*
        else if (ftype instanceof ResultTreeType)  {
            _filterExpr = new CastExpr(_filterExpr, Type.NodeSet);
        }
        */
        else if (ftype instanceof NodeType)  {
            _filterExpr = new CastExpr(_filterExpr, Type.NodeSet);
        }
        else {
            throw new TypeCheckError(this);
        }
    }

    // Wrap single node path in a node set
    final Type ptype = _path.typeCheck(stable);
    if (!(ptype instanceof NodeSetType)) {
        _path = new CastExpr(_path, Type.NodeSet);
    }

    return _type = Type.NodeSet;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:FilterParentPath.java

示例8: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    _type = _select.typeCheck(stable);

    if (_type instanceof ReferenceType || _type instanceof NodeType) {
        _select = new CastExpr(_select, Type.NodeSet);
        typeCheckContents(stable);
        return Type.Void;
    }
    if (_type instanceof NodeSetType||_type instanceof ResultTreeType) {
        typeCheckContents(stable);
        return Type.Void;
    }
    throw new TypeCheckError(this);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:ForEach.java

示例9: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
 * Typing rules: see XSLT Reference by M. Kay page 345.
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    final Type tleft = _left.typeCheck(stable);
    final Type tright = _right.typeCheck(stable);

    if (tleft.isSimple() && tright.isSimple()) {
        if (tleft != tright) {
            if (tleft instanceof BooleanType) {
                _right = new CastExpr(_right, Type.Boolean);
            }
            else if (tright instanceof BooleanType) {
                _left = new CastExpr(_left, Type.Boolean);
            }
            else if (tleft instanceof NumberType ||
                     tright instanceof NumberType) {
                _left = new CastExpr(_left, Type.Real);
                _right = new CastExpr(_right, Type.Real);
            }
            else {          // both compared as strings
                _left = new CastExpr(_left,   Type.String);
                _right = new CastExpr(_right, Type.String);
            }
        }
    }
    else if (tleft instanceof ReferenceType) {
        _right = new CastExpr(_right, Type.Reference);
    }
    else if (tright instanceof ReferenceType) {
        _left = new CastExpr(_left, Type.Reference);
    }
    // the following 2 cases optimize @attr|.|.. = 'string'
    else if (tleft instanceof NodeType && tright == Type.String) {
        _left = new CastExpr(_left, Type.String);
    }
    else if (tleft == Type.String && tright instanceof NodeType) {
        _right = new CastExpr(_right, Type.String);
    }
    // optimize node/node
    else if (tleft instanceof NodeType && tright instanceof NodeType) {
        _left = new CastExpr(_left, Type.String);
        _right = new CastExpr(_right, Type.String);
    }
    else if (tleft instanceof NodeType && tright instanceof NodeSetType) {
        // compare(Node, NodeSet) will be invoked
    }
    else if (tleft instanceof NodeSetType && tright instanceof NodeType) {
        swapArguments();    // for compare(Node, NodeSet)
    }
    else {
        // At least one argument is of type node, node-set or result-tree

        // Promote an expression of type node to node-set
        if (tleft instanceof NodeType) {
            _left = new CastExpr(_left, Type.NodeSet);
        }
        if (tright instanceof NodeType) {
            _right = new CastExpr(_right, Type.NodeSet);
        }

        // If one arg is a node-set then make it the left one
        if (tleft.isSimple() ||
            tleft instanceof ResultTreeType &&
            tright instanceof NodeSetType) {
            swapArguments();
        }

        // Promote integers to doubles to have fewer compares
        if (_right.getType() instanceof IntType) {
            _right = new CastExpr(_right, Type.Real);
        }
    }
    return _type = Type.Boolean;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:76,代码来源:EqualityExpr.java

示例10: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    return Type.NodeSet;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:IdKeyPattern.java

示例11: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
 * Type check a predicate expression. If the type of the expression is
 * number convert it to boolean by adding a comparison with position().
 * Note that if the expression is a parameter, we cannot distinguish
 * at compile time if its type is number or not. Hence, expressions of
 * reference type are always converted to booleans.
 *
 * This method may be called twice, before and after calling
 * <code>dontOptimize()</code>. If so, the second time it should honor
 * the new value of <code>_canOptimize</code>.
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    Type texp = _exp.typeCheck(stable);

    // We need explicit type information for reference types - no good!
    if (texp instanceof ReferenceType) {
        _exp = new CastExpr(_exp, texp = Type.Real);
    }

    // A result tree fragment should not be cast directly to a number type,
    // but rather to a boolean value, and then to a numer (0 or 1).
    // Ref. section 11.2 of the XSLT 1.0 spec
    if (texp instanceof ResultTreeType) {
        _exp = new CastExpr(_exp, Type.Boolean);
        _exp = new CastExpr(_exp, Type.Real);
        texp = _exp.typeCheck(stable);
    }

    // Numerical types will be converted to a position filter
    if (texp instanceof NumberType) {
        // Cast any numerical types to an integer
        if (texp instanceof IntType == false) {
            _exp = new CastExpr(_exp, Type.Int);
        }

        if (_canOptimize) {
            // Nth position optimization. Expression must not depend on context
            _nthPositionFilter =
                !_exp.hasLastCall() && !_exp.hasPositionCall();

            // _nthDescendant optimization - only if _nthPositionFilter is on
            if (_nthPositionFilter) {
                SyntaxTreeNode parent = getParent();
                _nthDescendant = (parent instanceof Step) &&
                    (parent.getParent() instanceof AbsoluteLocationPath);
                return _type = Type.NodeSet;
            }
        }

       // Reset optimization flags
        _nthPositionFilter = _nthDescendant = false;

       // Otherwise, expand [e] to [position() = e]
       final QName position =
            getParser().getQNameIgnoreDefaultNs("position");
       final PositionCall positionCall =
            new PositionCall(position);
       positionCall.setParser(getParser());
       positionCall.setParent(this);

       _exp = new EqualityExpr(Operators.EQ, positionCall,
                                _exp);
       if (_exp.typeCheck(stable) != Type.Boolean) {
           _exp = new CastExpr(_exp, Type.Boolean);
       }
       return _type = Type.Boolean;
    }
    else {
        // All other types will be handled as boolean values
        if (texp instanceof BooleanType == false) {
            _exp = new CastExpr(_exp, Type.Boolean);
        }
        return _type = Type.Boolean;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:76,代码来源:Predicate.java

示例12: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
 * Type check the parameters for the id() or key() function.
 * The index name (for key() call only) must be a string or convertable
 * to a string, and the lookup-value must be a string or a node-set.
 * @param stable The parser's symbol table
 * @throws TypeCheckError When the parameters have illegal type
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    final Type returnType = super.typeCheck(stable);

    // Run type check on the key name (first argument) - must be a string,
    // and if it is not it must be converted to one using string() rules.
    if (_name != null) {
        final Type nameType = _name.typeCheck(stable);

        if (_name instanceof LiteralExpr) {
            final LiteralExpr literal = (LiteralExpr) _name;
            _resolvedQName =
                getParser().getQNameIgnoreDefaultNs(literal.getValue());
        }
        else if (nameType instanceof StringType == false) {
            _name = new CastExpr(_name, Type.String);
        }
    }

    // Run type check on the value for this key. This value can be of
    // any data type, so this should never cause any type-check errors.
    // If the value is a reference, then we have to defer the decision
    // of how to process it until run-time.
    // If the value is known not to be a node-set, then it should be
    // converted to a string before the lookup is done. If the value is
    // known to be a node-set then this process (convert to string, then
    // do lookup) should be applied to every node in the set, and the
    // result from all lookups should be added to the resulting node-set.
    _valueType = _value.typeCheck(stable);

    if (_valueType != Type.NodeSet
            && _valueType != Type.Reference
            && _valueType != Type.String) {
        _value = new CastExpr(_value, Type.String);
        _valueType = _value.typeCheck(stable);
    }

    // If in a top-level element, create dependency to the referenced key
    addParentDependency();

    return returnType;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:49,代码来源:KeyCall.java

示例13: translate

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
 * Translates the document() function call to a call to LoadDocument()'s
 * static method document().
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    final int ac = argumentCount();

    final int domField = cpg.addFieldref(classGen.getClassName(),
                                         DOM_FIELD,
                                         DOM_INTF_SIG);

    String docParamList = null;
    if (ac == 1) {
       // documentF(Object,String,AbstractTranslet,DOM)
       docParamList = "("+OBJECT_SIG+STRING_SIG+TRANSLET_SIG+DOM_INTF_SIG
                     +")"+NODE_ITERATOR_SIG;
    } else { //ac == 2; ac < 1 or as >2  was tested in typeChec()
       // documentF(Object,DTMAxisIterator,String,AbstractTranslet,DOM)
       docParamList = "("+OBJECT_SIG+NODE_ITERATOR_SIG+STRING_SIG
                     +TRANSLET_SIG+DOM_INTF_SIG+")"+NODE_ITERATOR_SIG;
    }
    final int docIdx = cpg.addMethodref(LOAD_DOCUMENT_CLASS, "documentF",
                                        docParamList);


    // The URI can be either a node-set or something else cast to a string
    _arg1.translate(classGen, methodGen);
    if (_arg1Type == Type.NodeSet) {
        _arg1.startIterator(classGen, methodGen);
    }

    if (ac == 2) {
        //_arg2 == null was tested in typeChec()
        _arg2.translate(classGen, methodGen);
        _arg2.startIterator(classGen, methodGen);
    }

    // Feck the rest of the parameters on the stack
    il.append(new PUSH(cpg, getStylesheet().getSystemId()));
    il.append(classGen.loadTranslet());
    il.append(DUP);
    il.append(new GETFIELD(domField));
    il.append(new INVOKESTATIC(docIdx));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:47,代码来源:DocumentCall.java


注:本文中的com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type.NodeSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。