Search in sources :

Example 36 with AnyType

use of org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType 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 37 with AnyType

use of org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType 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)

Example 38 with AnyType

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

the class XSDate method gt.

/**
 * Comparison on this and the supplied dates (taking timezones into account)
 *
 * @param arg
 *            XSDate representation of the date to compare to
 * @throws DynamicError
 * @return True if in time, this date lies after the date supplied. False
 *         otherwise.
 */
public boolean gt(AnyType arg, DynamicContext context) throws DynamicError {
    XSDate val = (XSDate) NumericType.get_single_type((Item) arg, XSDate.class);
    Calendar thiscal = normalizeCalendar(calendar(), tz());
    Calendar thatcal = normalizeCalendar(val.calendar(), val.tz());
    return thiscal.after(thatcal);
}
Also used : Item(org.eclipse.wst.xml.xpath2.api.Item) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Calendar(java.util.Calendar)

Example 39 with AnyType

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

the class XSDate method eq.

// comparisons
/**
 * Equality comparison on this and the supplied dates (taking timezones into
 * account)
 *
 * @param arg
 *            XSDate representation of the date to compare to
 * @throws DynamicError
 * @return True if the two dates are represent the same exact point in time.
 *         False otherwise.
 */
public boolean eq(AnyType arg, DynamicContext dynamicContext) throws DynamicError {
    XSDate val = (XSDate) NumericType.get_single_type((Item) arg, XSDate.class);
    Calendar thiscal = normalizeCalendar(calendar(), tz());
    Calendar thatcal = normalizeCalendar(val.calendar(), val.tz());
    return thiscal.equals(thatcal);
}
Also used : Item(org.eclipse.wst.xml.xpath2.api.Item) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Calendar(java.util.Calendar)

Example 40 with AnyType

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

the class XSInteger method convertArg.

protected Item convertArg(AnyType arg) throws DynamicError {
    ResultSequence rs = ResultSequenceFactory.create_new(arg);
    rs = constructor(rs);
    Item carg = rs.first();
    return carg;
}
Also used : Item(org.eclipse.wst.xml.xpath2.api.Item) ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence)

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