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