001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.commons.math.exception; 018 019 import org.apache.commons.math.exception.util.Localizable; 020 021 /** 022 * Base class for exceptions raised by a wrong number. 023 * This class is not intended to be instantiated directly: it should serve 024 * as a base class to create all the exceptions that are raised because some 025 * precondition is violated by a number argument. 026 * 027 * @since 2.2 028 * @version $Revision$ $Date$ 029 */ 030 public class MathIllegalNumberException extends MathIllegalArgumentException { 031 032 /** Serializable version Id. */ 033 private static final long serialVersionUID = -7447085893598031110L; 034 035 /** Requested. */ 036 private final Number argument; 037 038 /** 039 * Construct an exception. 040 * 041 * @param specific Localizable pattern. 042 * @param general Localizable pattern. 043 * @param wrong wrong number 044 * @param arguments Arguments. 045 */ 046 protected MathIllegalNumberException(Localizable specific, 047 Localizable general, 048 Number wrong, 049 Object ... arguments) { 050 super(specific, general, wrong, arguments); 051 argument = wrong; 052 } 053 054 /** 055 * Construct an exception. 056 * 057 * @param general Localizable pattern. 058 * @param wrong wrong number 059 * @param arguments Arguments. 060 */ 061 protected MathIllegalNumberException(Localizable general, 062 Number wrong, 063 Object ... arguments) { 064 super(general, wrong, arguments); 065 argument = wrong; 066 } 067 068 /** 069 * @return the requested value. 070 */ 071 public Number getArgument() { 072 return argument; 073 } 074 }