Package org.exolab.castor.xml

Examples of org.exolab.castor.xml.ValidationException


    public void validate() throws ValidationException {
        if (_order == Order.all) {
            if (getMaxOccurs() != 1) {
                String err = "Wrong maxOccurs value for a <all>:" + getMaxOccurs();
                err += "\n1 is the only possible value.";
                throw new ValidationException(err);
            }
            if (getMinOccurs() > 1) {
                String err = "Wrong minOccurs value for a <all>:" + getMinOccurs();
                err += "\n0 or 1 are the only possible values.";
                throw new ValidationException(err);
            }
        }
        Enumeration<Structure> enumeration = _contentModel.enumerate();
        while (enumeration.hasMoreElements()) {
            enumeration.nextElement().validate();
View Full Code Here


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

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

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

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

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

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

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

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

        String value = null;
        if (!(object instanceof String)) {
            throw new ValidationException("IDs should be of type String");
        }

        value = (String) object;

        if (value.equals("")) {
            String err = "Invalid ID value: '' is not a valid value.";
            throw new ValidationException(err);
        }

        context.addID(value);

        // validate(value, context);
View Full Code Here

                if (i.hasNext()) {
                    buff.append(", ");
                }
            }
        }
        throw new ValidationException(buff.toString());
    } // -- validate
View Full Code Here

    public void validate(final Object object, final ValidationContext context)
                                                    throws ValidationException {
        if (object == null) {
            if (!_nillable) {
                String err = "PatternValidator cannot validate a null object.";
                throw new ValidationException(err);
            }
            return;
        }
        validate(object.toString(), context);
    } // -- validate
View Full Code Here

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

        if (hasPattern()) {
            super.validate(String.valueOf(b), context);
        }
View Full Code Here

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

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

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

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

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

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

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

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

        byte value = 0;
        try {
            value = ((Byte) object).byteValue();
        } catch (Exception ex) {
            String err = "Expecting a Byte, received instead: ";
            err += object.getClass().getName();
            throw new ValidationException(err);
        }
        validate(value, context);
    } // -- validate
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.