Search in sources :

Example 56 with XSString

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

the class FnSubstring method expected_args.

/**
 * Calculate the expected arguments.
 *
 * @return The expected arguments.
 */
public static Collection expected_args(Collection actualArgs) {
    Collection _expected_args = new ArrayList();
    _expected_args.add(new SeqType(new XSString(), SeqType.OCC_QMARK));
    _expected_args.add(new SeqType(new XSDouble(), SeqType.OCC_NONE));
    // for arity 3
    if (actualArgs.size() == 3) {
        _expected_args.add(new SeqType(new XSDouble(), SeqType.OCC_NONE));
    }
    return _expected_args;
}
Also used : XSDouble(org.eclipse.wst.xml.xpath2.processor.internal.types.XSDouble) SeqType(org.eclipse.wst.xml.xpath2.processor.internal.SeqType) ArrayList(java.util.ArrayList) Collection(java.util.Collection) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)

Example 57 with XSString

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

the class FnSubstringBefore method substring_before.

/**
 * Substring-Before operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fn:substring-before operation.
 */
public static ResultSequence substring_before(Collection args) throws DynamicError {
    Collection cargs = Function.convert_arguments(args, expected_args());
    // get args
    Iterator argiter = cargs.iterator();
    ResultSequence arg1 = (ResultSequence) argiter.next();
    String str1 = "";
    String str2 = "";
    if (!arg1.empty()) {
        str1 = ((XSString) arg1.first()).value();
    }
    ResultSequence arg2 = (ResultSequence) argiter.next();
    if (!arg2.empty()) {
        str2 = ((XSString) arg2.first()).value();
    }
    int str2len = str2.length();
    if (str2len == 0) {
        return new XSString("");
    }
    int index = str1.indexOf(str2);
    if (index == -1) {
        return new XSString("");
    }
    return new XSString(str1.substring(0, index));
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) Iterator(java.util.Iterator) Collection(java.util.Collection) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)

Example 58 with XSString

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

the class FnUpperCase method expected_args.

/**
 * Calculate the expected arguments.
 *
 * @return The expected arguments.
 */
public static synchronized Collection expected_args() {
    if (_expected_args == null) {
        _expected_args = new ArrayList();
        _expected_args.add(new SeqType(new XSString(), SeqType.OCC_QMARK));
    }
    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 59 with XSString

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

the class FnUpperCase method upper_case.

/**
 * Convert arguments to upper case.
 *
 * @param args
 *            are converted to upper case.
 * @throws DynamicError
 *             Dynamic error.
 * @return The result of converting the arguments to upper case.
 */
public static ResultSequence upper_case(Collection args) throws DynamicError {
    Collection cargs = Function.convert_arguments(args, expected_args());
    ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
    if (arg1.empty()) {
        return new XSString("");
    }
    String str = ((XSString) arg1.first()).value();
    return new XSString(str.toUpperCase());
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) Collection(java.util.Collection) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)

Example 60 with XSString

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

the class FnResolveQName 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(new XSString(), SeqType.OCC_QMARK);
        _expected_args.add(arg);
        _expected_args.add(new SeqType(new ElementType(), SeqType.OCC_NONE));
    }
    return _expected_args;
}
Also used : ElementType(org.eclipse.wst.xml.xpath2.processor.internal.types.ElementType) SeqType(org.eclipse.wst.xml.xpath2.processor.internal.SeqType) ArrayList(java.util.ArrayList) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)

Aggregations

XSString (org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)73 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)37 ArrayList (java.util.ArrayList)32 Collection (java.util.Collection)32 Iterator (java.util.Iterator)29 SeqType (org.eclipse.wst.xml.xpath2.processor.internal.SeqType)29 ResultBuffer (org.eclipse.wst.xml.xpath2.api.ResultBuffer)9 Item (org.eclipse.wst.xml.xpath2.api.Item)7 QName (org.eclipse.wst.xml.xpath2.processor.internal.types.QName)7 AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)6 XSInteger (org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger)6 ResultSequence (org.eclipse.wst.xml.xpath2.processor.ResultSequence)5 AnyAtomicType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyAtomicType)5 NumericType (org.eclipse.wst.xml.xpath2.processor.internal.types.NumericType)5 XSBoolean (org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean)5 XSDouble (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDouble)5 DynamicError (org.eclipse.wst.xml.xpath2.processor.DynamicError)4 XSUntypedAtomic (org.eclipse.wst.xml.xpath2.processor.internal.types.XSUntypedAtomic)4 URL (java.net.URL)3 PatternSyntaxException (java.util.regex.PatternSyntaxException)3