Return-Path: Delivered-To: apmail-commons-dev-archive@www.apache.org Received: (qmail 16641 invoked from network); 24 Jun 2010 18:31:17 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 24 Jun 2010 18:31:17 -0000 Received: (qmail 75551 invoked by uid 500); 24 Jun 2010 18:31:16 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 75411 invoked by uid 500); 24 Jun 2010 18:31:16 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 75403 invoked by uid 99); 24 Jun 2010 18:31:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Jun 2010 18:31:15 +0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=AWL,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_NEUTRAL,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [194.206.126.239] (HELO smtp.nordnet.fr) (194.206.126.239) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Jun 2010 18:31:08 +0000 Received: from lehrin (68.219.20.81.dynamic.adsl.abo.nordnet.fr [81.20.219.68]) by smtp.nordnet.fr (Postfix) with ESMTP id 7D26A4830A for ; Thu, 24 Jun 2010 20:30:43 +0200 (CEST) Received: by lehrin (Postfix, from userid 5001) id 6DCD44171; Thu, 24 Jun 2010 20:30:44 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on lehrin.spaceroots.local X-Spam-Level: Received: from lehrin.spaceroots.local (lehrin.spaceroots.local [127.0.0.1]) by lehrin (Postfix) with ESMTP id 7446E416F for ; Thu, 24 Jun 2010 20:30:41 +0200 (CEST) Message-ID: <4C23A451.10907@free.fr> Date: Thu, 24 Jun 2010 20:30:41 +0200 From: Luc Maisonobe User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100423 Thunderbird/3.0.4 MIME-Version: 1.0 To: dev@commons.apache.org Subject: Re: svn commit: r957518 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/exception/ site/xdoc/ References: <20100624120914.D4D5B23889EA@eris.apache.org> In-Reply-To: <20100624120914.D4D5B23889EA@eris.apache.org> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Old-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,FREEMAIL_FROM autolearn=unavailable version=3.3.1 Le 24/06/2010 14:09, erans@apache.org a écrit : > Author: erans > Date: Thu Jun 24 12:09:14 2010 > New Revision: 957518 > > URL: http://svn.apache.org/viewvc?rev=957518&view=rev > Log: > MATH-361 > > Added: > commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/ > commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/DimensionMismatchException.java (with props) > commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalArgumentException.java (with props) > commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MessageFactory.java (with props) > commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/OutOfRangeException.java (with props) > Modified: > commons/proper/math/trunk/src/site/xdoc/changes.xml > > Added: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/DimensionMismatchException.java > URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/DimensionMismatchException.java?rev=957518&view=auto > ============================================================================== > --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/DimensionMismatchException.java (added) > +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/DimensionMismatchException.java Thu Jun 24 12:09:14 2010 > @@ -0,0 +1,60 @@ > +/* > + * Licensed to the Apache Software Foundation (ASF) under one or more > + * contributor license agreements. See the NOTICE file distributed with > + * this work for additional information regarding copyright ownership. > + * The ASF licenses this file to You under the Apache License, Version 2.0 > + * (the "License"); you may not use this file except in compliance with > + * the License. You may obtain a copy of the License at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in writing, software > + * distributed under the License is distributed on an "AS IS" BASIS, > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > + * See the License for the specific language governing permissions and > + * limitations under the License. > + */ > +package org.apache.commons.math.exception; > + > +import org.apache.commons.math.util.LocalizedFormats; > + > +/** > + * Exception to be thrown when two dimensions differ. > + * > + * @since 2.2 > + * @version $Revision$ $Date$ > + */ > +public class DimensionMismatchException extends MathIllegalArgumentException { > + /** First dimension. */ > + private final int dimension1; > + > + /** Second dimension. */ > + private final int dimension2; > + > + /** > + * Construct an exception from the mismatched dimensions. > + * > + * @param dimension1 First dimension. > + * @param dimension2 Second dimension. > + */ > + public DimensionMismatchException(int dimension1, > + int dimension2) { > + super(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, dimension1, dimension2); > + > + this.dimension1 = dimension1; > + this.dimension2 = dimension2; > + } > + > + /** > + * @return the first dimension. > + */ > + public int getDimension1() { > + return dimension1; > + } > + /** > + * @return the second dimension. > + */ > + public int getDimension2() { > + return dimension2; > + } > +} > > Propchange: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/DimensionMismatchException.java > ------------------------------------------------------------------------------ > svn:eol-style = native > > Added: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalArgumentException.java > URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalArgumentException.java?rev=957518&view=auto > ============================================================================== > --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalArgumentException.java (added) > +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalArgumentException.java Thu Jun 24 12:09:14 2010 > @@ -0,0 +1,63 @@ > +/* > + * Licensed to the Apache Software Foundation (ASF) under one or more > + * contributor license agreements. See the NOTICE file distributed with > + * this work for additional information regarding copyright ownership. > + * The ASF licenses this file to You under the Apache License, Version 2.0 > + * (the "License"); you may not use this file except in compliance with > + * the License. You may obtain a copy of the License at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in writing, software > + * distributed under the License is distributed on an "AS IS" BASIS, > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > + * See the License for the specific language governing permissions and > + * limitations under the License. > + */ > +package org.apache.commons.math.exception; > + > +import java.util.Locale; > +import org.apache.commons.math.util.Localizable; > + > +/** > + * Base class for all preconditions violation exceptions. > + * This class is not intended to be instantiated directly in most case: it > + * should serve as a base class to create all the exceptions that share the > + * semantics of the standard {@link IllegalArgumentException}, but must also > + * provide a localized message. > + * > + * @since 2.2 > + * @version $Revision$ $Date$ > + */ > +public class MathIllegalArgumentException extends IllegalArgumentException { > + /** > + * Pattern used to build the message. > + */ > + private final Localizable pattern; > + /** > + * Arguments used to build the message. > + */ > + private final Object[] arguments; > + > + /** > + * @param pattern Message pattern. > + * @param arguments Arguments. > + */ > + protected MathIllegalArgumentException(Localizable pattern, > + Object ... arguments) { > + this.pattern = pattern; > + this.arguments = arguments.clone(); I would have used something like: this.arguments = (arguments == null) ? new Object[0] : arguments.clone(); I think this would prevent problems for message patterns without any arguments. Luc > + } > + > + /** {@inheritDoc} */ > + @Override > + public String getMessage() { > + return MessageFactory.buildMessage(Locale.US, pattern, arguments); > + } > + > + /** {@inheritDoc} */ > + @Override > + public String getLocalizedMessage() { > + return MessageFactory.buildMessage(Locale.getDefault(), pattern, arguments); > + } > +} > > Propchange: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalArgumentException.java > ------------------------------------------------------------------------------ > svn:eol-style = native > > Added: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MessageFactory.java > URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MessageFactory.java?rev=957518&view=auto > ============================================================================== > --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MessageFactory.java (added) > +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MessageFactory.java Thu Jun 24 12:09:14 2010 > @@ -0,0 +1,49 @@ > +/* > + * Licensed to the Apache Software Foundation (ASF) under one or more > + * contributor license agreements. See the NOTICE file distributed with > + * this work for additional information regarding copyright ownership. > + * The ASF licenses this file to You under the Apache License, Version 2.0 > + * (the "License"); you may not use this file except in compliance with > + * the License. You may obtain a copy of the License at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in writing, software > + * distributed under the License is distributed on an "AS IS" BASIS, > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > + * See the License for the specific language governing permissions and > + * limitations under the License. > + */ > +package org.apache.commons.math.exception; > + > +import java.text.MessageFormat; > +import java.util.Locale; > +import org.apache.commons.math.util.Localizable; > + > +/** > + * Class for constructing localized messages. > + * > + * @since 2.2 > + * @version $Revision$ $Date$ > + */ > +public class MessageFactory { > + /** > + * Class contains only static methods. > + */ > + private MessageFactory() {} > + > + /** > + * Builds a message string by from a pattern and its arguments. > + * > + * @param locale Locale in which the message should be translated. > + * @param pattern Format specifier. > + * @param arguments Format arguments. > + * @return a message string. > + * @since 2.2 > + */ > + public static String buildMessage(Locale locale, > + Localizable pattern, > + Object ... arguments) { > + return new MessageFormat(pattern.getLocalizedString(locale), locale).format(arguments); > + } > +} > > Propchange: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MessageFactory.java > ------------------------------------------------------------------------------ > svn:eol-style = native > > Added: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/OutOfRangeException.java > URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/OutOfRangeException.java?rev=957518&view=auto > ============================================================================== > --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/OutOfRangeException.java (added) > +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/OutOfRangeException.java Thu Jun 24 12:09:14 2010 > @@ -0,0 +1,70 @@ > +/* > + * Licensed to the Apache Software Foundation (ASF) under one or more > + * contributor license agreements. See the NOTICE file distributed with > + * this work for additional information regarding copyright ownership. > + * The ASF licenses this file to You under the Apache License, Version 2.0 > + * (the "License"); you may not use this file except in compliance with > + * the License. You may obtain a copy of the License at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in writing, software > + * distributed under the License is distributed on an "AS IS" BASIS, > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > + * See the License for the specific language governing permissions and > + * limitations under the License. > + */ > +package org.apache.commons.math.exception; > + > +import org.apache.commons.math.util.LocalizedFormats; > + > +/** > + * Exception to be thrown when some argument is out of range. > + * > + * @since 2.2 > + * @version $Revision$ $Date$ > + */ > +public class OutOfRangeException extends MathIllegalArgumentException { > + /** Lower bound. */ > + private final Number lo; > + /** Higher bound. */ > + private final Number hi; > + /** Requested. */ > + private final Number requested; > + > + /** > + * Construct an exception from the mismatched dimensions. > + * > + * @param requested Requested value. > + * @param lo Lower bound. > + * @param hi Higher bound. > + */ > + public OutOfRangeException(Number requested, > + Number lo, > + Number hi) { > + super(LocalizedFormats.OUT_OF_RANGE_SIMPLE, requested, lo, hi); > + > + this.requested = requested; > + this.lo = lo; > + this.hi = hi; > + } > + > + /** > + * @return the requested value. > + */ > + public Number getRequested() { > + return requested; > + } > + /** > + * @return the lower bound. > + */ > + public Number getLo() { > + return lo; > + } > + /** > + * @return the higher bound. > + */ > + public Number getHi() { > + return hi; > + } > +} > > Propchange: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/OutOfRangeException.java > ------------------------------------------------------------------------------ > svn:eol-style = native > > Modified: commons/proper/math/trunk/src/site/xdoc/changes.xml > URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/changes.xml?rev=957518&r1=957517&r2=957518&view=diff > ============================================================================== > --- commons/proper/math/trunk/src/site/xdoc/changes.xml (original) > +++ commons/proper/math/trunk/src/site/xdoc/changes.xml Thu Jun 24 12:09:14 2010 > @@ -52,6 +52,9 @@ The type attribute can be add,u > If the output is not quite correct, check for invisible trailing spaces! > --> > > + > + Created package "exception" to contain the new exceptions hierarchy. > + > > Implementation of linear interpolation. > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org