use of org.eclipse.wst.xml.xpath2.api.Item in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method do_exists.
private XSBoolean do_exists(ListIterator iter, Expr finalexpr) {
// we have more vars to bind...
if (iter.hasNext()) {
VarExprPair ve = (VarExprPair) iter.next();
// evaluate binding sequence
ResultSequence rs = (ResultSequence) ve.expr().accept(this);
QName varname = ve.varname();
try {
for (Iterator i = rs.iterator(); i.hasNext(); ) {
AnyType item = (AnyType) i.next();
pushScope(varname, item);
XSBoolean effbool = do_exists(iter, finalexpr);
popScope();
// out what to do with it
if (effbool.value())
return XSBoolean.TRUE;
}
} finally {
iter.previous();
}
// since none in this sequence evaluated to true, return false
return XSBoolean.FALSE;
} else // we finally got to do the "last expression"
{
return effective_boolean_value((ResultSequence) finalexpr.accept(this));
}
}
use of org.eclipse.wst.xml.xpath2.api.Item in project webtools.sourceediting by eclipse.
the class XSNormalizedString method constructor.
/**
* Creates a new ResultSequence consisting of the extractable String in the
* supplied ResultSequence
*
* @param arg
* The ResultSequence from which to extract the String
* @return New ResultSequence consisting of the supplied String
* @throws DynamicError
*/
public ResultSequence constructor(ResultSequence arg) throws DynamicError {
if (arg.empty())
return ResultBuffer.EMPTY;
Item aat = arg.first();
String srcString = aat.getStringValue();
if (!isSatisfiesConstraints(srcString)) {
// invalid input
DynamicError.throw_type_error();
}
return new XSNormalizedString(srcString);
}
use of org.eclipse.wst.xml.xpath2.api.Item in project webtools.sourceediting by eclipse.
the class XSPositiveInteger method constructor.
/**
* Creates a new ResultSequence consisting of the extractable positiveInteger
* in the supplied ResultSequence
*
* @param arg
* The ResultSequence from which the positiveInteger is to be extracted
* @return New ResultSequence consisting of the 'positiveInteger' supplied
* @throws DynamicError
*/
public ResultSequence constructor(ResultSequence arg) throws DynamicError {
if (arg.empty())
return ResultBuffer.EMPTY;
// the function conversion rules apply here too. Get the argument
// and convert it's string value to a positiveInteger.
Item aat = arg.first();
try {
BigInteger bigInt = new BigInteger(aat.getStringValue());
// doing the range checking
// min value is 1
// max value is INF
BigInteger min = BigInteger.valueOf(1);
if (bigInt.compareTo(min) < 0) {
// invalid input
throw DynamicError.cant_cast(null);
}
return new XSPositiveInteger(bigInt);
} catch (NumberFormatException e) {
throw DynamicError.cant_cast(null);
}
}
use of org.eclipse.wst.xml.xpath2.api.Item in project webtools.sourceediting by eclipse.
the class XSUnsignedInt method constructor.
/**
* Creates a new ResultSequence consisting of the extractable unsignedInt
* in the supplied ResultSequence
*
* @param arg
* The ResultSequence from which the unsignedInt is to be extracted
* @return New ResultSequence consisting of the 'unsignedInt' supplied
* @throws DynamicError
*/
public ResultSequence constructor(ResultSequence arg) throws DynamicError {
if (arg.empty())
return ResultBuffer.EMPTY;
// the function conversion rules apply here too. Get the argument
// and convert it's string value to a unsignedInt.
Item aat = arg.first();
try {
BigInteger bigInt = new BigInteger(aat.getStringValue());
// doing the range checking
// min value is 0
// max value is 4294967295
BigInteger min = BigInteger.valueOf(0);
BigInteger max = BigInteger.valueOf(4294967295L);
if (bigInt.compareTo(min) < 0 || bigInt.compareTo(max) > 0) {
// invalid input
throw DynamicError.cant_cast(null);
}
return new XSUnsignedInt(bigInt);
} catch (NumberFormatException e) {
throw DynamicError.cant_cast(null);
}
}
use of org.eclipse.wst.xml.xpath2.api.Item in project webtools.sourceediting by eclipse.
the class XSUnsignedShort method constructor.
/**
* Creates a new ResultSequence consisting of the extractable unsignedShort
* in the supplied ResultSequence
*
* @param arg
* The ResultSequence from which the unsignedShort is to be extracted
* @return New ResultSequence consisting of the 'unsignedShort' supplied
* @throws DynamicError
*/
public ResultSequence constructor(ResultSequence arg) throws DynamicError {
if (arg.empty())
return ResultBuffer.EMPTY;
// the function conversion rules apply here too. Get the argument
// and convert it's string value to a unsignedShort.
Item aat = arg.first();
try {
BigInteger bigInt = new BigInteger(aat.getStringValue());
// doing the range checking
// min value is 0
// max value is 65535
BigInteger min = BigInteger.valueOf(0);
BigInteger max = BigInteger.valueOf(65535L);
if (bigInt.compareTo(min) < 0 || bigInt.compareTo(max) > 0) {
// invalid input
throw DynamicError.cant_cast(null);
}
return new XSUnsignedShort(bigInt);
} catch (NumberFormatException e) {
throw DynamicError.cant_cast(null);
}
}
Aggregations