use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSString in project webtools.sourceediting by eclipse.
the class FnCodepointsToString method codepoints_to_string.
/**
* Codepoints to string operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:codepoints-to-string operation.
*/
public static ResultSequence codepoints_to_string(Collection args) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
if (arg1.empty()) {
return new XSString("");
}
int[] codePointArray = new int[arg1.size()];
int codePointIndex = 0;
for (Iterator i = arg1.iterator(); i.hasNext(); ) {
XSInteger code = (XSInteger) i.next();
int codepoint = code.int_value().intValue();
if (codepoint < MIN_LEGAL_CODEPOINT || codepoint > MAX_LEGAL_CODEPOINT) {
throw DynamicError.unsupported_codepoint("U+" + Integer.toString(codepoint, 16).toUpperCase());
}
codePointArray[codePointIndex] = codepoint;
codePointIndex++;
}
try {
String str = UTF16.newString(codePointArray, 0, codePointArray.length);
return new XSString(str);
} catch (IllegalArgumentException iae) {
// This should be duoble checked above, but rather safe than sorry
throw DynamicError.unsupported_codepoint(iae.getMessage());
}
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSString in project webtools.sourceediting by eclipse.
the class FnCompare method compare.
/**
* Compare the arguments.
*
* @param args
* are compared (optional 3rd argument is the collation)
* @param dynamicContext
* Current dynamic context
* @throws DynamicError
* Dynamic error.
* @return The result of the comparison of the arguments.
*/
public static ResultSequence compare(Collection args, DynamicContext context) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
Iterator argiter = cargs.iterator();
ResultSequence arg1 = (ResultSequence) argiter.next();
ResultSequence arg2 = (ResultSequence) argiter.next();
String collationUri = context.getCollationProvider().getDefaultCollation();
if (argiter.hasNext()) {
ResultSequence collArg = (ResultSequence) argiter.next();
collationUri = collArg.first().getStringValue();
}
XSString xstr1 = arg1.empty() ? null : (XSString) arg1.first();
XSString xstr2 = arg2.empty() ? null : (XSString) arg2.first();
BigInteger result = compare_string(collationUri, xstr1, xstr2, context);
if (result != null) {
return ResultSequenceFactory.create_new(new XSInteger(result));
} else {
return ResultSequenceFactory.create_new();
}
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSString in project webtools.sourceediting by eclipse.
the class FnContains 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(arg);
}
return _expected_args;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSString in project webtools.sourceediting by eclipse.
the class FnLang method lang.
/**
* Language operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:lang operation.
*/
public static ResultSequence lang(Collection args, EvaluationContext ec) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
// get arg
Iterator citer = cargs.iterator();
ResultSequence arg1 = (ResultSequence) citer.next();
ResultSequence arg2 = null;
if (cargs.size() == 1) {
if (ec.getContextItem() == null) {
throw DynamicError.contextUndefined();
}
arg2 = (AnyType) ec.getContextItem();
} else {
arg2 = (ResultSequence) citer.next();
}
String lang = "";
if (!arg1.empty()) {
lang = ((XSString) arg1.first()).value();
}
if (!(arg2.first() instanceof NodeType)) {
throw DynamicError.invalidType();
}
NodeType an = (NodeType) arg2.first();
return new XSBoolean(test_lang(an.node_value(), lang));
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSString 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;
}
Aggregations