Search in sources :

Example 6 with XSSimpleTypeDefinition

use of org.apache.xerces.xs.XSSimpleTypeDefinition 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()));
}
Also used : Item(org.eclipse.wst.xml.xpath2.api.Item) ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) BigInteger(java.math.BigInteger) XSSimpleTypeDefinition(org.apache.xerces.xs.XSSimpleTypeDefinition)

Aggregations

XSSimpleTypeDefinition (org.apache.xerces.xs.XSSimpleTypeDefinition)6 XSObjectList (org.apache.xerces.xs.XSObjectList)3 XSAttributeDeclaration (org.apache.xerces.xs.XSAttributeDeclaration)2 XSAttributeUse (org.apache.xerces.xs.XSAttributeUse)2 XSTypeDefinition (org.apache.xerces.xs.XSTypeDefinition)2 BigInteger (java.math.BigInteger)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 XSNamedMap (org.apache.xerces.xs.XSNamedMap)1 XSObject (org.apache.xerces.xs.XSObject)1 Item (org.eclipse.wst.xml.xpath2.api.Item)1 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)1 ResultSequence (org.eclipse.wst.xml.xpath2.processor.ResultSequence)1 AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)1 UserDefinedCtrLibrary (org.eclipse.wst.xml.xpath2.processor.internal.types.userdefined.UserDefinedCtrLibrary)1 XercesFloatUserDefined (org.eclipse.wst.xml.xpath2.processor.testsuite.userdefined.XercesFloatUserDefined)1 XercesIntegerUserDefined (org.eclipse.wst.xml.xpath2.processor.testsuite.userdefined.XercesIntegerUserDefined)1 XercesQNameUserDefined (org.eclipse.wst.xml.xpath2.processor.testsuite.userdefined.XercesQNameUserDefined)1 XercesUserDefined (org.eclipse.wst.xml.xpath2.processor.testsuite.userdefined.XercesUserDefined)1 AttributesImpl (org.xml.sax.helpers.AttributesImpl)1