View Javadoc
1   /*
2    * Copyright 2007 Edward Kuns
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *
16   * $Id: Location.java 0000 2007-01-09 00:10:00-0600 ekuns $
17   */
18  package org.castor.xmlctf.xmldiff.xml;
19  
20  import org.xml.sax.Locator;
21  
22  /**
23   * An immutable class for storing XML file location information.
24   *
25   * @author <a href="mailto:edward.kuns@aspect.com">Edward Kuns</a>
26   * @version $Revision: 0000 $ $Date: 2007-01-09 00:10:00 -0600 (Tue, 09 Jan 2007) $
27   * @since Castor 1.1
28   */
29  public class Location {
30  
31      /** Line number. */
32      private final int _line;
33      /** Column number. */
34      private final int _column;
35  
36      /**
37       * Creates a new Location with the current values from the provided Locator.
38       *
39       * @param locator a SAX locator
40       */
41      public Location(Locator locator) {
42          _line   = locator.getLineNumber();
43          _column = locator.getColumnNumber();
44      }
45  
46      /**
47       * Returns the column number.
48       * @return the column number.
49       */
50      public int getColumnNumber() {
51          return _column;
52      }
53  
54      /**
55       * Returns the line number.
56       * @return the line number.
57       */
58      public int getLineNumber() {
59          return _line;
60      }
61  
62  }