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: 811827 $ $Date: 2009-09-06 11:32:50 -0400 (Sun, 06 Sep 2009) $
024     */
025    public class DimensionMismatchException extends MathException {
026    
027        /** Serializable version identifier */
028        private static final long serialVersionUID = -1316089546353786411L;
029    
030        /** First dimension. */
031        private final int dimension1;
032    
033        /** Second dimension. */
034        private final int dimension2;
035    
036        /**
037         * Construct an exception from the mismatched dimensions
038         * @param dimension1 first dimension
039         * @param dimension2 second dimension
040         */
041        public DimensionMismatchException(final int dimension1, final int dimension2) {
042            super("dimension mismatch {0} != {1}", dimension1, dimension2);
043            this.dimension1 = dimension1;
044            this.dimension2 = dimension2;
045        }
046    
047        /**
048         * Get the first dimension
049         * @return first dimension
050         */
051        public int getDimension1() {
052            return dimension1;
053        }
054    
055        /**
056         * Get the second dimension
057         * @return second dimension
058         */
059        public int getDimension2() {
060            return dimension2;
061        }
062    
063    }