Search in sources :

Example 31 with AnyType

use of org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType in project webtools.sourceediting by eclipse.

the class XSFloat method lt.

/**
 * Comparison between this number and the supplied representation.
 *
 * @param arg
 *            The datatype to compare with
 * @return True if the supplied representation is a greater number than the
 *         one stored. False otherwise
 * @throws DynamicError
 */
public boolean lt(AnyType arg, DynamicContext context) throws DynamicError {
    Item carg = convertArg(arg);
    XSFloat val = (XSFloat) get_single_type(carg, XSFloat.class);
    return float_value() < val.float_value();
}
Also used : Item(org.eclipse.wst.xml.xpath2.api.Item)

Example 32 with AnyType

use of org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType in project webtools.sourceediting by eclipse.

the class XSFloat method eq.

/**
 * Equality comparison between this number and the supplied representation.
 * @param aa
 *            The datatype to compare with
 *
 * @return True if the two representations are of the same number. False
 *         otherwise
 * @throws DynamicError
 */
public boolean eq(AnyType aa, DynamicContext dynamicContext) throws DynamicError {
    Item carg = convertArg(aa);
    if (!(carg instanceof XSFloat))
        DynamicError.throw_type_error();
    XSFloat f = (XSFloat) carg;
    if (nan() && f.nan()) {
        return false;
    }
    Float thatvalue = new Float(f.float_value());
    Float thisvalue = new Float(float_value());
    return thisvalue.equals(thatvalue);
}
Also used : Item(org.eclipse.wst.xml.xpath2.api.Item)

Example 33 with AnyType

use of org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType in project webtools.sourceediting by eclipse.

the class XSFloat method convertResultSequence.

private ResultSequence convertResultSequence(ResultSequence arg) throws DynamicError {
    ResultSequence carg = arg;
    Iterator it = carg.iterator();
    while (it.hasNext()) {
        AnyType type = (AnyType) it.next();
        if (type.string_type().equals("xs:untypedAtomic") || type.string_type().equals("xs:string")) {
            throw DynamicError.throw_type_error();
        }
    }
    carg = constructor(carg);
    return carg;
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) Iterator(java.util.Iterator)

Example 34 with AnyType

use of org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType in project webtools.sourceediting by eclipse.

the class FnSum method sum.

/**
 * Sum operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fn:sum operation.
 */
public static ResultSequence sum(ResultSequence arg, AnyAtomicType zero) throws DynamicError {
    if (arg.empty())
        return ResultSequenceFactory.create_new(zero);
    MathPlus total = null;
    TypePromoter tp = new ScalarTypePromoter();
    tp.considerSequence(arg);
    for (Iterator i = arg.iterator(); i.hasNext(); ) {
        AnyAtomicType conv = tp.promote((AnyType) i.next());
        if (conv == null) {
            conv = zero;
        }
        if (conv instanceof XSDouble && ((XSDouble) conv).nan() || conv instanceof XSFloat && ((XSFloat) conv).nan()) {
            return ResultSequenceFactory.create_new(tp.promote(new XSFloat(Float.NaN)));
        }
        if (total == null) {
            total = (MathPlus) conv;
        } else {
            total = (MathPlus) total.plus(ResultSequenceFactory.create_new(conv)).first();
        }
    }
    return ResultSequenceFactory.create_new((AnyType) total);
}
Also used : XSFloat(org.eclipse.wst.xml.xpath2.processor.internal.types.XSFloat) ScalarTypePromoter(org.eclipse.wst.xml.xpath2.processor.internal.utils.ScalarTypePromoter) XSDouble(org.eclipse.wst.xml.xpath2.processor.internal.types.XSDouble) Iterator(java.util.Iterator) TypePromoter(org.eclipse.wst.xml.xpath2.processor.internal.utils.TypePromoter) ScalarTypePromoter(org.eclipse.wst.xml.xpath2.processor.internal.utils.ScalarTypePromoter) AnyAtomicType(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyAtomicType)

Example 35 with AnyType

use of org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType in project webtools.sourceediting by eclipse.

the class XSDouble method convertResultSequence.

private ResultSequence convertResultSequence(ResultSequence arg) throws DynamicError {
    ResultSequence carg = arg;
    Iterator it = carg.iterator();
    while (it.hasNext()) {
        AnyType type = (AnyType) it.next();
        if (type.string_type().equals("xs:untypedAtomic") || type.string_type().equals("xs:string")) {
            throw DynamicError.throw_type_error();
        }
    }
    carg = constructor(carg);
    return carg;
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) Iterator(java.util.Iterator)

Aggregations

AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)162 ResultSequence (org.eclipse.wst.xml.xpath2.processor.ResultSequence)127 StaticError (org.eclipse.wst.xml.xpath2.processor.StaticError)123 XPathParserException (org.eclipse.wst.xml.xpath2.processor.XPathParserException)123 URL (java.net.URL)122 XSModel (org.apache.xerces.xs.XSModel)121 DynamicError (org.eclipse.wst.xml.xpath2.processor.DynamicError)40 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)38 Iterator (java.util.Iterator)37 Item (org.eclipse.wst.xml.xpath2.api.Item)26 ResultBuffer (org.eclipse.wst.xml.xpath2.api.ResultBuffer)14 NodeType (org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType)14 QName (org.eclipse.wst.xml.xpath2.processor.internal.types.QName)11 AnyAtomicType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyAtomicType)9 XSDouble (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDouble)9 Collection (java.util.Collection)8 XSString (org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)8 ListIterator (java.util.ListIterator)7 ArrayList (java.util.ArrayList)6 NumericType (org.eclipse.wst.xml.xpath2.processor.internal.types.NumericType)6