Search in sources :

Example 11 with DynamicContext

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

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

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

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

the class XSDouble method gt.

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

Example 15 with DynamicContext

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

the class FsEq method do_cmp_general_op.

// voodoo 3
/**
 * Actual equality operation for fs_eq_general.
 *
 * @param args
 *            input arguments.
 * @param type
 *            type of the arguments.
 * @param mname
 *            Method name for template simulation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of the operation.
 */
public static ResultSequence do_cmp_general_op(Collection args, Class type, String mname, DynamicContext dc) throws DynamicError {
    // do the voodoo
    Method comparator = null;
    try {
        Class[] margsdef = { Collection.class, DynamicContext.class };
        comparator = type.getMethod(mname, margsdef);
    } catch (NoSuchMethodException err) {
        throw new RuntimeException("Can�'t find method : " + mname, err);
    }
    // sanity check args and get them
    if (args.size() != 2)
        DynamicError.throw_type_error();
    Iterator argiter = args.iterator();
    org.eclipse.wst.xml.xpath2.api.ResultSequence one = (org.eclipse.wst.xml.xpath2.api.ResultSequence) argiter.next();
    org.eclipse.wst.xml.xpath2.api.ResultSequence two = (org.eclipse.wst.xml.xpath2.api.ResultSequence) argiter.next();
    // XXX ?
    if (one.empty() || two.empty())
        return ResultSequenceFactory.create_new(new XSBoolean(false));
    // atomize
    one = FnData.atomize(one);
    two = FnData.atomize(two);
    // we gotta find a pair that satisfied the condition
    for (Iterator i = one.iterator(); i.hasNext(); ) {
        AnyType a = (AnyType) i.next();
        for (Iterator j = two.iterator(); j.hasNext(); ) {
            AnyType b = (AnyType) j.next();
            if (do_general_pair(a, b, comparator, dc))
                return ResultSequenceFactory.create_new(new XSBoolean(true));
        }
    }
    return ResultSequenceFactory.create_new(new XSBoolean(false));
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) Method(java.lang.reflect.Method) XSBoolean(org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean) Iterator(java.util.Iterator) AnyType(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)

Aggregations

XPath (org.eclipse.wst.xml.xpath2.processor.ast.XPath)77 DynamicContext (org.eclipse.wst.xml.xpath2.processor.DynamicContext)75 DynamicError (org.eclipse.wst.xml.xpath2.processor.DynamicError)75 URL (java.net.URL)73 DefaultEvaluator (org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator)73 Evaluator (org.eclipse.wst.xml.xpath2.processor.Evaluator)73 ResultSequence (org.eclipse.wst.xml.xpath2.processor.ResultSequence)73 StaticError (org.eclipse.wst.xml.xpath2.processor.StaticError)72 XPathParserException (org.eclipse.wst.xml.xpath2.processor.XPathParserException)72 XSModel (org.apache.xerces.xs.XSModel)69 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)20 Item (org.eclipse.wst.xml.xpath2.api.Item)17 Iterator (java.util.Iterator)13 AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)11 Collection (java.util.Collection)10 XSBoolean (org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean)8 XSString (org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)8 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)6 XSDayTimeDuration (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDayTimeDuration)6 Duration (javax.xml.datatype.Duration)5