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