1. // Locator2.java - extended Locator
  2. // http://www.saxproject.org
  3. // Public Domain: no warranty.
  4. // $Id: Locator2.java,v 1.1.2.1 2004/05/01 08:34:44 jsuttor Exp $
  5. package org.xml.sax.ext;
  6. import org.xml.sax.Locator;
  7. /**
  8. * SAX2 extension to augment the entity information provided
  9. * though a {@link Locator}.
  10. * If an implementation supports this extension, the Locator
  11. * provided in {@link org.xml.sax.ContentHandler#setDocumentLocator
  12. * ContentHandler.setDocumentLocator() } will implement this
  13. * interface, and the
  14. * <em>http://xml.org/sax/features/use-locator2</em> feature
  15. * flag will have the value <em>true</em>.
  16. *
  17. * <blockquote>
  18. * <em>This module, both source code and documentation, is in the
  19. * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
  20. * </blockquote>
  21. *
  22. * <p> XMLReader implementations are not required to support this
  23. * information, and it is not part of core-only SAX2 distributions.</p>
  24. *
  25. * @since SAX 2.0 (extensions 1.1 alpha)
  26. * @author David Brownell
  27. * @version TBS
  28. */
  29. public interface Locator2 extends Locator
  30. {
  31. /**
  32. * Returns the version of XML used for the entity. This will
  33. * normally be the identifier from the current entity's
  34. * <em><?xml version='...' ...?></em> declaration,
  35. * or be defaulted by the parser.
  36. *
  37. * @return Identifier for the XML version being used to interpret
  38. * the entity's text, or null if that information is not yet
  39. * available in the current parsing state.
  40. */
  41. public String getXMLVersion ();
  42. /**
  43. * Returns the name of the character encoding for the entity.
  44. * If the encoding was declared externally (for example, in a MIME
  45. * Content-Type header), that will be the name returned. Else if there
  46. * was an <em><?xml ...encoding='...'?></em> declaration at
  47. * the start of the document, that encoding name will be returned.
  48. * Otherwise the encoding will been inferred (normally to be UTF-8, or
  49. * some UTF-16 variant), and that inferred name will be returned.
  50. *
  51. * <p>When an {@link org.xml.sax.InputSource InputSource} is used
  52. * to provide an entity's character stream, this method returns the
  53. * encoding provided in that input stream.
  54. *
  55. * <p> Note that some recent W3C specifications require that text
  56. * in some encodings be normalized, using Unicode Normalization
  57. * Form C, before processing. Such normalization must be performed
  58. * by applications, and would normally be triggered based on the
  59. * value returned by this method.
  60. *
  61. * <p> Encoding names may be those used by the underlying JVM,
  62. * and comparisons should be case-insensitive.
  63. *
  64. * @return Name of the character encoding being used to interpret
  65. * * the entity's text, or null if this was not provided for a *
  66. * character stream passed through an InputSource or is otherwise
  67. * not yet available in the current parsing state.
  68. */
  69. public String getEncoding ();
  70. }