1. // SAX locator interface for document events.
  2. // No warranty; no copyright -- use this as you will.
  3. // $Id: Locator.java,v 1.1 2001/05/20 03:12:56 curcuru Exp $
  4. package org.xml.sax;
  5. /**
  6. * Interface for associating a SAX event with a document location.
  7. *
  8. * <blockquote>
  9. * <em>This module, both source code and documentation, is in the
  10. * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
  11. * </blockquote>
  12. *
  13. * <p>If a SAX parser provides location information to the SAX
  14. * application, it does so by implementing this interface and then
  15. * passing an instance to the application using the content
  16. * handler's {@link org.xml.sax.ContentHandler#setDocumentLocator
  17. * setDocumentLocator} method. The application can use the
  18. * object to obtain the location of any other content handler event
  19. * in the XML source document.</p>
  20. *
  21. * <p>Note that the results returned by the object will be valid only
  22. * during the scope of each content handler method: the application
  23. * will receive unpredictable results if it attempts to use the
  24. * locator at any other time.</p>
  25. *
  26. * <p>SAX parsers are not required to supply a locator, but they are
  27. * very strongly encouraged to do so. If the parser supplies a
  28. * locator, it must do so before reporting any other document events.
  29. * If no locator has been set by the time the application receives
  30. * the {@link org.xml.sax.ContentHandler#startDocument startDocument}
  31. * event, the application should assume that a locator is not
  32. * available.</p>
  33. *
  34. * @since SAX 1.0
  35. * @author David Megginson,
  36. * <a href="mailto:sax@megginson.com">sax@megginson.com</a>
  37. * @version 2.0r2pre
  38. * @see org.xml.sax.ContentHandler#setDocumentLocator
  39. */
  40. public interface Locator {
  41. /**
  42. * Return the public identifier for the current document event.
  43. *
  44. * <p>The return value is the public identifier of the document
  45. * entity or of the external parsed entity in which the markup
  46. * triggering the event appears.</p>
  47. *
  48. * @return A string containing the public identifier, or
  49. * null if none is available.
  50. * @see #getSystemId
  51. */
  52. public abstract String getPublicId ();
  53. /**
  54. * Return the system identifier for the current document event.
  55. *
  56. * <p>The return value is the system identifier of the document
  57. * entity or of the external parsed entity in which the markup
  58. * triggering the event appears.</p>
  59. *
  60. * <p>If the system identifier is a URL, the parser must resolve it
  61. * fully before passing it to the application.</p>
  62. *
  63. * @return A string containing the system identifier, or null
  64. * if none is available.
  65. * @see #getPublicId
  66. */
  67. public abstract String getSystemId ();
  68. /**
  69. * Return the line number where the current document event ends.
  70. *
  71. * <p><strong>Warning:</strong> The return value from the method
  72. * is intended only as an approximation for the sake of error
  73. * reporting; it is not intended to provide sufficient information
  74. * to edit the character content of the original XML document.</p>
  75. *
  76. * <p>The return value is an approximation of the line number
  77. * in the document entity or external parsed entity where the
  78. * markup triggering the event appears.</p>
  79. *
  80. * <p>If possible, the SAX driver should provide the line position
  81. * of the first character after the text associated with the document
  82. * event. The first line in the document is line 1.</p>
  83. *
  84. * @return The line number, or -1 if none is available.
  85. * @see #getColumnNumber
  86. */
  87. public abstract int getLineNumber ();
  88. /**
  89. * Return the column number where the current document event ends.
  90. *
  91. * <p><strong>Warning:</strong> The return value from the method
  92. * is intended only as an approximation for the sake of error
  93. * reporting; it is not intended to provide sufficient information
  94. * to edit the character content of the original XML document.</p>
  95. *
  96. * <p>The return value is an approximation of the column number
  97. * in the document entity or external parsed entity where the
  98. * markup triggering the event appears.</p>
  99. *
  100. * <p>If possible, the SAX driver should provide the line position
  101. * of the first character after the text associated with the document
  102. * event.</p>
  103. *
  104. * <p>If possible, the SAX driver should provide the line position
  105. * of the first character after the text associated with the document
  106. * event. The first column in each line is column 1.</p>
  107. *
  108. * @return The column number, or -1 if none is available.
  109. * @see #getLineNumber
  110. */
  111. public abstract int getColumnNumber ();
  112. }
  113. // end of Locator.java