Search in sources :

Example 6 with SeqType

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

the class FnLang method expected_args.

/**
 * Obtain a list of expected arguments.
 *
 * @return Result of operation.
 */
public static synchronized Collection expected_args() {
    if (_expected_args == null) {
        _expected_args = new ArrayList();
        _expected_args.add(new SeqType(new XSString(), SeqType.OCC_QMARK));
        _expected_args.add(new SeqType(SeqType.OCC_NONE));
    }
    return _expected_args;
}
Also used : SeqType(org.eclipse.wst.xml.xpath2.processor.internal.SeqType) ArrayList(java.util.ArrayList) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)

Example 7 with SeqType

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

the class FnLocalName method expected_args.

/**
 * Obtain a list of expected arguments.
 *
 * @return Result of operation.
 */
public static synchronized Collection expected_args() {
    if (_expected_args == null) {
        _expected_args = new ArrayList();
        SeqType arg = new SeqType(SeqType.OCC_QMARK);
        _expected_args.add(arg);
    }
    return _expected_args;
}
Also used : SeqType(org.eclipse.wst.xml.xpath2.processor.internal.SeqType) ArrayList(java.util.ArrayList)

Example 8 with SeqType

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

the class FnMinutesFromDateTime method expected_args.

/**
 * Obtain a list of expected arguments.
 *
 * @return Result of operation.
 */
public static synchronized Collection expected_args() {
    if (_expected_args == null) {
        _expected_args = new ArrayList();
        _expected_args.add(new SeqType(new XSDateTime(), SeqType.OCC_QMARK));
    }
    return _expected_args;
}
Also used : XSDateTime(org.eclipse.wst.xml.xpath2.processor.internal.types.XSDateTime) SeqType(org.eclipse.wst.xml.xpath2.processor.internal.SeqType) ArrayList(java.util.ArrayList)

Example 9 with SeqType

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

the class Function method convert_argument.

// convert argument according to section 3.1.5 of xpath 2.0 spec
/**
 * Convert the input argument according to section 3.1.5 of specification.
 *
 * @param arg
 *            input argument.
 * @param expected
 *            Expected Sequence type.
 * @throws DynamicError
 *             Dynamic error.
 * @return Converted argument.
 */
public static org.eclipse.wst.xml.xpath2.api.ResultSequence convert_argument(org.eclipse.wst.xml.xpath2.api.ResultSequence arg, SeqType expected) throws DynamicError {
    ResultBuffer result = new ResultBuffer();
    // XXX: Should use type_class instead and use item.getClass().isAssignableTo(expected.type_class())
    AnyType expected_type = expected.type();
    // expected is atomic
    if (expected_type instanceof AnyAtomicType) {
        AnyAtomicType expected_aat = (AnyAtomicType) expected_type;
        // atomize
        org.eclipse.wst.xml.xpath2.api.ResultSequence rs = FnData.atomize(arg);
        // cast untyped to expected type
        for (Iterator i = rs.iterator(); i.hasNext(); ) {
            AnyType item = (AnyType) i.next();
            if (item instanceof XSUntypedAtomic) {
                // create a new item of the expected
                // type initialized with from the string
                // value of the item
                ResultSequence converted = null;
                if (expected_aat instanceof XSString) {
                    XSString strType = new XSString(item.getStringValue());
                    converted = ResultSequenceFactory.create_new(strType);
                } else {
                    converted = ResultSequenceFactory.create_new(item);
                }
                result.concat(converted);
            } else // xs:anyURI promotion to xs:string
            if (item instanceof XSAnyURI && expected_aat instanceof XSString) {
                result.add(new XSString(item.getStringValue()));
            } else // numeric type promotion
            if (item instanceof NumericType) {
                if (expected_aat instanceof XSDouble) {
                    XSDouble doubleType = new XSDouble(item.getStringValue());
                    result.add(doubleType);
                } else {
                    result.add(item);
                }
            } else {
                result.add(item);
            }
        }
        // do sequence type matching on converted arguments
        return expected.match(result.getSequence());
    } else {
        // do sequence type matching on converted arguments
        return expected.match(arg);
    }
}
Also used : NumericType(org.eclipse.wst.xml.xpath2.processor.internal.types.NumericType) ResultBuffer(org.eclipse.wst.xml.xpath2.api.ResultBuffer) XSAnyURI(org.eclipse.wst.xml.xpath2.processor.internal.types.XSAnyURI) XSDouble(org.eclipse.wst.xml.xpath2.processor.internal.types.XSDouble) ResultSequence(org.eclipse.wst.xml.xpath2.processor.ResultSequence) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString) Iterator(java.util.Iterator) AnyAtomicType(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyAtomicType) XSUntypedAtomic(org.eclipse.wst.xml.xpath2.processor.internal.types.XSUntypedAtomic) AnyType(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)

Example 10 with SeqType

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

the class FnAdjustDateTimeToTimeZone method expectedArgs.

/**
 * Obtain a list of expected arguments.
 *
 * @return Result of operation.
 */
public static synchronized Collection expectedArgs() {
    if (_expected_args == null) {
        _expected_args = new ArrayList();
        _expected_args.add(new SeqType(new XSDateTime(), SeqType.OCC_QMARK));
        _expected_args.add(new SeqType(new XSDayTimeDuration(), SeqType.OCC_QMARK));
    }
    return _expected_args;
}
Also used : XSDateTime(org.eclipse.wst.xml.xpath2.processor.internal.types.XSDateTime) SeqType(org.eclipse.wst.xml.xpath2.processor.internal.SeqType) ArrayList(java.util.ArrayList) XSDayTimeDuration(org.eclipse.wst.xml.xpath2.processor.internal.types.XSDayTimeDuration)

Aggregations

SeqType (org.eclipse.wst.xml.xpath2.processor.internal.SeqType)75 ArrayList (java.util.ArrayList)74 XSString (org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)30 XSDateTime (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDateTime)8 XSDate (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDate)6 XSDuration (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDuration)6 XSTime (org.eclipse.wst.xml.xpath2.processor.internal.types.XSTime)6 QName (org.eclipse.wst.xml.xpath2.processor.internal.types.QName)5 XSDayTimeDuration (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDayTimeDuration)3 Collection (java.util.Collection)2 Iterator (java.util.Iterator)2 ResultSequence (org.eclipse.wst.xml.xpath2.processor.ResultSequence)2 AnyAtomicType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyAtomicType)2 AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)2 ElementType (org.eclipse.wst.xml.xpath2.processor.internal.types.ElementType)2 XSDouble (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDouble)2 XSInteger (org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger)2 ResultBuffer (org.eclipse.wst.xml.xpath2.api.ResultBuffer)1 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)1 SequenceType (org.eclipse.wst.xml.xpath2.processor.internal.ast.SequenceType)1