use of org.eclipse.wst.xml.xpath2.processor.internal.types.AnyAtomicType in project webtools.sourceediting by eclipse.
the class XercesIntegerUserDefined method constructor.
public ResultSequence constructor(ResultSequence arg) throws DynamicError {
ResultSequence rs = ResultSequenceFactory.create_new();
if (arg.empty())
return rs;
// AnyAtomicType aat = (AnyAtomicType) arg.first();
Item aat = arg.first();
XSSimpleTypeDefinition simpletype = (XSSimpleTypeDefinition) typeInfo;
if (simpletype != null) {
if (simpletype.isDefinedFacet(XSSimpleTypeDefinition.FACET_MININCLUSIVE)) {
String minValue = simpletype.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MININCLUSIVE);
int iminValue = Integer.parseInt(minValue);
int actualValue = Integer.parseInt(aat.getStringValue());
if (actualValue < iminValue) {
throw DynamicError.invalidForCastConstructor();
}
}
if (simpletype.isDefinedFacet(XSSimpleTypeDefinition.FACET_MAXINCLUSIVE)) {
String maxValue = simpletype.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MAXINCLUSIVE);
int imaxValue = Integer.parseInt(maxValue);
int actualValue = Integer.parseInt(aat.getStringValue());
if (actualValue > imaxValue) {
throw DynamicError.invalidForCastConstructor();
}
}
}
return new XercesIntegerUserDefined(new BigInteger(aat.getStringValue()));
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.AnyAtomicType in project webtools.sourceediting by eclipse.
the class FnSum method evaluate.
/**
* Evaluate arguments.
*
* @param args
* argument expressions.
* @throws DynamicError
* Dynamic error.
* @return Result of evaluation.
*/
public ResultSequence evaluate(Collection args, org.eclipse.wst.xml.xpath2.api.EvaluationContext ec) throws DynamicError {
Iterator argIterator = args.iterator();
ResultSequence argSequence = (ResultSequence) argIterator.next();
AnyAtomicType zero = ZERO;
if (argIterator.hasNext()) {
ResultSequence zeroSequence = (ResultSequence) argIterator.next();
if (zeroSequence.size() != 1)
throw new DynamicError(TypeError.invalid_type(null));
if (!(zeroSequence.first() instanceof AnyAtomicType))
throw new DynamicError(TypeError.invalid_type(zeroSequence.first().getStringValue()));
zero = (AnyAtomicType) zeroSequence.first();
}
return sum(argSequence, zero);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.AnyAtomicType in project webtools.sourceediting by eclipse.
the class NodeType method getXDMTypedValue.
// getTypedValueForPrimitiveType
/*
* Construct the "typed value" from a "string value", given the simpleType of the node.
*/
protected ResultSequence getXDMTypedValue(TypeDefinition typeDef, List itemValTypes) {
if ("anySimpleType".equals(typeDef.getName()) || "anyAtomicType".equals(typeDef.getName())) {
return new XSUntypedAtomic(getStringValue());
} else {
SimpleTypeDefinition simpType = null;
if (typeDef instanceof ComplexTypeDefinition) {
ComplexTypeDefinition complexTypeDefinition = (ComplexTypeDefinition) typeDef;
simpType = complexTypeDefinition.getSimpleType();
if (simpType != null) {
// element has a complexType with a simple content
return getTypedValueForSimpleContent(simpType, itemValTypes);
} else {
// element has a complexType with complex content
return new XSUntypedAtomic(getStringValue());
}
} else {
// element has a simpleType
simpType = (SimpleTypeDefinition) typeDef;
return getTypedValueForSimpleContent(simpType, itemValTypes);
}
}
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.AnyAtomicType 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();
}
Aggregations