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;
018    
019    /**
020     * Error thrown when two dimensions differ.
021     * 
022     * @since 1.2
023     * @version $Revision: 746578 $ $Date: 2009-02-21 15:01:14 -0500 (Sat, 21 Feb 2009) $
024     */
025    public class DimensionMismatchException extends MathException {
026        
027        /** Serializable version identifier */
028        private static final long serialVersionUID = -1316089546353786411L;
029    
030        /**
031         * Construct an exception from the mismatched dimensions
032         * @param dimension1 first dimension
033         * @param dimension2 second dimension
034         */
035        public DimensionMismatchException(int dimension1, int dimension2) {
036            super("dimension mismatch {0} != {1}", dimension1, dimension2);
037            this.dimension1 = dimension1;
038            this.dimension2 = dimension2;
039        }
040    
041        /**
042         * Get the first dimension
043         * @return first dimension
044         */
045        public int getDimension1() {
046            return dimension1;
047        }
048        
049        /**
050         * Get the second dimension
051         * @return second dimension
052         */
053        public int getDimension2() {
054            return dimension2;
055        }
056    
057        /** First dimension. */
058        private int dimension1;
059        
060        /** Second dimension. */
061        private int dimension2;
062        
063    }