001: // Locator2Impl.java - extended LocatorImpl
002: // http://www.saxproject.org
003: // Public Domain: no warranty.
004: // $Id: Locator2Impl.java,v 1.3 2002/02/01 20:06:20 db Exp $
005:
006: package org.xml.sax.ext;
007:
008: import org.xml.sax.Locator;
009: import org.xml.sax.helpers.LocatorImpl;
010:
011: /**
012: * SAX2 extension helper for holding additional Entity information,
013: * implementing the {@link Locator2} interface.
014: *
015: * <blockquote>
016: * <em>This module, both source code and documentation, is in the
017: * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
018: * </blockquote>
019: *
020: * <p> This is not part of core-only SAX2 distributions.</p>
021: *
022: * @since SAX 2.0 (extensions 1.1 alpha)
023: * @author David Brownell
024: * @version TBS
025: */
026: public class Locator2Impl extends LocatorImpl implements Locator2 {
027: private String encoding;
028: private String version;
029:
030: /**
031: * Construct a new, empty Locator2Impl object.
032: * This will not normally be useful, since the main purpose
033: * of this class is to make a snapshot of an existing Locator.
034: */
035: public Locator2Impl() {
036: }
037:
038: /**
039: * Copy an existing Locator or Locator2 object.
040: * If the object implements Locator2, values of the
041: * <em>encoding</em> and <em>version</em>strings are copied,
042: * otherwise they set to <em>null</em>.
043: *
044: * @param locator The existing Locator object.
045: */
046: public Locator2Impl(Locator locator) {
047: super (locator);
048: if (locator instanceof Locator2) {
049: Locator2 l2 = (Locator2) locator;
050:
051: version = l2.getXMLVersion();
052: encoding = l2.getEncoding();
053: }
054: }
055:
056: ////////////////////////////////////////////////////////////////////
057: // Locator2 method implementations
058: ////////////////////////////////////////////////////////////////////
059:
060: /**
061: * Returns the current value of the version property.
062: *
063: * @see #setXMLVersion
064: */
065: public String getXMLVersion() {
066: return version;
067: }
068:
069: /**
070: * Returns the current value of the encoding property.
071: *
072: * @see #setEncoding
073: */
074: public String getEncoding() {
075: return encoding;
076: }
077:
078: ////////////////////////////////////////////////////////////////////
079: // Setters
080: ////////////////////////////////////////////////////////////////////
081:
082: /**
083: * Assigns the current value of the version property.
084: *
085: * @param version the new "version" value
086: * @see #getXMLVersion
087: */
088: public void setXMLVersion(String version) {
089: this .version = version;
090: }
091:
092: /**
093: * Assigns the current value of the encoding property.
094: *
095: * @param version the new "encoding" value
096: * @see #getEncoding
097: */
098: public void setEncoding(String encoding) {
099: this.encoding = encoding;
100: }
101: }
|