1 /*
   2  * Copyright (c) 2004, 2019, 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 package org.xml.sax.ext;
  27 
  28 import org.xml.sax.Locator;
  29 
  30 
  31 /**
  32  * SAX2 extension to augment the entity information provided
  33  * through a {@link Locator}.
  34  * If an implementation supports this extension, the Locator
  35  * provided in {@link org.xml.sax.ContentHandler#setDocumentLocator
  36  * ContentHandler.setDocumentLocator() } will implement this
  37  * interface, and the
  38  * <em>http://xml.org/sax/features/use-locator2</em> feature
  39  * flag will have the value <em>true</em>.
  40  *
  41  * <p> XMLReader implementations are not required to support this
  42  * information, and it is not part of core-only SAX2 distributions.</p>
  43  *
  44  * @since 1.5, SAX 2.0 (extensions 1.1 alpha)
  45  * @author David Brownell
  46  */
  47 public interface Locator2 extends Locator
  48 {
  49     /**
  50      * Returns the version of XML used for the entity.  This will
  51      * normally be the identifier from the current entity's
  52      * <em>&lt;?xml&nbsp;version='...'&nbsp;...?&gt;</em> declaration,
  53      * or be defaulted by the parser.
  54      *
  55      * @return Identifier for the XML version being used to interpret
  56      * the entity's text, or null if that information is not yet
  57      * available in the current parsing state.
  58      */
  59     public String getXMLVersion ();
  60 
  61     /**
  62      * Returns the name of the character encoding for the entity.
  63      * If the encoding was declared externally (for example, in a MIME
  64      * Content-Type header), that will be the name returned.  Else if there
  65      * was an <em>&lt;?xml&nbsp;...encoding='...'?&gt;</em> declaration at
  66      * the start of the document, that encoding name will be returned.
  67      * Otherwise the encoding will been inferred (normally to be UTF-8, or
  68      * some UTF-16 variant), and that inferred name will be returned.
  69      *
  70      * <p>When an {@link org.xml.sax.InputSource InputSource} is used
  71      * to provide an entity's character stream, this method returns the
  72      * encoding provided in that input stream.
  73      *
  74      * <p> Note that some recent W3C specifications require that text
  75      * in some encodings be normalized, using Unicode Normalization
  76      * Form C, before processing.  Such normalization must be performed
  77      * by applications, and would normally be triggered based on the
  78      * value returned by this method.
  79      *
  80      * <p> Encoding names may be those used by the underlying JVM,
  81      * and comparisons should be case-insensitive.
  82      *
  83      * @return Name of the character encoding being used to interpret
  84      * * the entity's text, or null if this was not provided for a *
  85      * character stream passed through an InputSource or is otherwise
  86      * not yet available in the current parsing state.
  87      */
  88     public String getEncoding ();
  89 }