Locator2
Stay organized with collections
Save and categorize content based on your preferences.
Known Indirect Subclasses
Locator2Impl |
SAX2 extension helper for holding additional Entity information,
implementing the Locator2 interface. |
|
SAX2 extension to augment the entity information provided
though a Locator
.
If an implementation supports this extension, the Locator
provided in ContentHandler.setDocumentLocator()
will implement this
interface, and the
http://xml.org/sax/features/use-locator2 feature
flag will have the value true.
This module, both source code and documentation, is in the
Public Domain, and comes with NO WARRANTY.
XMLReader implementations are not required to support this
information, and it is not part of core-only SAX2 distributions.
Public Methods
public
abstract
String
getEncoding
()
Returns the name of the character encoding for the entity.
If the encoding was declared externally (for example, in a MIME
Content-Type header), that will be the name returned. Else if there
was an <?xml ...encoding='...'?> declaration at
the start of the document, that encoding name will be returned.
Otherwise the encoding will been inferred (normally to be UTF-8, or
some UTF-16 variant), and that inferred name will be returned.
When an InputSource
is used
to provide an entity's character stream, this method returns the
encoding provided in that input stream.
Note that some recent W3C specifications require that text
in some encodings be normalized, using Unicode Normalization
Form C, before processing. Such normalization must be performed
by applications, and would normally be triggered based on the
value returned by this method.
Encoding names may be those used by the underlying JVM,
and comparisons should be case-insensitive.
Returns
- Name of the character encoding being used to interpret
* the entity's text, or null if this was not provided for a *
character stream passed through an InputSource or is otherwise
not yet available in the current parsing state.
public
abstract
String
getXMLVersion
()
Returns the version of XML used for the entity. This will
normally be the identifier from the current entity's
<?xml version='...' ...?> declaration,
or be defaulted by the parser.
Returns
- Identifier for the XML version being used to interpret
the entity's text, or null if that information is not yet
available in the current parsing state.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003e\u003ccode\u003eLocator2\u003c/code\u003e is a SAX2 extension that enhances the entity information provided through a \u003ccode\u003eLocator\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eImplementations supporting this extension provide a \u003ccode\u003eLocator\u003c/code\u003e that implements the \u003ccode\u003eLocator2\u003c/code\u003e interface and set the \u003cem\u003ehttp://xml.org/sax/features/use-locator2\u003c/em\u003e feature flag to \u003cem\u003etrue\u003c/em\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIt offers methods to retrieve the character encoding (\u003ccode\u003egetEncoding\u003c/code\u003e) and XML version (\u003ccode\u003egetXMLVersion\u003c/code\u003e) used for the entity.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eLocator2\u003c/code\u003e is not a mandatory part of core-only SAX2 distributions, and XMLReader implementations are not obligated to support it.\u003c/p\u003e\n"]]],["`Locator2` augments entity information within SAX2. It provides methods to retrieve the character encoding (`getEncoding`) and XML version (`getXMLVersion`) used for an entity. `Locator2` implementations can also provide line and column numbers, as well as public and system identifiers, from its parent interface `Locator`. If the feature is supported, a `ContentHandler` will use `Locator2` with the feature flag *http://xml.org/sax/features/use-locator2* set to true.\n"],null,["public interface **Locator2** implements [Locator](../../../../../reference/org/xml/sax/Locator.html) \n\n|---|---|---|\n| Known Indirect Subclasses [Locator2Impl](../../../../../reference/org/xml/sax/ext/Locator2Impl.html) |----------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Locator2Impl](../../../../../reference/org/xml/sax/ext/Locator2Impl.html) | SAX2 extension helper for holding additional Entity information, implementing the [Locator2](../../../../../reference/org/xml/sax/ext/Locator2.html) interface. | |||\n\nSAX2 extension to augment the entity information provided\nthough a [Locator](../../../../../reference/org/xml/sax/Locator.html).\nIf an implementation supports this extension, the Locator\nprovided in [ContentHandler.setDocumentLocator()](../../../../../reference/org/xml/sax/ContentHandler.html#setDocumentLocator(org.xml.sax.Locator)) will implement this\ninterface, and the\n*http://xml.org/sax/features/use-locator2* feature\nflag will have the value *true*.\n\n\u003e *This module, both source code and documentation, is in the\n\u003e Public Domain, and comes with **NO WARRANTY**.*\n\nXMLReader implementations are not required to support this\ninformation, and it is not part of core-only SAX2 distributions.\n\n\u003cbr /\u003e\n\nPublic Method Summary\n\n|-------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [String](../../../../../reference/java/lang/String.html) | [getEncoding](../../../../../reference/org/xml/sax/ext/Locator2.html#getEncoding())() Returns the name of the character encoding for the entity. |\n| abstract [String](../../../../../reference/java/lang/String.html) | [getXMLVersion](../../../../../reference/org/xml/sax/ext/Locator2.html#getXMLVersion())() Returns the version of XML used for the entity. |\n\nInherited Method Summary \nFrom interface [org.xml.sax.Locator](../../../../../reference/org/xml/sax/Locator.html) \n\n|-------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract int | [getColumnNumber](../../../../../reference/org/xml/sax/Locator.html#getColumnNumber())() Return the column number where the current document event ends. |\n| abstract int | [getLineNumber](../../../../../reference/org/xml/sax/Locator.html#getLineNumber())() Return the line number where the current document event ends. |\n| abstract [String](../../../../../reference/java/lang/String.html) | [getPublicId](../../../../../reference/org/xml/sax/Locator.html#getPublicId())() Return the public identifier for the current document event. |\n| abstract [String](../../../../../reference/java/lang/String.html) | [getSystemId](../../../../../reference/org/xml/sax/Locator.html#getSystemId())() Return the system identifier for the current document event. |\n\nPublic Methods \n\npublic abstract [String](../../../../../reference/java/lang/String.html)\n**getEncoding**\n() \nReturns the name of the character encoding for the entity.\nIf the encoding was declared externally (for example, in a MIME\nContent-Type header), that will be the name returned. Else if there\nwas an *\\\u003c?xml ...encoding='...'?\\\u003e* declaration at\nthe start of the document, that encoding name will be returned.\nOtherwise the encoding will been inferred (normally to be UTF-8, or\nsome UTF-16 variant), and that inferred name will be returned.\n\nWhen an [InputSource](../../../../../reference/org/xml/sax/InputSource.html) is used\nto provide an entity's character stream, this method returns the\nencoding provided in that input stream.\n\nNote that some recent W3C specifications require that text\nin some encodings be normalized, using Unicode Normalization\nForm C, before processing. Such normalization must be performed\nby applications, and would normally be triggered based on the\nvalue returned by this method.\n\nEncoding names may be those used by the underlying JVM,\nand comparisons should be case-insensitive. \n\nReturns\n\n- Name of the character encoding being used to interpret \\* the entity's text, or null if this was not provided for a \\* character stream passed through an InputSource or is otherwise not yet available in the current parsing state. \n\npublic abstract [String](../../../../../reference/java/lang/String.html)\n**getXMLVersion**\n() \nReturns the version of XML used for the entity. This will\nnormally be the identifier from the current entity's\n*\\\u003c?xml version='...' ...?\\\u003e* declaration,\nor be defaulted by the parser. \n\nReturns\n\n- Identifier for the XML version being used to interpret the entity's text, or null if that information is not yet available in the current parsing state."]]