[Jvalid-checkins] CVS: jvalid/src/net/sourceforge/jvalid DataValidationException.java,NONE,1.1
Status: Alpha
Brought to you by:
mikewill_1998
From: Mike W. <mik...@us...> - 2001-03-27 10:48:25
|
Update of /cvsroot/jvalid/jvalid/src/net/sourceforge/jvalid In directory usw-pr-cvs1:/tmp/cvs-serv16627 Added Files: DataValidationException.java Log Message: New exception that is thrown by the getObject() method in the Validator class when validation errors occur. --- NEW FILE --- /*------------------------------------------------------------------------------------------ * First let me give credit where credit is due! * * This package is based on the orginal work of Brett McLaughlin in the Javaworld article * 'Validation with Java and XML schema, Part 1' which can be found at * http://www.javaworld.com/javaworld/jw-09-2000/jw-0908-validation.html * * * Major modifications are noted in the JavaDoc comment or in the CVS change log. *------------------------------------------------------------------------------------------ * * Legal Stuff * * JValid is Open Source. * * Copyright (c) 2000 Mike Williams. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted under the terms of the * GNU LESSER GENERAL PUBLIC LICENSE version 2.1 or later. * * You should have received a copy the license in this distribution. * * This product includes software developed by the JDOM Project * (http://www.jdom.org). Please see LICENSE-JDOM for details. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * *------------------------------------------------------------------- * C H A N G E L O G *------------------------------------------------------------------- * Created on February 25, 2001, 11:13 PM * * $Header: /cvsroot/jvalid/jvalid/src/net/sourceforge/jvalid/DataValidationException.java,v 1.1 2001/03/27 10:48:22 mikewill_1998 Exp $ * $Log: DataValidationException.java,v $ * Revision 1.1 2001/03/27 10:48:22 mikewill_1998 * New exception that is thrown by the getObject() method in the Validator * class when validation errors occur. * * Revision 1.1 2001/03/15 00:39:47 mikewill_1998 * This exception is thrown if an unkown data type is passed to the toDouble() method in DataConverter. * Missed adding it the first time. Bad developer!!! ;) * * */ package net.sourceforge.jvalid; import java.lang.Exception; import java.lang.StringBuffer; import java.util.List; import java.util.LinkedList; import java.util.Iterator; /** * <p> * An Exception subclass. Note that methods throwing an Exception have to * declare this by using the "throws DataValidationException" keyword. * </p> * * This exception provides access to a List containing any validation * errors encountered. * * @author Mike Williams * @version 1.0 */ public class DataValidationException extends Exception { /** * List containing all errors associated with this exception. */ private List mErrorList; /** * Default constructor. */ private DataValidationException() { super(); } /** * Construct an exception having a Message String<br> * The message is printed to System.out when printStackTrace() is called * * @param <code>String</code> message providing details about the Exception. */ public DataValidationException( String message ) { this(); mErrorList = new LinkedList(); mErrorList.add( message ); } /** * Construct an exception having a List of errors. * You can retrieve this list by calling getErrors(). * The getMessage() method will build a String from this * list. * * @param <code>List</code> errorList providing all errors associated with * the Exception. */ public DataValidationException( List errorList ) { this.mErrorList = errorList; } /** * Overridden to return the contents of the ErrorList. * * @return <code>String</code> contents of the ErrorList. */ public String getMessage() { Iterator i = mErrorList.iterator(); StringBuffer sb = new StringBuffer(); while ( i.hasNext() ) { sb.append( (String) i.next() + "\n" ); } if ( sb.length() >= 2 ) { sb.setLength( sb.length() - 2 ); } return sb.toString(); } } |