1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the  "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 *     http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18/*
19 * $Id: NodeLocator.java 468653 2006-10-28 07:07:05Z minchau $
20 */
21
22package org.apache.xml.dtm.ref;
23
24import javax.xml.transform.SourceLocator;
25
26/**
27 * <code>NodeLocator</code> maintains information on an XML source
28 * node.
29 *
30 * @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
31 * @since May 23, 2001
32 */
33public class NodeLocator implements SourceLocator
34{
35  protected String m_publicId;
36  protected String m_systemId;
37  protected int m_lineNumber;
38  protected int m_columnNumber;
39
40  /**
41   * Creates a new <code>NodeLocator</code> instance.
42   *
43   * @param publicId a <code>String</code> value
44   * @param systemId a <code>String</code> value
45   * @param lineNumber an <code>int</code> value
46   * @param columnNumber an <code>int</code> value
47   */
48  public NodeLocator(String publicId, String systemId,
49                     int lineNumber, int columnNumber)
50  {
51    this.m_publicId = publicId;
52    this.m_systemId = systemId;
53    this.m_lineNumber = lineNumber;
54    this.m_columnNumber = columnNumber;
55  }
56
57  /**
58   * <code>getPublicId</code> returns the public ID of the node.
59   *
60   * @return a <code>String</code> value
61   */
62  public String getPublicId()
63  {
64    return m_publicId;
65  }
66
67  /**
68   * <code>getSystemId</code> returns the system ID of the node.
69   *
70   * @return a <code>String</code> value
71   */
72  public String getSystemId()
73  {
74    return m_systemId;
75  }
76
77  /**
78   * <code>getLineNumber</code> returns the line number of the node.
79   *
80   * @return an <code>int</code> value
81   */
82  public int getLineNumber()
83  {
84    return m_lineNumber;
85  }
86
87  /**
88   * <code>getColumnNumber</code> returns the column number of the
89   * node.
90   *
91   * @return an <code>int</code> value
92   */
93  public int getColumnNumber()
94  {
95    return m_columnNumber;
96  }
97
98  /**
99   * <code>toString</code> returns a string representation of this
100   * NodeLocator instance.
101   *
102   * @return a <code>String</code> value
103   */
104  public String toString()
105  {
106    return "file '" + m_systemId
107      + "', line #" + m_lineNumber
108      + ", column #" + m_columnNumber;
109  }
110}
111