Return-Path: Delivered-To: apmail-incubator-geronimo-cvs-archive@www.apache.org Received: (qmail 85092 invoked from network); 1 Sep 2003 15:09:39 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 1 Sep 2003 15:09:39 -0000 Received: (qmail 99605 invoked by uid 500); 1 Sep 2003 15:09:31 -0000 Delivered-To: apmail-incubator-geronimo-cvs-archive@incubator.apache.org Received: (qmail 99578 invoked by uid 500); 1 Sep 2003 15:09:31 -0000 Mailing-List: contact geronimo-cvs-help@incubator.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: geronimo-dev@incubator.apache.org Delivered-To: mailing list geronimo-cvs@incubator.apache.org Received: (qmail 99558 invoked from network); 1 Sep 2003 15:09:30 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 1 Sep 2003 15:09:30 -0000 Received: (qmail 85003 invoked by uid 1715); 1 Sep 2003 15:09:27 -0000 Date: 1 Sep 2003 15:09:27 -0000 Message-ID: <20030901150927.85002.qmail@minotaur.apache.org> From: jdillon@apache.org To: incubator-geronimo-cvs@apache.org Subject: cvs commit: incubator-geronimo/modules/common/src/java/org/apache/geronimo/common InvalidArgumentException.java NullArgumentException.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N jdillon 2003/09/01 08:09:26 Modified: modules/common/src/java/org/apache/geronimo/common NullArgumentException.java Added: modules/common/src/java/org/apache/geronimo/common InvalidArgumentException.java Log: o Applied modified patch GERONIMO-32, changed parameter order Revision Changes Path 1.9 +19 -70 incubator-geronimo/modules/common/src/java/org/apache/geronimo/common/NullArgumentException.java Index: NullArgumentException.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/common/src/java/org/apache/geronimo/common/NullArgumentException.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- NullArgumentException.java 16 Aug 2003 15:14:11 -0000 1.8 +++ NullArgumentException.java 1 Sep 2003 15:09:26 -0000 1.9 @@ -57,110 +57,59 @@ package org.apache.geronimo.common; /** - * Thrown to indicate that a method argument was null and + * Thrown to indicate that a method argument was null and * should not have been. * * @version $Revision$ $Date$ */ -public class NullArgumentException - extends IllegalArgumentException +public class NullArgumentException + extends InvalidArgumentException { /** * A simple helper method to check that the given argument value - * is not null. If it is null then a NullArgumentException is thrown. + * is not null. If it is null then a + * NullArgumentException is thrown. * * @param name name of the argument - * @param argument the value of the argument + * @param value the value of the argument * - * @throws NullArgumentException if the argument is null + * @throws NullArgumentException if the argument is null */ - public static void checkForNull(String name, Object argument) throws NullArgumentException { - if (argument == null) { + public static void checkForNull(String name, Object value) + throws NullArgumentException + { + if (value == null) { throw new NullArgumentException(name); } } - /** The name of the argument that was null. */ - protected final String name; - - /** The index of the argument or null if no index. */ - protected final Object index; - /** - * Construct a NullArgumentException. + * Construct a NullArgumentException. * * @param name Argument name. */ public NullArgumentException(final String name) { - super(makeMessage(name)); - - this.name = name; - this.index = null; + this(name,null); } /** - * Construct a NullArgumentException. + * Construct a NullArgumentException. * * @param name Argument name. * @param index Argument index. */ public NullArgumentException(final String name, final long index) { - super(makeMessage(name, new Long(index))); - - this.name = name; - this.index = new Long(index); + this(name, new Long(index)); } /** - * Construct a NullArgumentException. + * Construct a NullArgumentException. * * @param name Argument name. * @param index Argument index. */ public NullArgumentException(final String name, final Object index) { - super(makeMessage(name, index)); - - this.name = name; - this.index = index; - } - - /** - * Construct a NullArgumentException. - */ - public NullArgumentException() { - this.name = null; - this.index = null; - } - - /** - * Get the argument name that was null. - * - * @return The argument name that was null. - */ - public final String getArgumentName() { - return name; - } - - /** - * Get the argument index. - * - * @return The argument index. - */ - public final Object getArgumentIndex() { - return index; - } - - /** - * Make a execption message for the argument name. - */ - private static String makeMessage(final String name) { - return "'" + name + "' is null"; - } - - /** - * Make a execption message for the argument name and index - */ - private static String makeMessage(final String name, final Object index) { - return "'" + name + "[" + index + "]' is null"; + super(name, null, index, "cannot be null"); } + } 1.1 incubator-geronimo/modules/common/src/java/org/apache/geronimo/common/InvalidArgumentException.java Index: InvalidArgumentException.java =================================================================== /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" and * "Apache Geronimo" must not be used to endorse or promote products * derived from this software without prior written permission. For * written permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * "Apache Geronimo", nor may "Apache" appear in their name, without * prior written permission of the Apache Software Foundation. * * 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 APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . * * ==================================================================== */ package org.apache.geronimo.common; /** * Thrown to inidcate an invalid value used for a method argument. * * @version $Revision: 1.1 $ $Date: 2003/09/01 15:09:26 $ */ public class InvalidArgumentException extends IllegalArgumentException { /** * Make a execption message for the given reasons */ private static String makeMessage(String name, Object value, Object index, String reason) { assert name != null; return "'" + name + "'" + (index == null ? "" : "[" + index + "]") + "='" + value + "'" + (reason == null ? " (invalid value)" : " (" + reason + ")"); // TODO I18N internationalise reason } /** The index of the argument or null if no index. */ private final Object index; /** The name of the argument that was invalid. */ private final String name; /** The value of the argument or null if no value. */ private final Object value; /** * Construct a InvalidArgumentException. * * @param name Argument name. */ public InvalidArgumentException(String name, Object value) { this(name, value, null, null); } /** * Construct a InvalidArgumentException. * * @param name Argument name. */ public InvalidArgumentException(String name, Object value, String reason) { this(name, value, null, reason); } /** * Construct a InvalidArgumentException. * * @param name The name of the argument * @param value The value of the argument, or null * @param index The index of the argument, or null if none. * @param reason The reason (short description) of why it is invalid, * or null for the default */ public InvalidArgumentException(String name, Object value, Object index, String reason) { super(makeMessage(name, value, index, reason)); this.name = name; this.value = value; this.index = index; } /** * Returns the index associated with this argument. * May be null if there is no such index. * * @return the index associated with this argument */ public Object getIndex() { return index; } /** * Returns the name of the argument. * * @return the name of the argument */ public String getName() { return name; } /** * Returns the value of the argument. * * @return The value of the argument or null if not specified. */ public Object getValue() { return value; } }