Package org.apache.xmlbeans

Examples of org.apache.xmlbeans.XmlAnySimpleType


                            continue;
                        }
                        boolean ismin = (code == SchemaType.FACET_MIN_EXCLUSIVE || code == SchemaType.FACET_MIN_INCLUSIVE);
                        boolean isexclusive = (code == SchemaType.FACET_MIN_EXCLUSIVE || code == SchemaType.FACET_MAX_EXCLUSIVE);

                        XmlAnySimpleType limit;
                        try
                        {
                            limit = baseImpl.newValue(facet.getValue());
                        }
                        catch (XmlValueOutOfRangeException e)
                        {
                            // note: this guarantees that the limit is a valid number in the
                            // base data type!!
                            state.error("Must be valid value in base type", XmlErrorContext.FACET_VALUE_MALFORMED, facet);

                            // BUGBUG: if there are actual schemas that redefine min/maxExclusive,
                            // they will need this rule relaxed for them!!
                            continue;
                        }
                        if (fixedFacets[code] && !myFacets[code].valueEquals(limit))
                        {
                            state.error("This facet is fixed and cannot be overridden", XmlErrorContext.FACET_FIXED, facet);
                            continue;
                        }
                        if (myFacets[code] != null)
                        {
                            int comparison = limit.compareValue(myFacets[code]);
                            if (comparison == 2 || comparison == (ismin ? -1 : 1))
                            {
                                state.error(ismin ?
                                        (isexclusive ?
                                            "Must be greater than or equal to previous minExclusive" :
View Full Code Here


                    if (type.getFacet(i) != null)
                        facetCount++;
                writeShort(facetCount);
                for (int i = 0; i <= SchemaType.LAST_FACET; i++)
                {
                    XmlAnySimpleType facet = type.getFacet(i);
                    if (facet != null)
                    {
                        writeShort(i);
                        writeXmlValueObject(facet);
                        writeShort(type.isFacetFixed(i) ? 1 : 0);
View Full Code Here

                        }
                        if (myFacets[SchemaType.FACET_MIN_LENGTH] != null)
                        {
                            // An error for 'length' and 'minLength' to be specified at the same time
                            // except if the base type had the same value for 'minLength' also
                            XmlAnySimpleType baseMinLength = baseImpl.getFacet(SchemaType.FACET_MIN_LENGTH);
                            if (!(baseMinLength != null &&
                                baseMinLength.valueEquals(myFacets[SchemaType.FACET_MIN_LENGTH]) &&
                                baseMinLength.compareValue(len) <= 0))
                            {
                                state.error(XmlErrorCodes.DATATYPE_LENGTH, null, facet);
                                continue;
                            }
                        }
                        if (myFacets[SchemaType.FACET_MAX_LENGTH] != null)
                        {
                            // An error for 'length' and 'maxLength' to be specified at the same time
                            // except if the base type had the same value for 'maxLength' also
                            XmlAnySimpleType baseMaxLength = baseImpl.getFacet(SchemaType.FACET_MAX_LENGTH);
                            if (!(baseMaxLength != null &&
                                baseMaxLength.valueEquals(myFacets[SchemaType.FACET_MAX_LENGTH]) &&
                                baseMaxLength.compareValue(len) >= 0))
                            {
                                state.error(XmlErrorCodes.DATATYPE_LENGTH, null, facet);
                                continue;
                            }
                        }
                        myFacets[code] = len;
                        break;

                    case SchemaType.FACET_MIN_LENGTH:
                    case SchemaType.FACET_MAX_LENGTH:
                        XmlInteger mlen = StscTranslator.buildNnInteger(facet.getValue());
                        if (mlen == null)
                        {
                            state.error("Must be a nonnegative integer", XmlErrorCodes.FACET_VALUE_MALFORMED, facet);
                            continue;
                        }
                        if (fixedFacets[code] && !myFacets[code].valueEquals(mlen))
                        {
                            state.error(XmlErrorCodes.FACET_FIXED, new Object[] { facetName }, facet);
                            continue;
                        }
                        if (myFacets[SchemaType.FACET_LENGTH] != null)
                        {
                            // It's an error for 'length' and 'minLength'/'maxLength' to be
                            // specified at the same time, except for the case when
                            // the base type had the same value for 'minLength'/'maxLength'
                            // and the two values are consistent
                            XmlAnySimpleType baseMinMaxLength = baseImpl.getFacet(code);
                            if (!(baseMinMaxLength != null &&
                                baseMinMaxLength.valueEquals(mlen) &&
                                (code == SchemaType.FACET_MIN_LENGTH ?
                                    baseMinMaxLength.compareTo(myFacets[SchemaType.FACET_LENGTH]) <= 0 :
                                    baseMinMaxLength.compareTo(myFacets[SchemaType.FACET_LENGTH]) >= 0)))
                            {
                                state.error(XmlErrorCodes.DATATYPE_LENGTH, null, facet);
                                continue;
                            }
                        }
                        if (myFacets[SchemaType.FACET_MAX_LENGTH] != null)
                        {
                            if (mlen.compareValue(myFacets[SchemaType.FACET_MAX_LENGTH]) > 0)
                            {
                                state.error(XmlErrorCodes.DATATYPE_MAX_LENGTH_RESTRICTION, null, facet);
                                continue;
                            }
                        }
                        if (myFacets[SchemaType.FACET_MIN_LENGTH] != null)
                        {
                            if (mlen.compareValue(myFacets[SchemaType.FACET_MIN_LENGTH]) < 0)
                            {
                                state.error(XmlErrorCodes.DATATYPE_MIN_LENGTH_RESTRICTION, null, facet);
                                continue;
                            }
                        }
                        myFacets[code] = mlen;
                        break;

                    case SchemaType.FACET_TOTAL_DIGITS:
                        XmlPositiveInteger dig = StscTranslator.buildPosInteger(facet.getValue());
                        if (dig == null)
                        {
                            state.error("Must be a positive integer", XmlErrorCodes.FACET_VALUE_MALFORMED, facet);
                            break;
                        }
                        if (fixedFacets[code] && !myFacets[code].valueEquals(dig))
                        {
                            state.error(XmlErrorCodes.FACET_FIXED, new Object[] { facetName }, facet);
                            continue;
                        }
                        if (myFacets[SchemaType.FACET_TOTAL_DIGITS] != null)
                        {
                            if (dig.compareValue(myFacets[SchemaType.FACET_TOTAL_DIGITS]) > 0)
                                state.error(XmlErrorCodes.DATATYPE_TOTAL_DIGITS_RESTRICTION, null, facet);
                        }
                        myFacets[code] = dig;
                        break;

                    case SchemaType.FACET_FRACTION_DIGITS:
                        XmlNonNegativeInteger fdig = StscTranslator.buildNnInteger(facet.getValue());
                        if (fdig == null)
                        {
                            state.error("Must be a nonnegative integer", XmlErrorCodes.FACET_VALUE_MALFORMED, facet);
                            break;
                        }
                        if (fixedFacets[code] && !myFacets[code].valueEquals(fdig))
                        {
                            state.error(XmlErrorCodes.FACET_FIXED, new Object[] { facetName }, facet);
                            continue;
                        }
                        if (myFacets[SchemaType.FACET_FRACTION_DIGITS] != null)
                        {
                            if (fdig.compareValue(myFacets[SchemaType.FACET_FRACTION_DIGITS]) > 0)
                                state.error(XmlErrorCodes.DATATYPE_FRACTION_DIGITS_RESTRICTION, null, facet);
                        }
                        if (myFacets[SchemaType.FACET_TOTAL_DIGITS] != null)
                        {
                            if (fdig.compareValue(myFacets[SchemaType.FACET_TOTAL_DIGITS]) > 0)
                                state.error(XmlErrorCodes.DATATYPE_FRACTION_DIGITS_LE_TOTAL_DIGITS, null, facet);
                        }
                        myFacets[code] = fdig;
                        break;

                    case SchemaType.FACET_MIN_EXCLUSIVE:
                    case SchemaType.FACET_MIN_INCLUSIVE:
                    case SchemaType.FACET_MAX_INCLUSIVE:
                    case SchemaType.FACET_MAX_EXCLUSIVE:

                        if (seenFacet[other_similar_limit(code)])
                        {
                            state.error("Cannot define both inclusive and exclusive limit in the same restriciton", XmlErrorCodes.FACET_DUPLICATED, facet);
                            continue;
                        }
                        boolean ismin = (code == SchemaType.FACET_MIN_EXCLUSIVE || code == SchemaType.FACET_MIN_INCLUSIVE);
                        boolean isexclusive = (code == SchemaType.FACET_MIN_EXCLUSIVE || code == SchemaType.FACET_MAX_EXCLUSIVE);

                        XmlAnySimpleType limit;
                        try
                        {
                            limit = baseImpl.newValue(facet.getValue(), true);
                        }
                        catch (XmlValueOutOfRangeException e)
                        {
                            // note: this guarantees that the limit is a valid number in the
                            // base data type!!
                            switch (code)
                            {
                            case SchemaType.FACET_MIN_EXCLUSIVE:
                                state.error(XmlErrorCodes.DATATYPE_MIN_EXCLUSIVE_RESTRICTION,
                                    new Object[] {e.getMessage()}, facet);
                                break;
                            case SchemaType.FACET_MIN_INCLUSIVE:
                                state.error(XmlErrorCodes.DATATYPE_MIN_INCLUSIVE_RESTRICTION,
                                    new Object[] {e.getMessage()}, facet);
                                break;
                            case SchemaType.FACET_MAX_INCLUSIVE:
                                state.error(XmlErrorCodes.DATATYPE_MAX_INCLUSIVE_RESTRICTION,
                                    new Object[] {e.getMessage()}, facet);
                                break;
                            case SchemaType.FACET_MAX_EXCLUSIVE:
                                state.error(XmlErrorCodes.DATATYPE_MAX_EXCLUSIVE_RESTRICTION,
                                    new Object[] {e.getMessage()}, facet);
                                break;
                            }

                            // BUGBUG: if there are actual schemas that redefine min/maxExclusive,
                            // they will need this rule relaxed for them!!
                            continue;
                        }
                        if (fixedFacets[code] && !myFacets[code].valueEquals(limit))
                        {
                            state.error(XmlErrorCodes.FACET_FIXED, new Object[] { facetName }, facet);
                            continue;
                        }
                        if (myFacets[code] != null)
                        {
                            int comparison = limit.compareValue(myFacets[code]);
                            if (comparison == 2 || comparison == (ismin ? -1 : 1))
                            {
                                state.error(ismin ?
                                        (isexclusive ?
                                            "Must be greater than or equal to previous minExclusive" :
View Full Code Here

                        }
                        if (myFacets[SchemaType.FACET_MIN_LENGTH] != null)
                        {
                            // An error for 'length' and 'minLength' to be specified at the same time
                            // except if the base type had the same value for 'minLength' also
                            XmlAnySimpleType baseMinLength = baseImpl.getFacet(SchemaType.FACET_MIN_LENGTH);
                            if (!(baseMinLength != null &&
                                baseMinLength.valueEquals(myFacets[SchemaType.FACET_MIN_LENGTH]) &&
                                baseMinLength.compareValue(len) <= 0))
                            {
                                state.error(XmlErrorCodes.DATATYPE_LENGTH, null, facet);
                                continue;
                            }
                        }
                        if (myFacets[SchemaType.FACET_MAX_LENGTH] != null)
                        {
                            // An error for 'length' and 'maxLength' to be specified at the same time
                            // except if the base type had the same value for 'maxLength' also
                            XmlAnySimpleType baseMaxLength = baseImpl.getFacet(SchemaType.FACET_MAX_LENGTH);
                            if (!(baseMaxLength != null &&
                                baseMaxLength.valueEquals(myFacets[SchemaType.FACET_MAX_LENGTH]) &&
                                baseMaxLength.compareValue(len) >= 0))
                            {
                                state.error(XmlErrorCodes.DATATYPE_LENGTH, null, facet);
                                continue;
                            }
                        }
                        myFacets[code] = len;
                        break;

                    case SchemaType.FACET_MIN_LENGTH:
                    case SchemaType.FACET_MAX_LENGTH:
                        XmlInteger mlen = StscTranslator.buildNnInteger(facet.getValue());
                        if (mlen == null)
                        {
                            state.error("Must be a nonnegative integer", XmlErrorCodes.FACET_VALUE_MALFORMED, facet);
                            continue;
                        }
                        if (fixedFacets[code] && !myFacets[code].valueEquals(mlen))
                        {
                            state.error(XmlErrorCodes.FACET_FIXED, new Object[] { facetName }, facet);
                            continue;
                        }
                        if (myFacets[SchemaType.FACET_LENGTH] != null)
                        {
                            // It's an error for 'length' and 'minLength'/'maxLength' to be
                            // specified at the same time, except for the case when
                            // the base type had the same value for 'minLength'/'maxLength'
                            // and the two values are consistent
                            XmlAnySimpleType baseMinMaxLength = baseImpl.getFacet(code);
                            if (!(baseMinMaxLength != null &&
                                baseMinMaxLength.valueEquals(mlen) &&
                                (code == SchemaType.FACET_MIN_LENGTH ?
                                    baseMinMaxLength.compareTo(myFacets[SchemaType.FACET_LENGTH]) <= 0 :
                                    baseMinMaxLength.compareTo(myFacets[SchemaType.FACET_LENGTH]) >= 0)))
                            {
                                state.error(XmlErrorCodes.DATATYPE_LENGTH, null, facet);
                                continue;
                            }
                        }
                        if (myFacets[SchemaType.FACET_MAX_LENGTH] != null)
                        {
                            if (mlen.compareValue(myFacets[SchemaType.FACET_MAX_LENGTH]) > 0)
                            {
                                state.error(XmlErrorCodes.DATATYPE_MAX_LENGTH_RESTRICTION, null, facet);
                                continue;
                            }
                        }
                        if (myFacets[SchemaType.FACET_MIN_LENGTH] != null)
                        {
                            if (mlen.compareValue(myFacets[SchemaType.FACET_MIN_LENGTH]) < 0)
                            {
                                state.error(XmlErrorCodes.DATATYPE_MIN_LENGTH_RESTRICTION, null, facet);
                                continue;
                            }
                        }
                        myFacets[code] = mlen;
                        break;

                    case SchemaType.FACET_TOTAL_DIGITS:
                        XmlPositiveInteger dig = StscTranslator.buildPosInteger(facet.getValue());
                        if (dig == null)
                        {
                            state.error("Must be a positive integer", XmlErrorCodes.FACET_VALUE_MALFORMED, facet);
                            break;
                        }
                        if (fixedFacets[code] && !myFacets[code].valueEquals(dig))
                        {
                            state.error(XmlErrorCodes.FACET_FIXED, new Object[] { facetName }, facet);
                            continue;
                        }
                        if (myFacets[SchemaType.FACET_TOTAL_DIGITS] != null)
                        {
                            if (dig.compareValue(myFacets[SchemaType.FACET_TOTAL_DIGITS]) > 0)
                                state.error(XmlErrorCodes.DATATYPE_TOTAL_DIGITS_RESTRICTION, null, facet);
                        }
                        myFacets[code] = dig;
                        break;

                    case SchemaType.FACET_FRACTION_DIGITS:
                        XmlNonNegativeInteger fdig = StscTranslator.buildNnInteger(facet.getValue());
                        if (fdig == null)
                        {
                            state.error("Must be a nonnegative integer", XmlErrorCodes.FACET_VALUE_MALFORMED, facet);
                            break;
                        }
                        if (fixedFacets[code] && !myFacets[code].valueEquals(fdig))
                        {
                            state.error(XmlErrorCodes.FACET_FIXED, new Object[] { facetName }, facet);
                            continue;
                        }
                        if (myFacets[SchemaType.FACET_FRACTION_DIGITS] != null)
                        {
                            if (fdig.compareValue(myFacets[SchemaType.FACET_FRACTION_DIGITS]) > 0)
                                state.error(XmlErrorCodes.DATATYPE_FRACTION_DIGITS_RESTRICTION, null, facet);
                        }
                        if (myFacets[SchemaType.FACET_TOTAL_DIGITS] != null)
                        {
                            if (fdig.compareValue(myFacets[SchemaType.FACET_TOTAL_DIGITS]) > 0)
                                state.error(XmlErrorCodes.DATATYPE_FRACTION_DIGITS_LE_TOTAL_DIGITS, null, facet);
                        }
                        myFacets[code] = fdig;
                        break;

                    case SchemaType.FACET_MIN_EXCLUSIVE:
                    case SchemaType.FACET_MIN_INCLUSIVE:
                    case SchemaType.FACET_MAX_INCLUSIVE:
                    case SchemaType.FACET_MAX_EXCLUSIVE:

                        if (seenFacet[other_similar_limit(code)])
                        {
                            state.error("Cannot define both inclusive and exclusive limit in the same restriciton", XmlErrorCodes.FACET_DUPLICATED, facet);
                            continue;
                        }
                        boolean ismin = (code == SchemaType.FACET_MIN_EXCLUSIVE || code == SchemaType.FACET_MIN_INCLUSIVE);
                        boolean isexclusive = (code == SchemaType.FACET_MIN_EXCLUSIVE || code == SchemaType.FACET_MAX_EXCLUSIVE);

                        XmlAnySimpleType limit;
                        try
                        {
                            limit = baseImpl.newValue(facet.getValue(), true);
                        }
                        catch (XmlValueOutOfRangeException e)
                        {
                            // note: this guarantees that the limit is a valid number in the
                            // base data type!!
                            switch (code)
                            {
                            case SchemaType.FACET_MIN_EXCLUSIVE:
                                state.error(XmlErrorCodes.DATATYPE_MIN_EXCLUSIVE_RESTRICTION,
                                    new Object[] {e.getMessage()}, facet);
                                break;
                            case SchemaType.FACET_MIN_INCLUSIVE:
                                state.error(XmlErrorCodes.DATATYPE_MIN_INCLUSIVE_RESTRICTION,
                                    new Object[] {e.getMessage()}, facet);
                                break;
                            case SchemaType.FACET_MAX_INCLUSIVE:
                                state.error(XmlErrorCodes.DATATYPE_MAX_INCLUSIVE_RESTRICTION,
                                    new Object[] {e.getMessage()}, facet);
                                break;
                            case SchemaType.FACET_MAX_EXCLUSIVE:
                                state.error(XmlErrorCodes.DATATYPE_MAX_EXCLUSIVE_RESTRICTION,
                                    new Object[] {e.getMessage()}, facet);
                                break;
                            }

                            // BUGBUG: if there are actual schemas that redefine min/maxExclusive,
                            // they will need this rule relaxed for them!!
                            continue;
                        }
                        if (fixedFacets[code] && !myFacets[code].valueEquals(limit))
                        {
                            state.error(XmlErrorCodes.FACET_FIXED, new Object[] { facetName }, facet);
                            continue;
                        }
                        if (myFacets[code] != null)
                        {
                            SchemaType limitSType = limit.schemaType();
                            if ( limitSType!=null && !limitSType.isSimpleType() &&
                                    limitSType.getContentType()==SchemaType.SIMPLE_CONTENT)
                            {
                                // in the case of complex types with simple content that has facets
                                // we need to compare values based on the content type
                                limit = baseImpl.getContentBasedOnType().newValue(facet.getValue());
                            }

                            int comparison = limit.compareValue(myFacets[code]);
                            if (comparison == 2 || comparison == (ismin ? -1 : 1))
                            {
                                state.error(ismin ?
                                        (isexclusive ?
                                            "Must be greater than or equal to previous minExclusive" :
View Full Code Here

                    String valueConstraint = sAttrs[i].getDefaultText();
                    if (valueConstraint != null)
                    {
                        try
                        {
                            XmlAnySimpleType val = sAttrs[i].getDefaultValue();
                            if (!val.validate())
                                throw new Exception();
                           
                            SchemaPropertyImpl sProp = (SchemaPropertyImpl)sType.getAttributeProperty(sAttrs[i].getName());
                            if (sProp != null && sProp.getDefaultText() != null)
                            {
View Full Code Here

                {
                    if (model.getType().isSimpleType() || model.getType().getContentType() == SchemaType.SIMPLE_CONTENT)
                    {
                        try
                        {
                            XmlAnySimpleType val = model.getDefaultValue();
                            XmlOptions opt = new XmlOptions();
                            opt.put(XmlOptions.VALIDATE_TEXT_ONLY);
                            if (!val.validate(opt))
                                throw new Exception();

                            SchemaPropertyImpl sProp = (SchemaPropertyImpl)parentType.getElementProperty(model.getName());
                            if (sProp != null && sProp.getDefaultText() != null)
                            {
View Full Code Here

        }

        primitive:
        if (obj instanceof XmlAnySimpleType)
        {
            XmlAnySimpleType v = (XmlAnySimpleType)obj;
            SchemaType instanceType = ((SimpleValue)v).instanceType();
            assert(instanceType != null) : "Nil case should have been handled already";

            // handle lists
            if (instanceType.getSimpleVariety() == SchemaType.LIST)
            {
                synchronized (monitor())
                {
                    set_prepare();
                    set_list(((SimpleValue)v).xgetListValue());
                    set_commit();
                    return;
                }
            }

            // handle atomic types
            synchronized (monitor())
            {
                assert(instanceType.getSimpleVariety() == SchemaType.ATOMIC);
                switch (instanceType.getPrimitiveType().getBuiltinTypeCode())
                {
                    default:
                        assert(false) : "encountered nonprimitive type.";
                    // case SchemaType.BTC_ANY_SIMPLE:  This is handled below...
                    // but we eventually want to handle it with a treecopy, so
                    // eventually we should break here.
                        break primitive;

                    case SchemaType.BTC_BOOLEAN:
                    {
                        boolean bool = ((SimpleValue)v).getBooleanValue();
                        set_prepare();
                        set_boolean(bool);
                        break;
                    }
                    case SchemaType.BTC_BASE_64_BINARY:
                    {
                        byte[] byteArr = ((SimpleValue)v).getByteArrayValue();
                        set_prepare();
                        set_b64(byteArr);
                        break;
                    }
                    case SchemaType.BTC_HEX_BINARY:
                    {
                        byte[] byteArr = ((SimpleValue)v).getByteArrayValue();
                        set_prepare();
                        set_hex(byteArr);
                        break;
                    }
                    case SchemaType.BTC_QNAME:
                    {
                        QName name = ((SimpleValue)v).getQNameValue();
                        set_prepare();
                        set_QName(name);
                        break;
                    }
                    case SchemaType.BTC_FLOAT:
                    {
                        float f = ((SimpleValue)v).getFloatValue();
                        set_prepare();
                        set_float(f);
                        break;
                    }
                    case SchemaType.BTC_DOUBLE:
                    {
                        double d = ((SimpleValue)v).getDoubleValue();
                        set_prepare();
                        set_double(d);
                        break;
                    }
                    case SchemaType.BTC_DECIMAL:
                    {
                        switch (instanceType.getDecimalSize())
                        {
                            case SchemaType.SIZE_BYTE:
                            {
                                byte b = ((SimpleValue)v).getByteValue();
                                set_prepare();
                                set_byte(b);
                                break;
                            }
                            case SchemaType.SIZE_SHORT:
                            {
                                short s = ((SimpleValue)v).getShortValue();
                                set_prepare();
                                set_short(s);
                                break;
                            }
                            case SchemaType.SIZE_INT:
                            {
                                int i = ((SimpleValue)v).getIntValue();
                                set_prepare();
                                set_int(i);
                                break;
                            }
                            case SchemaType.SIZE_LONG:
                            {
                                long l = ((SimpleValue)v).getLongValue();
                                set_prepare();
                                set_long(l);
                                break;
                            }
                            case SchemaType.SIZE_BIG_INTEGER:
                            {
                                BigInteger bi = ((SimpleValue)v).getBigIntegerValue();
                                set_prepare();
                                set_BigInteger(bi);
                                break;
                            }
                            default:
                            {
                                assert(false) : "invalid numeric bit count";
                                // fallthrough
                            }
                            case SchemaType.SIZE_BIG_DECIMAL:
                            {
                                BigDecimal bd = ((SimpleValue)v).getBigDecimalValue();
                                set_prepare();
                                set_BigDecimal(bd);
                                break;
                            }
                        }
                        break;
                    }
                    case SchemaType.BTC_ANY_URI:
                    {
                        String uri = v.getStringValue();
                        set_prepare();
                        set_text(uri);
                        break;
                    }
                    case SchemaType.BTC_NOTATION:
                    {
                        String s = v.getStringValue();
                        set_prepare();
                        set_notation(s);
                        break;
                    }
                    case SchemaType.BTC_DURATION:
                    {
                        GDuration gd = ((SimpleValue)v).getGDurationValue();
                        set_prepare();
                        set_GDuration(gd);
                        break;
                    }
                    case SchemaType.BTC_DATE_TIME:
                    case SchemaType.BTC_TIME:
                    case SchemaType.BTC_DATE:
                    case SchemaType.BTC_G_YEAR_MONTH:
                    case SchemaType.BTC_G_YEAR:
                    case SchemaType.BTC_G_MONTH_DAY:
                    case SchemaType.BTC_G_DAY:
                    case SchemaType.BTC_G_MONTH:
                    {
                        GDate gd = ((SimpleValue)v).getGDateValue();
                        set_prepare();
                        set_GDate(gd);
                        break;
                    }
                    case SchemaType.BTC_STRING:
                    {
                        String s = v.getStringValue();
                        set_prepare();
                        set_String(s);
                        break;
                    }
                    case SchemaType.BTC_ANY_SIMPLE:
                        {
                            boolean pushed = false;
                            if (!v.isImmutable())
                            {
                                pushed = true;
                                NamespaceContext.push(new NamespaceContext(v));
                            }
                            try
View Full Code Here

        }

        primitive:
        if (obj instanceof XmlAnySimpleType)
        {
            XmlAnySimpleType v = (XmlAnySimpleType)obj;
            SchemaType instanceType = ((SimpleValue)v).instanceType();
            assert(instanceType != null) : "Nil case should have been handled already";

            // handle lists
            if (instanceType.getSimpleVariety() == SchemaType.LIST)
            {
                synchronized (monitor())
                {
                    set_prepare();
                    set_list(((SimpleValue)v).xgetListValue());
                    set_commit();
                    return;
                }
            }

            // handle atomic types
            synchronized (monitor())
            {
                assert(instanceType.getSimpleVariety() == SchemaType.ATOMIC);
                switch (instanceType.getPrimitiveType().getBuiltinTypeCode())
                {
                    default:
                        assert(false) : "encountered nonprimitive type.";
                    // case SchemaType.BTC_ANY_SIMPLE:  This is handled below...
                    // but we eventually want to handle it with a treecopy, so
                    // eventually we should break here.
                        break primitive;

                    case SchemaType.BTC_BOOLEAN:
                    {
                        boolean bool = ((SimpleValue)v).getBooleanValue();
                        set_prepare();
                        set_boolean(bool);
                        break;
                    }
                    case SchemaType.BTC_BASE_64_BINARY:
                    {
                        byte[] byteArr = ((SimpleValue)v).getByteArrayValue();
                        set_prepare();
                        set_b64(byteArr);
                        break;
                    }
                    case SchemaType.BTC_HEX_BINARY:
                    {
                        byte[] byteArr = ((SimpleValue)v).getByteArrayValue();
                        set_prepare();
                        set_hex(byteArr);
                        break;
                    }
                    case SchemaType.BTC_QNAME:
                    {
                        QName name = ((SimpleValue)v).getQNameValue();
                        set_prepare();
                        set_QName(name);
                        break;
                    }
                    case SchemaType.BTC_FLOAT:
                    {
                        float f = ((SimpleValue)v).getFloatValue();
                        set_prepare();
                        set_float(f);
                        break;
                    }
                    case SchemaType.BTC_DOUBLE:
                    {
                        double d = ((SimpleValue)v).getDoubleValue();
                        set_prepare();
                        set_double(d);
                        break;
                    }
                    case SchemaType.BTC_DECIMAL:
                    {
                        switch (instanceType.getDecimalSize())
                        {
                            case SchemaType.SIZE_BYTE:
                            {
                                byte b = ((SimpleValue)v).getByteValue();
                                set_prepare();
                                set_byte(b);
                                break;
                            }
                            case SchemaType.SIZE_SHORT:
                            {
                                short s = ((SimpleValue)v).getShortValue();
                                set_prepare();
                                set_short(s);
                                break;
                            }
                            case SchemaType.SIZE_INT:
                            {
                                int i = ((SimpleValue)v).getIntValue();
                                set_prepare();
                                set_int(i);
                                break;
                            }
                            case SchemaType.SIZE_LONG:
                            {
                                long l = ((SimpleValue)v).getLongValue();
                                set_prepare();
                                set_long(l);
                                break;
                            }
                            case SchemaType.SIZE_BIG_INTEGER:
                            {
                                BigInteger bi = ((SimpleValue)v).getBigIntegerValue();
                                set_prepare();
                                set_BigInteger(bi);
                                break;
                            }
                            default:
                            {
                                assert(false) : "invalid numeric bit count";
                                // fallthrough
                            }
                            case SchemaType.SIZE_BIG_DECIMAL:
                            {
                                BigDecimal bd = ((SimpleValue)v).getBigDecimalValue();
                                set_prepare();
                                set_BigDecimal(bd);
                                break;
                            }
                        }
                        break;
                    }
                    case SchemaType.BTC_ANY_URI:
                    {
                        String uri = v.getStringValue();
                        set_prepare();
                        set_text(uri);
                        break;
                    }
                    case SchemaType.BTC_NOTATION:
                    {
                        String s = v.getStringValue();
                        set_prepare();
                        set_notation(s);
                        break;
                    }
                    case SchemaType.BTC_DURATION:
                    {
                        GDuration gd = ((SimpleValue)v).getGDurationValue();
                        set_prepare();
                        set_GDuration(gd);
                        break;
                    }
                    case SchemaType.BTC_DATE_TIME:
                    case SchemaType.BTC_TIME:
                    case SchemaType.BTC_DATE:
                    case SchemaType.BTC_G_YEAR_MONTH:
                    case SchemaType.BTC_G_YEAR:
                    case SchemaType.BTC_G_MONTH_DAY:
                    case SchemaType.BTC_G_DAY:
                    case SchemaType.BTC_G_MONTH:
                    {
                        GDate gd = ((SimpleValue)v).getGDateValue();
                        set_prepare();
                        set_GDate(gd);
                        break;
                    }
                    case SchemaType.BTC_STRING:
                    {
                        String s = v.getStringValue();
                        set_prepare();
                        set_String(s);
                        break;
                    }
                    case SchemaType.BTC_ANY_SIMPLE:
                        {
                            boolean pushed = false;
                            if (!v.isImmutable())
                            {
                                pushed = true;
                                NamespaceContext.push(new NamespaceContext(v));
                            }
                            try
View Full Code Here

                    String valueConstraint = sAttrs[i].getDefaultText();
                    if (valueConstraint != null)
                    {
                        try
                        {
                            XmlAnySimpleType val = sAttrs[i].getDefaultValue();
                            if (!val.validate())
                                throw new Exception();
                           
                            SchemaPropertyImpl sProp = (SchemaPropertyImpl)sType.getAttributeProperty(sAttrs[i].getName());
                            if (sProp != null && sProp.getDefaultText() != null)
                            {
View Full Code Here

                {
                    if (model.getType().isSimpleType() || model.getType().getContentType() == SchemaType.SIMPLE_CONTENT)
                    {
                        try
                        {
                            XmlAnySimpleType val = model.getDefaultValue();
                            XmlOptions opt = new XmlOptions();
                            opt.put(XmlOptions.VALIDATE_TEXT_ONLY);
                            if (!val.validate(opt))
                                throw new Exception();

                            SchemaPropertyImpl sProp = (SchemaPropertyImpl)parentType.getElementProperty(model.getName());
                            if (sProp != null && sProp.getDefaultText() != null)
                            {
View Full Code Here

TOP

Related Classes of org.apache.xmlbeans.XmlAnySimpleType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.