1. /*
  2. * Copyright 1999-2004 The Apache Software Foundation.
  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. /*
  17. * $Id: NodeLocator.java,v 1.3 2004/02/16 23:06:11 minchau Exp $
  18. */
  19. package com.sun.org.apache.xml.internal.dtm.ref;
  20. import javax.xml.transform.SourceLocator;
  21. /**
  22. * <code>NodeLocator</code> maintains information on an XML source
  23. * node.
  24. *
  25. * @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
  26. * @since May 23, 2001
  27. */
  28. public class NodeLocator implements SourceLocator
  29. {
  30. protected String m_publicId;
  31. protected String m_systemId;
  32. protected int m_lineNumber;
  33. protected int m_columnNumber;
  34. /**
  35. * Creates a new <code>NodeLocator</code> instance.
  36. *
  37. * @param publicId a <code>String</code> value
  38. * @param systemId a <code>String</code> value
  39. * @param lineNumber an <code>int</code> value
  40. * @param columnNumber an <code>int</code> value
  41. */
  42. public NodeLocator(String publicId, String systemId,
  43. int lineNumber, int columnNumber)
  44. {
  45. this.m_publicId = publicId;
  46. this.m_systemId = systemId;
  47. this.m_lineNumber = lineNumber;
  48. this.m_columnNumber = columnNumber;
  49. }
  50. /**
  51. * <code>getPublicId</code> returns the public ID of the node.
  52. *
  53. * @return a <code>String</code> value
  54. */
  55. public String getPublicId()
  56. {
  57. return m_publicId;
  58. }
  59. /**
  60. * <code>getSystemId</code> returns the system ID of the node.
  61. *
  62. * @return a <code>String</code> value
  63. */
  64. public String getSystemId()
  65. {
  66. return m_systemId;
  67. }
  68. /**
  69. * <code>getLineNumber</code> returns the line number of the node.
  70. *
  71. * @return an <code>int</code> value
  72. */
  73. public int getLineNumber()
  74. {
  75. return m_lineNumber;
  76. }
  77. /**
  78. * <code>getColumnNumber</code> returns the column number of the
  79. * node.
  80. *
  81. * @return an <code>int</code> value
  82. */
  83. public int getColumnNumber()
  84. {
  85. return m_columnNumber;
  86. }
  87. /**
  88. * <code>toString</code> returns a string representation of this
  89. * NodeLocator instance.
  90. *
  91. * @return a <code>String</code> value
  92. */
  93. public String toString()
  94. {
  95. return "file '" + m_systemId
  96. + "', line #" + m_lineNumber
  97. + ", column #" + m_columnNumber;
  98. }
  99. }