Search in sources :

Example 21 with Item

use of org.eclipse.wst.xml.xpath2.api.Item in project webtools.sourceediting by eclipse.

the class XSDecimal method lt.

/**
 * Comparison between this number and the supplied representation.
 *
 * @param arg
 *            Representation to be compared with (must currently be of type
 *            XSDecimal)
 * @return True if the supplied type represents a number greater than this
 *         one stored. False otherwise
 */
public boolean lt(AnyType arg, DynamicContext context) throws DynamicError {
    Item carg = convertArg(arg);
    XSDecimal val = (XSDecimal) get_single_type(carg, XSDecimal.class);
    return (_value.compareTo(val.getValue()) == -1);
}
Also used : Item(org.eclipse.wst.xml.xpath2.api.Item)

Example 22 with Item

use of org.eclipse.wst.xml.xpath2.api.Item 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 23 with Item

use of org.eclipse.wst.xml.xpath2.api.Item in project webtools.sourceediting by eclipse.

the class XSFloat method plus.

/**
 * Mathematical addition operator between this XSFloat and the supplied
 * ResultSequence.
 *
 * @param arg
 *            The ResultSequence to perform an addition with
 * @return A XSFloat consisting of the result of the mathematical addition.
 */
public ResultSequence plus(ResultSequence arg) throws DynamicError {
    ResultSequence carg = convertResultSequence(arg);
    Item at = get_single_arg(carg);
    if (!(at instanceof XSFloat))
        DynamicError.throw_type_error();
    XSFloat val = (XSFloat) at;
    return ResultSequenceFactory.create_new(new XSFloat(float_value() + val.float_value()));
}
Also used : Item(org.eclipse.wst.xml.xpath2.api.Item) ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence)

Example 24 with Item

use of org.eclipse.wst.xml.xpath2.api.Item 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 25 with Item

use of org.eclipse.wst.xml.xpath2.api.Item in project webtools.sourceediting by eclipse.

the class FnString method string.

/**
 * String operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fn:string operation.
 */
public static ResultSequence string(Collection args, EvaluationContext ec) throws DynamicError {
    assert (args.size() == 0 || args.size() == 1);
    ResultSequence arg1 = null;
    if (args.isEmpty()) {
        // support for arity = 0
        return getResultSetForArityZero(ec);
    } else {
        arg1 = (ResultSequence) args.iterator().next();
    }
    // sanity check args
    if (arg1.size() > 1)
        throw new DynamicError(TypeError.invalid_type(null));
    ResultBuffer rs = new ResultBuffer();
    if (arg1.empty()) {
        rs.add(new XSString(""));
    } else {
        Item at = arg1.first();
        rs.add(new XSString(at.getStringValue()));
    }
    return rs.getSequence();
}
Also used : Item(org.eclipse.wst.xml.xpath2.api.Item) ResultBuffer(org.eclipse.wst.xml.xpath2.api.ResultBuffer) ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString) DynamicError(org.eclipse.wst.xml.xpath2.processor.DynamicError)

Aggregations

DynamicError (org.eclipse.wst.xml.xpath2.processor.DynamicError)71 Item (org.eclipse.wst.xml.xpath2.api.Item)69 ResultSequence (org.eclipse.wst.xml.xpath2.processor.ResultSequence)66 XPathParserException (org.eclipse.wst.xml.xpath2.processor.XPathParserException)65 URL (java.net.URL)64 XSModel (org.apache.xerces.xs.XSModel)64 StaticError (org.eclipse.wst.xml.xpath2.processor.StaticError)64 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)46 AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)34 Iterator (java.util.Iterator)26 ResultBuffer (org.eclipse.wst.xml.xpath2.api.ResultBuffer)14 BigInteger (java.math.BigInteger)13 Collection (java.util.Collection)13 XSString (org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)11 ListIterator (java.util.ListIterator)8 NodeType (org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType)8 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)6 NumericType (org.eclipse.wst.xml.xpath2.processor.internal.types.NumericType)5 ArrayList (java.util.ArrayList)4 GregorianCalendar (java.util.GregorianCalendar)4