Package org.exolab.castor.xml

Examples of org.exolab.castor.xml.ValidationException


        switch (_type) {
            case XMLConstants.NAME_TYPE_CDATA:
                if (!ValidationUtils.isCDATA(value)) {
                    String err = "Name '" + value + "' is not a valid CDATA.";
                    throw new ValidationException(err);
                }
                break;

            case XMLConstants.NAME_TYPE_NMTOKEN:
                if (!ValidationUtils.isNMToken(value)) {
                    String err = "Name '" + value + "' is not a valid NMToken.";
                    throw new ValidationException(err);
                }
                break;

            case XMLConstants.NAME_TYPE_QNAME:
                if (!ValidationUtils.isQName(value)) {
                    String err = "Name '" + value + "' is not a valid QName.";
                    throw new ValidationException(err);
                }
                break;

            case XMLConstants.NAME_TYPE_NCNAME:
            default:
                if (!ValidationUtils.isNCName(value)) {
                    String err = "Name '" + value + "' is not a valid NCName.";
                    throw new ValidationException(err);
                }
                break;
        }
    } // -- validate
View Full Code Here


     */
    public void validate(final BigInteger value, final ValidationContext context)
                                                    throws ValidationException {
        if (_useFixed && value != _fixed) {
            String err = "BigInteger " + value + " is not equal to the fixed value: " + _fixed;
            throw new ValidationException(err);
        }

        if (_useMin && value.compareTo(_min) == -1) {
            String err = "BigInteger " + value + " is less than the minimum allowed value: " + _min;
            throw new ValidationException(err);
        }

        if (_useMax && value.compareTo(_max) == 1) {
            String err = "BigInteger " + value + " is greater than the maximum allowed value: "
                    + _max;
            throw new ValidationException(err);
        }

        if (_totalDigits != -1) {
            int length = value.toString().length();
            if (value.compareTo(new BigInteger("0")) == -1) {
                length--;
            }
            if (length > _totalDigits) {
                String err = "BigInteger " + value + " has too many digits -- must have "
                        + _totalDigits + " digits or fewer.";
                throw new ValidationException(err);
            }
        }

        if (hasPattern()) {
            super.validate(value.toString(), context);
View Full Code Here

     */
    public void validate(final Object object, final ValidationContext context)
                                                    throws ValidationException {
        if (object == null) {
            String err = "BigIntegerValidator cannot validate a null object.";
            throw new ValidationException(err);
        }

        BigInteger value = BigInteger.valueOf(0);
        try {
            value = (BigInteger) object;
        } catch (Exception ex) {
            String err = "Expecting a BigInteger, received instead: ";
            err += object.getClass().getName();
            throw new ValidationException(err);
        }
        validate(value, context);
    } // -- validate
View Full Code Here

     */
    public void validate(final short s, final ValidationContext context)
                                                    throws ValidationException {
        if (_useFixed && s != _fixed) {
            String err = "short " + s + " is not equal to the fixed value: " + _fixed;
            throw new ValidationException(err);
        }

        if (_useMin && s < _min) {
            String err = "short " + s + " is less than the minimum allowed value: " + _min;
            throw new ValidationException(err);
        }

        if (_useMax && s > _max) {
            String err = "short " + s + " is greater than the maximum allowed value: " + _max;
            throw new ValidationException(err);
        }

        if (_totalDigits != -1) {
            int length = Short.toString(s).length();
            if (s < 0) {
                length--;
            }
            if (length > _totalDigits) {
                String err = "short " + s + " has too many digits -- must have "
                        + _totalDigits + " digits or fewer.";
                throw new ValidationException(err);
            }
        }

        if (hasPattern()) {
            super.validate(Short.toString(s), context);
View Full Code Here

     */
    public void validate(final Object object, final ValidationContext context)
                                                    throws ValidationException {
        if (object == null) {
            String err = "ShortValidator cannot validate a null object.";
            throw new ValidationException(err);
        }

        short value = 0;
        try {
            value = ((Short) object).shortValue();
        } catch (Exception ex) {
            String err = "Expecting a Short, received instead: " + object.getClass().getName();
            throw new ValidationException(err);
        }
        validate(value, context);
    } //-- validate
View Full Code Here

        boolean isThereMinExclusive = (_minExclusive != null);
        boolean isThereMaxInclusive = (_maxInclusive != null);
        boolean isThereMaxExclusive = (_maxExclusive != null);

        if (isThereMinExclusive && isThereMinInclusive) {
            throw new ValidationException("both minInclusive and minExclusive"
                                          +"are set up");
        }

        if (isThereMaxExclusive && isThereMaxInclusive) {
            throw new ValidationException("both maxInclusive and maxExclusive"
                                          +"are set up");
        }

        if (isThereMinInclusive) {
            if ( _minInclusive.isGreater(duration)) {
                String err = duration + " is less than the minimum allowable ";
                err += "value of " + _minInclusive;
                throw new ValidationException(err);
            }
        }

         if (isThereMinExclusive) {
            if ( (_minExclusive.isGreater(duration)) ||
                  duration.equals(_minExclusive) )
            {
                String err = duration + " is less than the minimum allowable ";
                err += "value of " + _minExclusive;
                throw new ValidationException(err);
            }
        }

         if (isThereMaxInclusive) {
            if ( duration.isGreater(_maxInclusive)) {
                String err = duration + " is greater than the maximum allowable ";
                err += "value of " + _maxInclusive;
                throw new ValidationException(err);
            }
        }

         if (isThereMaxExclusive) {
            if ( (duration.isGreater(_maxExclusive)) ||
                  duration.equals(_maxExclusive) )
            {
                String err = duration + " is greater than the maximum allowable ";
                err += "value of " + _maxExclusive;
                throw new ValidationException(err);
            }
        }

        //use the pattern validator
        //if (hasPattern()) {
View Full Code Here

    public void validate(Object object, ValidationContext context)
        throws ValidationException
    {
        if (object == null) {
            String err = "durationValidator cannot validate a null object.";
            throw new ValidationException(err);
        }

        Duration value = null;
        try {
            value = Duration.parseDuration(object.toString());
        }
        catch(Exception ex) {
            String err = "Expecting a duration, received instead: ";
            err += object.getClass().getName();
            throw new ValidationException(err);
        }
        validate(value);
    } //-- validate
View Full Code Here

        boolean isThereMinExclusive = (_minExclusive != null);
        boolean isThereMaxInclusive = (_maxInclusive != null);
        boolean isThereMaxExclusive = (_maxExclusive != null);

        if (isThereMinExclusive && isThereMinInclusive) {
            throw new ValidationException("both minInclusive and minExclusive"
                                          +"are set up");
        }

        if (isThereMaxExclusive && isThereMaxInclusive) {
            throw new ValidationException("both maxInclusive and maxExclusive"
                                          +"are set up");
        }
        if (isThereMinInclusive) {
            if ( (dateTime.compareTo(_minInclusive) != DateTimeBase.GREATER_THAN) &&
               !dateTime.equals(_minInclusive) ) {
                String err = dateTime + " must be greater than (or equal to) the minimum allowable ";
                err += "value of " + _minInclusive;
                throw new ValidationException(err);
            }
        }

         if (isThereMinExclusive) {
            if (dateTime.compareTo(_minExclusive) != DateTimeBase.GREATER_THAN) {
                String err = dateTime + " must be greater than the minimum allowable ";
                err += "value of " + _minExclusive;
                throw new ValidationException(err);
            }
        }

         if (isThereMaxInclusive) {
            if ( (dateTime.compareTo(_maxInclusive) != DateTimeBase.LESS_THAN) &&
                 !dateTime.equals(_maxInclusive) ) {
                String err = dateTime + " must be less than (or equal to) the maximum allowable ";
                err += "value of " + _maxInclusive;
                throw new ValidationException(err);
            }
        }

         if (isThereMaxExclusive) {
            if (dateTime.compareTo(_maxExclusive) != DateTimeBase.LESS_THAN) {
                String err = dateTime + " must be less than the maximum allowable ";
                err += "value of " + _maxExclusive;
                throw new ValidationException(err);
            }
        }

        //use the pattern validator
        /*if (hasPattern()) {
View Full Code Here

    public void validate(Object object, ValidationContext context)
        throws ValidationException
    {
        if (object == null) {
            String err = "DateTimeValidator cannot validate a null object.";
            throw new ValidationException(err);
        }

        DateTimeBase value = null;

        try {
            value = (DateTimeBase)object;
        } catch(Exception ex) {
            String err = ex.toString()+"\nExpecting a RecurringDuration, received instead: ";
            err += object.getClass().getName();
            throw new ValidationException(err);
        }
        validate(value);
    } //-- validate
View Full Code Here

        if ( !(this.getPeriod().equals(reccD.getPeriod())) ||
             !(this.getDuration().equals(reccD.getDuration())) )
        {
                String err = " Recurring Duration which have different values "
                            +"for the duration and period can not be compared";
                throw new ValidationException(err);
        }
        result = this.getCentury() == reccD.getCentury();
        result = result && (this.getYear() == reccD.getYear());
        result = result && (this.getMonth() == reccD.getMonth());
        result = result && (this.getDay() == reccD.getDay());
View Full Code Here

TOP

Related Classes of org.exolab.castor.xml.ValidationException

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.