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: 746578 $ $Date: 2009-02-21 15:01:14 -0500 (Sat, 21 Feb 2009) $
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}", dimension1, dimension2);
37 this.dimension1 = dimension1;
38 this.dimension2 = dimension2;
39 }
40
41 /**
42 * Get the first dimension
43 * @return first dimension
44 */
45 public int getDimension1() {
46 return dimension1;
47 }
48
49 /**
50 * Get the second dimension
51 * @return second dimension
52 */
53 public int getDimension2() {
54 return dimension2;
55 }
56
57 /** First dimension. */
58 private int dimension1;
59
60 /** Second dimension. */
61 private int dimension2;
62
63 }