1. // Locator2Impl.java - extended LocatorImpl
  2. // http://www.saxproject.org
  3. // Public Domain: no warranty.
  4. // $Id: Locator2Impl.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. import org.xml.sax.helpers.LocatorImpl;
  8. /**
  9. * SAX2 extension helper for holding additional Entity information,
  10. * implementing the {@link Locator2} interface.
  11. *
  12. * <blockquote>
  13. * <em>This module, both source code and documentation, is in the
  14. * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
  15. * </blockquote>
  16. *
  17. * <p> This is not part of core-only SAX2 distributions.</p>
  18. *
  19. * @since SAX 2.0.2
  20. * @author David Brownell
  21. * @version TBS
  22. */
  23. public class Locator2Impl extends LocatorImpl implements Locator2
  24. {
  25. private String encoding;
  26. private String version;
  27. /**
  28. * Construct a new, empty Locator2Impl object.
  29. * This will not normally be useful, since the main purpose
  30. * of this class is to make a snapshot of an existing Locator.
  31. */
  32. public Locator2Impl () { }
  33. /**
  34. * Copy an existing Locator or Locator2 object.
  35. * If the object implements Locator2, values of the
  36. * <em>encoding</em> and <em>version</em>strings are copied,
  37. * otherwise they set to <em>null</em>.
  38. *
  39. * @param locator The existing Locator object.
  40. */
  41. public Locator2Impl (Locator locator)
  42. {
  43. super (locator);
  44. if (locator instanceof Locator2) {
  45. Locator2 l2 = (Locator2) locator;
  46. version = l2.getXMLVersion ();
  47. encoding = l2.getEncoding ();
  48. }
  49. }
  50. ////////////////////////////////////////////////////////////////////
  51. // Locator2 method implementations
  52. ////////////////////////////////////////////////////////////////////
  53. /**
  54. * Returns the current value of the version property.
  55. *
  56. * @see #setXMLVersion
  57. */
  58. public String getXMLVersion ()
  59. { return version; }
  60. /**
  61. * Returns the current value of the encoding property.
  62. *
  63. * @see #setEncoding
  64. */
  65. public String getEncoding ()
  66. { return encoding; }
  67. ////////////////////////////////////////////////////////////////////
  68. // Setters
  69. ////////////////////////////////////////////////////////////////////
  70. /**
  71. * Assigns the current value of the version property.
  72. *
  73. * @param version the new "version" value
  74. * @see #getXMLVersion
  75. */
  76. public void setXMLVersion (String version)
  77. { this.version = version; }
  78. /**
  79. * Assigns the current value of the encoding property.
  80. *
  81. * @param encoding the new "encoding" value
  82. * @see #getEncoding
  83. */
  84. public void setEncoding (String encoding)
  85. { this.encoding = encoding; }
  86. }