Package org.relaxng.datatype

Examples of org.relaxng.datatype.DatatypeException


        // this method is never called.
        if(o==null)    throw new IllegalStateException();    // assertion
       
        int cnt = ((Discrete)concreteType).countLength(o);
        if(cnt<minLength)
            throw new DatatypeException( DatatypeException.UNKNOWN,
                localize(ERR_MINLENGTH,    new Integer(cnt), new Integer(minLength)) );
    }
View Full Code Here


    }
   
    protected void diagnoseByFacet(String content, ValidationContext context) throws DatatypeException {
        if( _createValue(content,context)!=null )        return;
           
        throw new DatatypeException( DatatypeException.UNKNOWN,
            localize(ERR_OUT_OF_RANGE, facetName, limitValue) );
    }
View Full Code Here

        scale = _scale;
       
        // loosened facet check
        DataTypeWithFacet o = baseType.getFacetObject(FACET_FRACTIONDIGITS);
        if(o!=null && ((FractionDigitsFacet)o).scale < this.scale )
            throw new DatatypeException( localize( ERR_LOOSENED_FACET,
                FACET_FRACTIONDIGITS, o.displayName() ) );
       
        // consistency with precision is checked in XSDatatypeImpl.derive method.
    }
View Full Code Here

   
    protected void diagnoseByFacet(String content, ValidationContext context) throws DatatypeException {
        final int cnt = countScale(content);
        if(cnt<=scale)        return;
       
        throw new DatatypeException( DatatypeException.UNKNOWN,
            localize(ERR_TOO_MUCH_SCALE,
            new Integer(cnt), new Integer(scale)) );
    }
View Full Code Here

                // to issue an error, we need to first make sure that the
                // specified value is different from the fixed value.
                //            throw new DatatypeException( XSDatatypeImpl.localize(
                //                XSDatatypeImpl.ERR_OVERRIDING_FIXED_FACET, name ) );
            case XSDatatypeImpl.NOT_ALLOWED :
                throw new DatatypeException(XSDatatypeImpl.localize(XSDatatypeImpl.ERR_NOT_APPLICABLE_FACET, name));
            default :
                throw new Error(); // assertion failed
        }

        Object value;

        if (isValueFacet(name)) {
            value = baseType.createValue(strValue, context);
            if (value == null)
                throw new DatatypeException(
                    XSDatatypeImpl.localize(
                        XSDatatypeImpl.ERR_INVALID_VALUE_FOR_THIS_TYPE,
                        strValue,
                        baseType.displayName()));
        } else
            value = strValue;

        if (isRepeatable(name)) {
            FacetInfo fi;
            if (impl.containsKey(name))
                fi = (FacetInfo)impl.get(name);
            else
                impl.put(name, fi = new FacetInfo(new Vector(), fixed));

            ((Vector)fi.value).add(value);
            // TODO : what shall we do if
            // <enumeration value="a" fixed="true" />
            // <enumeration value="b" fixed="false" />
            fi.fixed |= fixed;
        } else {
            if (impl.containsKey(name))
                throw new DatatypeException(XSDatatypeImpl.localize(XSDatatypeImpl.ERR_DUPLICATE_FACET, name));
            impl.put(name, new FacetInfo(value, fixed));
        }
    }
View Full Code Here

        if (baseType instanceof ErrorType)
            return baseType;

        if (baseType.isFinal(XSDatatype.DERIVATION_BY_RESTRICTION))
            throw new DatatypeException(
                XSDatatypeImpl.localize(XSDatatypeImpl.ERR_INVALID_BASE_TYPE, baseType.displayName()));

        if (isEmpty()) {
            // if no facet is specified, and user wants anonymous type,
            // then no need to create another object.
            // TODO: for the type-derivation-OK test to work correctly,
            // maybe we need to wrap this by a FinalComponent.
            if (newNameUri == null && newLocalName == null)
                return baseType;

            // using FinalComponent as a wrapper,
            // so that the new type object can have its own name.
            return new FinalComponent(newNameUri, newLocalName, baseType, 0);
        }

        XSDatatypeImpl r = baseType; // start from current datatype

        // TODO : make sure that the following interpretation is true
        /*
            several facet consistency check is done here.
            those which are done in this time are:
       
                - length and (minLength/maxLength) are exclusive
                - maxInclusive and maxExclusive are exclusive
                - minInclusive and minExclusive are exclusive
       
       
            those are exclusive within the one restriction;
            that is, it is legal to derive types in the following way:
       
            <simpleType name="foo">
                <restriction baseType="string">
                    <minLength value="3" />
                </restrction>
            </simpleType>
       
            <simpleType name="bar">
                <restriction baseType="foo">
                    <length value="5" />
                </restrction>
            </simpleType>
       
            although the following is considered as an error
       
            <simpleType name="bar">
                <restriction baseType="foo">
                    <length value="5" />
                    <minLength value="3" />
                </restrction>
            </simpleType>
       
       
            This method is the perfect place to perform this kind of check.
        */

        // makes sure that no mutually exclusive facets are specified
        for (int i = 0; i < exclusiveFacetPairs.length; i++)
            if (contains(exclusiveFacetPairs[i][0]) && contains(exclusiveFacetPairs[i][1]))
                throw new DatatypeException(
                    XSDatatypeImpl.localize(
                        XSDatatypeImpl.ERR_X_AND_Y_ARE_EXCLUSIVE,
                        exclusiveFacetPairs[i][0],
                        exclusiveFacetPairs[i][1]));

View Full Code Here

        String o1typeName = o1.getName();
        String o2typeName = o2.getName();

        if (o1typeName.equals(o2typeName))
            // o1typeName==o2typeName==newName
            return new DatatypeException(
                XSDatatypeImpl.localize(XSDatatypeImpl.ERR_INCONSISTENT_FACETS_1, facetName1, facetName2));

        if (o1typeName.equals(newName))
            // o2 must be specified in somewhere in the derivation chain
            return new DatatypeException(
                XSDatatypeImpl.localize(
                    XSDatatypeImpl.ERR_INCONSISTENT_FACETS_2,
                    facetName1,
                    o2.displayName(),
                    facetName2));

        if (o2typeName.equals(newName))
            // vice versa
            return new DatatypeException(
                XSDatatypeImpl.localize(
                    XSDatatypeImpl.ERR_INCONSISTENT_FACETS_2,
                    facetName2,
                    o1.displayName(),
                    facetName1));
View Full Code Here

            } catch (NumberFormatException ee) {
                ;
            }
        }

        throw new DatatypeException(
            XSDatatypeImpl.localize(XSDatatypeImpl.ERR_FACET_MUST_BE_POSITIVE_INTEGER, facetName));
    }
View Full Code Here

                return value;
        } catch (NumberFormatException e) {
            ;
        }

        throw new DatatypeException(
            XSDatatypeImpl.localize(XSDatatypeImpl.ERR_FACET_MUST_BE_NON_NEGATIVE_INTEGER, facetName));
    }
View Full Code Here

        if( baseType.whiteSpace.tightness() > this.whiteSpace.tightness() ) {
            XSDatatype d;
            d=baseType.getFacetObject(FACET_WHITESPACE);
            if(d==null)    d = getConcreteType();
           
            throw new DatatypeException( localize(
                ERR_LOOSENED_FACET,    FACET_WHITESPACE, d.displayName() ));
        }
       
        // consistency with minLength/maxLength is checked in XSDatatypeImpl.derive method.
    }
View Full Code Here

TOP

Related Classes of org.relaxng.datatype.DatatypeException

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.