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