View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.math;
18  
19  /**
20   * Error thrown when two dimensions differ.
21   * 
22   * @since 1.2
23   * @version $Revision: 620312 $ $Date: 2008-02-10 12:28:59 -0700 (Sun, 10 Feb 2008) $
24   */
25  public class DimensionMismatchException extends MathException {
26      
27      /** Serializable version identifier */
28      private static final long serialVersionUID = -1316089546353786411L;
29  
30      /**
31       * Construct an exception from the mismatched dimensions
32       * @param dimension1 first dimension
33       * @param dimension2 second dimension
34       */
35      public DimensionMismatchException(int dimension1, int dimension2) {
36          super("dimension mismatch {0} != {1}",
37                new Object[] {
38                  new Integer(dimension1), new Integer(dimension2)
39                });
40          this.dimension1 = dimension1;
41          this.dimension2 = dimension2;
42      }
43  
44      /**
45       * Get the first dimension
46       * @return first dimension
47       */
48      public int getDimension1() {
49          return dimension1;
50      }
51      
52      /**
53       * Get the second dimension
54       * @return second dimension
55       */
56      public int getDimension2() {
57          return dimension2;
58      }
59  
60      /** First dimension. */
61      private int dimension1;
62      
63      /** Second dimension. */
64      private int dimension2;
65      
66  }