Search in sources :

Example 1 with CtrType

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

the class ConstructorFL method add_type.

/**
 * Adds a type into the functions library.
 *
 * @param at
 *            input of any atomic type.
 */
public void add_type(CtrType at) {
    QName name = new QName(at.type_name());
    name.set_namespace(namespace());
    _types.put(name, at);
    add_function(new Constructor(at));
}
Also used : QName(org.eclipse.wst.xml.xpath2.processor.internal.types.QName)

Example 2 with CtrType

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

the class FsConvertOperand method convert_operand.

/**
 * Convert-Operand operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fs: operation.
 */
public static ResultSequence convert_operand(Collection args) throws DynamicError {
    assert args.size() == 2;
    Iterator iter = args.iterator();
    ResultSequence actual = (ResultSequence) iter.next();
    ResultSequence expected = (ResultSequence) iter.next();
    if (expected.size() != 1)
        DynamicError.throw_type_error();
    Item at = expected.first();
    if (!(at instanceof AnyAtomicType))
        DynamicError.throw_type_error();
    AnyAtomicType exp_aat = (AnyAtomicType) at;
    ResultBuffer result = new ResultBuffer();
    // 1
    if (actual.empty())
        return result.getSequence();
    // convert sequence
    for (Iterator i = actual.iterator(); i.hasNext(); ) {
        AnyType item = (AnyType) i.next();
        // 2
        if (item instanceof XSUntypedAtomic) {
            // a
            if (exp_aat instanceof XSUntypedAtomic)
                result.add(new XSString(item.getStringValue()));
            else // b
            if (exp_aat instanceof NumericType)
                result.add(new XSDouble(item.getStringValue()));
            else // c
            {
                assert exp_aat instanceof CtrType;
                CtrType cons = (CtrType) exp_aat;
                result.concat(cons.constructor(new XSString(item.getStringValue())));
            }
        } else
            // 4
            result.add(item);
    }
    return result.getSequence();
}
Also used : NumericType(org.eclipse.wst.xml.xpath2.processor.internal.types.NumericType) Item(org.eclipse.wst.xml.xpath2.api.Item) ResultBuffer(org.eclipse.wst.xml.xpath2.api.ResultBuffer) XSDouble(org.eclipse.wst.xml.xpath2.processor.internal.types.XSDouble) ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) Iterator(java.util.Iterator) CtrType(org.eclipse.wst.xml.xpath2.processor.internal.types.CtrType) AnyAtomicType(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyAtomicType) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString) XSUntypedAtomic(org.eclipse.wst.xml.xpath2.processor.internal.types.XSUntypedAtomic) AnyType(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)

Aggregations

Iterator (java.util.Iterator)1 Item (org.eclipse.wst.xml.xpath2.api.Item)1 ResultBuffer (org.eclipse.wst.xml.xpath2.api.ResultBuffer)1 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)1 AnyAtomicType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyAtomicType)1 AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)1 CtrType (org.eclipse.wst.xml.xpath2.processor.internal.types.CtrType)1 NumericType (org.eclipse.wst.xml.xpath2.processor.internal.types.NumericType)1 QName (org.eclipse.wst.xml.xpath2.processor.internal.types.QName)1 XSDouble (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDouble)1 XSString (org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)1 XSUntypedAtomic (org.eclipse.wst.xml.xpath2.processor.internal.types.XSUntypedAtomic)1