Package net.sf.saxon.type

Examples of net.sf.saxon.type.ItemType


        sequence = sequence.analyze(env, contextItemType);

        RoleLocator role = new RoleLocator(RoleLocator.VARIABLE, getVariableName(env.getNamePool()), 0);
        sequence = TypeChecker.staticTypeCheck(
                        sequence, declaration.getRequiredType(), false, role, env);
        ItemType actualItemType = sequence.getItemType();
        declaration.refineTypeInformation(actualItemType,
                        sequence.getCardinality(),
                        (sequence instanceof Value ? (Value)sequence : null),
                        sequence.getSpecialProperties());
View Full Code Here


        operand1 = TypeChecker.staticTypeCheck(operand1, atomicType, backwardsCompatible, role1, env);
        // System.err.println("Second operand"); operand1.display(10);

        Expression e = super.analyze(env, contextItemType);
        if (e instanceof ArithmeticExpression) {
            final ItemType type0 = operand0.getItemType().getPrimitiveItemType();
            final ItemType type1 = operand1.getItemType().getPrimitiveItemType();
            final int action = getAction(type0, operator, type1);
            switch (action) {
                case NUMERIC_ARITHMETIC:
                    e = new NumericArithmetic(operand0, operator, operand1);
                    break;
                case DURATION_ADDITION:
                    e = new DurationAddition(operand0, operator, operand1);
                    break;
                case DURATION_MULTIPLICATION:
                    e = new DurationMultiplication(operand0, operator, operand1);
                    break;
                case DURATION_DIVISION:
                    e = new DurationDivision(operand0, operator, operand1);
                    break;
                case DATE_AND_DURATION:
                    e = new DateAndDuration(operand0, operator, operand1);
                    break;
                case DATE_DIFFERENCE:
                    e = new DateDifference(operand0, operator, operand1);
                    break;
                default:
                    // either the types are not known yet, or they are wrong
                    if (!backwardsCompatible &&
                            Type.isSubType(type0, Type.ANY_ATOMIC_TYPE) &&
                            type0 != Type.UNTYPED_ATOMIC_TYPE &&
                            type0 != Type.ANY_ATOMIC_TYPE &&
                            Type.isSubType(type1, Type.ANY_ATOMIC_TYPE) &&
                            type1 != Type.UNTYPED_ATOMIC_TYPE &&
                            type1 != Type.ANY_ATOMIC_TYPE) {
                        StaticError err = new StaticError("Unsuitable operands for arithmetic operation (" +
                                type0.toString(env.getNamePool()) + ", " +
                                type1.toString(env.getNamePool()) + ')');
                        err.setIsTypeError(true);
                        throw err;
                    }
                    return e;
            }
View Full Code Here

    /**
     * Determine the data type of the expression, if this is known statically
     */

    public ItemType getItemType() {
        final ItemType t1 = operand0.getItemType();
        final ItemType pt1 = t1.getPrimitiveItemType();
        final ItemType t2 = operand1.getItemType();
        final ItemType pt2 = t2.getPrimitiveItemType();
        final Signature[] table = getOperatorTable(operator);
        final int entry = getEntry(table, pt1, pt2);

        if (entry < 0) return Type.ANY_ATOMIC_TYPE;  // type is not known statically

        ItemType resultType = table[entry].resultType;
        if (resultType == Type.NUMBER_TYPE) {
            resultType = NumericValue.promote(pt1, pt2);
            // exception: integer div integer => decimal
            if (operator == Token.DIV && resultType == Type.INTEGER_TYPE) {
                resultType = Type.DECIMAL_TYPE;
View Full Code Here

    * Determine the data type of the items returned by this expression
    * @return the data type
    */

    public final ItemType getItemType() {
        final ItemType t1 = operand0.getItemType();
        final ItemType t2 = operand1.getItemType();
        return Type.getCommonSuperType(t1, t2);
    }
View Full Code Here

    public void refineTypeInformation(ItemType type, int cardinality,
                                      Value constantValue, int properties) {
        for (Iterator iter=references.iterator(); iter.hasNext();) {
            BindingReference ref = (BindingReference)iter.next();
            if (ref instanceof VariableReference) {
                ItemType oldItemType = ((VariableReference)ref).getItemType();
                ItemType newItemType = oldItemType;
                if (Type.isSubType(type, oldItemType)) {
                    newItemType = type;
                }
                int newcard = cardinality & ((VariableReference)ref).getCardinality();
                if (newcard==0) {
View Full Code Here

    * Determine the data type of the items returned by this expression
    * @return the data type
    */

    public final ItemType getItemType() {
        ItemType t1 = operand0.getItemType();
        ItemType t2 = operand1.getItemType();
        return Type.getCommonSuperType(t1, t2);
    }
View Full Code Here

            new SequenceType(decl.getPrimaryType(),
                             StaticProperty.ALLOWS_ZERO_OR_MORE);
        RoleLocator role = new RoleLocator(RoleLocator.VARIABLE, getVariableName(env.getNamePool()), 0);
        sequence = TypeChecker.staticTypeCheck(
                                sequence, sequenceType, false, role, env);
        ItemType actualItemType = sequence.getItemType();
        declaration.refineTypeInformation(actualItemType,
                StaticProperty.EXACTLY_ONE,
                null,
                sequence.getSpecialProperties());
View Full Code Here

                            new SequenceType(decl.getPrimaryType(),
                                             StaticProperty.ALLOWS_ZERO_OR_MORE);
        RoleLocator role = new RoleLocator(RoleLocator.VARIABLE, getVariableName(env.getNamePool()), 0);
        sequence = TypeChecker.staticTypeCheck(
                                sequence, sequenceType, false, role, env);
        ItemType actualItemType = sequence.getItemType();
        declaration.refineTypeInformation(actualItemType,
                StaticProperty.EXACTLY_ONE,
                null,
                sequence.getSpecialProperties());
View Full Code Here

    /**
    * Determine whether an expression, when used as a filter, is positional
    */

    private static boolean isPositionalFilter(Expression exp) {
        ItemType type = exp.getItemType();
        return ( type==Type.ANY_ATOMIC_TYPE ||
                 type instanceof AnyItemType ||
                 Type.isSubType(type, Type.NUMBER_TYPE) ||
                 isExplicitlyPositional(exp));
    }
View Full Code Here

    public Expression analyze(StaticContext env, ItemType contextItemType) throws XPathException {
        operand = operand.analyze(env, contextItemType);
        // When analyze is called a second time, we might have more information...

        ItemType supplied = operand.getItemType();
        int relation = Type.relationship(requiredItemType, supplied);
        if (relation == Type.SAME_TYPE || relation == Type.SUBSUMES) {
            return operand;
        }
        //ItemType supplied = operand.getItemType();
View Full Code Here

TOP

Related Classes of net.sf.saxon.type.ItemType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.