1/*
2 * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26// Locator2Impl.java - extended LocatorImpl
27// http://www.saxproject.org
28// Public Domain: no warranty.
29// $Id: Locator2Impl.java,v 1.2 2004/11/03 22:49:08 jsuttor Exp $
30
31package org.xml.sax.ext;
32
33import org.xml.sax.Locator;
34import org.xml.sax.helpers.LocatorImpl;
35
36
37/**
38 * SAX2 extension helper for holding additional Entity information,
39 * implementing the {@link Locator2} interface.
40 *
41 * <blockquote>
42 * <em>This module, both source code and documentation, is in the
43 * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
44 * </blockquote>
45 *
46 * <p> This is not part of core-only SAX2 distributions.</p>
47 *
48 * @since 1.5, SAX 2.0.2
49 * @author David Brownell
50 */
51public class Locator2Impl extends LocatorImpl implements Locator2
52{
53    private String      encoding;
54    private String      version;
55
56
57    /**
58     * Construct a new, empty Locator2Impl object.
59     * This will not normally be useful, since the main purpose
60     * of this class is to make a snapshot of an existing Locator.
61     */
62    public Locator2Impl () { }
63
64    /**
65     * Copy an existing Locator or Locator2 object.
66     * If the object implements Locator2, values of the
67     * <em>encoding</em> and <em>version</em>strings are copied,
68     * otherwise they set to <em>null</em>.
69     *
70     * @param locator The existing Locator object.
71     */
72    public Locator2Impl (Locator locator)
73    {
74        super (locator);
75        if (locator instanceof Locator2) {
76            Locator2    l2 = (Locator2) locator;
77
78            version = l2.getXMLVersion ();
79            encoding = l2.getEncoding ();
80        }
81    }
82
83    ////////////////////////////////////////////////////////////////////
84    // Locator2 method implementations
85    ////////////////////////////////////////////////////////////////////
86
87    /**
88     * Returns the current value of the version property.
89     *
90     * @see #setXMLVersion
91     */
92    public String getXMLVersion ()
93        { return version; }
94
95    /**
96     * Returns the current value of the encoding property.
97     *
98     * @see #setEncoding
99     */
100    public String getEncoding ()
101        { return encoding; }
102
103
104    ////////////////////////////////////////////////////////////////////
105    // Setters
106    ////////////////////////////////////////////////////////////////////
107
108    /**
109     * Assigns the current value of the version property.
110     *
111     * @param version the new "version" value
112     * @see #getXMLVersion
113     */
114    public void setXMLVersion (String version)
115        { this.version = version; }
116
117    /**
118     * Assigns the current value of the encoding property.
119     *
120     * @param encoding the new "encoding" value
121     * @see #getEncoding
122     */
123    public void setEncoding (String encoding)
124        { this.encoding = encoding; }
125}
126