1. // SAX locator interface for document events.
  2. // http://www.saxproject.org
  3. // No warranty; no copyright -- use this as you will.
  4. // $Id: Locator.java,v 1.1.24.1 2004/05/01 08:34:40 jsuttor Exp $
  5. package org.xml.sax;
  6. /**
  7. * Interface for associating a SAX event with a document location.
  8. *
  9. * <blockquote>
  10. * <em>This module, both source code and documentation, is in the
  11. * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
  12. * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
  13. * for further information.
  14. * </blockquote>
  15. *
  16. * <p>If a SAX parser provides location information to the SAX
  17. * application, it does so by implementing this interface and then
  18. * passing an instance to the application using the content
  19. * handler's {@link org.xml.sax.ContentHandler#setDocumentLocator
  20. * setDocumentLocator} method. The application can use the
  21. * object to obtain the location of any other SAX event
  22. * in the XML source document.</p>
  23. *
  24. * <p>Note that the results returned by the object will be valid only
  25. * during the scope of each callback method: the application
  26. * will receive unpredictable results if it attempts to use the
  27. * locator at any other time, or after parsing completes.</p>
  28. *
  29. * <p>SAX parsers are not required to supply a locator, but they are
  30. * very strongly encouraged to do so. If the parser supplies a
  31. * locator, it must do so before reporting any other document events.
  32. * If no locator has been set by the time the application receives
  33. * the {@link org.xml.sax.ContentHandler#startDocument startDocument}
  34. * event, the application should assume that a locator is not
  35. * available.</p>
  36. *
  37. * @since SAX 1.0
  38. * @author David Megginson
  39. * @version 2.0.1 (sax2r2)
  40. * @see org.xml.sax.ContentHandler#setDocumentLocator
  41. */
  42. public interface Locator {
  43. /**
  44. * Return the public identifier for the current document event.
  45. *
  46. * <p>The return value is the public identifier of the document
  47. * entity or of the external parsed entity in which the markup
  48. * triggering the event appears.</p>
  49. *
  50. * @return A string containing the public identifier, or
  51. * null if none is available.
  52. * @see #getSystemId
  53. */
  54. public abstract String getPublicId ();
  55. /**
  56. * Return the system identifier for the current document event.
  57. *
  58. * <p>The return value is the system identifier of the document
  59. * entity or of the external parsed entity in which the markup
  60. * triggering the event appears.</p>
  61. *
  62. * <p>If the system identifier is a URL, the parser must resolve it
  63. * fully before passing it to the application. For example, a file
  64. * name must always be provided as a <em>file:...</em> URL, and other
  65. * kinds of relative URI are also resolved against their bases.</p>
  66. *
  67. * @return A string containing the system identifier, or null
  68. * if none is available.
  69. * @see #getPublicId
  70. */
  71. public abstract String getSystemId ();
  72. /**
  73. * Return the line number where the current document event ends.
  74. * Lines are delimited by line ends, which are defined in
  75. * the XML specification.
  76. *
  77. * <p><strong>Warning:</strong> The return value from the method
  78. * is intended only as an approximation for the sake of diagnostics;
  79. * it is not intended to provide sufficient information
  80. * to edit the character content of the original XML document.
  81. * In some cases, these "line" numbers match what would be displayed
  82. * as columns, and in others they may not match the source text
  83. * due to internal entity expansion. </p>
  84. *
  85. * <p>The return value is an approximation of the line number
  86. * in the document entity or external parsed entity where the
  87. * markup triggering the event appears.</p>
  88. *
  89. * <p>If possible, the SAX driver should provide the line position
  90. * of the first character after the text associated with the document
  91. * event. The first line is line 1.</p>
  92. *
  93. * @return The line number, or -1 if none is available.
  94. * @see #getColumnNumber
  95. */
  96. public abstract int getLineNumber ();
  97. /**
  98. * Return the column number where the current document event ends.
  99. * This is one-based number of Java <code>char</code> values since
  100. * the last line end.
  101. *
  102. * <p><strong>Warning:</strong> The return value from the method
  103. * is intended only as an approximation for the sake of diagnostics;
  104. * it is not intended to provide sufficient information
  105. * to edit the character content of the original XML document.
  106. * For example, when lines contain combining character sequences, wide
  107. * characters, surrogate pairs, or bi-directional text, the value may
  108. * not correspond to the column in a text editor's display. </p>
  109. *
  110. * <p>The return value is an approximation of the column number
  111. * in the document entity or external parsed entity where the
  112. * markup triggering the event appears.</p>
  113. *
  114. * <p>If possible, the SAX driver should provide the line position
  115. * of the first character after the text associated with the document
  116. * event. The first column in each line is column 1.</p>
  117. *
  118. * @return The column number, or -1 if none is available.
  119. * @see #getLineNumber
  120. */
  121. public abstract int getColumnNumber ();
  122. }
  123. // end of Locator.java