Locator
Stay organized with collections
Save and categorize content based on your preferences.
Known Indirect Subclasses
Locator2 |
SAX2 extension to augment the entity information provided
though a Locator . |
Locator2Impl |
SAX2 extension helper for holding additional Entity information,
implementing the Locator2 interface. |
LocatorImpl |
Provide an optional convenience implementation of Locator. |
|
Interface for associating a SAX event with a document location.
This module, both source code and documentation, is in the
Public Domain, and comes with NO WARRANTY.
See http://www.saxproject.org
for further information.
If a SAX parser provides location information to the SAX
application, it does so by implementing this interface and then
passing an instance to the application using the content
handler's setDocumentLocator
method. The application can use the
object to obtain the location of any other SAX event
in the XML source document.
Note that the results returned by the object will be valid only
during the scope of each callback method: the application
will receive unpredictable results if it attempts to use the
locator at any other time, or after parsing completes.
SAX parsers are not required to supply a locator, but they are
very strongly encouraged to do so. If the parser supplies a
locator, it must do so before reporting any other document events.
If no locator has been set by the time the application receives
the startDocument
event, the application should assume that a locator is not
available.
Public Method Summary
abstract
int
|
getColumnNumber()
Return the column number where the current document event ends.
|
abstract
int
|
getLineNumber()
Return the line number where the current document event ends.
|
abstract
String
|
getPublicId()
Return the public identifier for the current document event.
|
abstract
String
|
getSystemId()
Return the system identifier for the current document event.
|
Public Methods
public
abstract
int
getColumnNumber
()
Return the column number where the current document event ends.
This is one-based number of Java char
values since
the last line end.
Warning: The return value from the method
is intended only as an approximation for the sake of diagnostics;
it is not intended to provide sufficient information
to edit the character content of the original XML document.
For example, when lines contain combining character sequences, wide
characters, surrogate pairs, or bi-directional text, the value may
not correspond to the column in a text editor's display.
The return value is an approximation of the column number
in the document entity or external parsed entity where the
markup triggering the event appears.
If possible, the SAX driver should provide the line position
of the first character after the text associated with the document
event. The first column in each line is column 1.
Returns
- The column number, or -1 if none is available.
public
abstract
int
getLineNumber
()
Return the line number where the current document event ends.
Lines are delimited by line ends, which are defined in
the XML specification.
Warning: The return value from the method
is intended only as an approximation for the sake of diagnostics;
it is not intended to provide sufficient information
to edit the character content of the original XML document.
In some cases, these "line" numbers match what would be displayed
as columns, and in others they may not match the source text
due to internal entity expansion.
The return value is an approximation of the line number
in the document entity or external parsed entity where the
markup triggering the event appears.
If possible, the SAX driver should provide the line position
of the first character after the text associated with the document
event. The first line is line 1.
Returns
- The line number, or -1 if none is available.
public
abstract
String
getPublicId
()
Return the public identifier for the current document event.
The return value is the public identifier of the document
entity or of the external parsed entity in which the markup
triggering the event appears.
Returns
- A string containing the public identifier, or
null if none is available.
public
abstract
String
getSystemId
()
Return the system identifier for the current document event.
The return value is the system identifier of the document
entity or of the external parsed entity in which the markup
triggering the event appears.
If the system identifier is a URL, the parser must resolve it
fully before passing it to the application. For example, a file
name must always be provided as a file:... URL, and other
kinds of relative URI are also resolved against their bases.
Returns
- A string containing the system identifier, or null
if none is available.
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\u003eThe \u003ccode\u003eLocator\u003c/code\u003e interface in SAX associates SAX events with the location in the XML document where they occurred.\u003c/p\u003e\n"],["\u003cp\u003eSAX parsers are strongly encouraged to provide a \u003ccode\u003eLocator\u003c/code\u003e instance to the application, allowing it to track event locations.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eLocator\u003c/code\u003e provides methods to retrieve line and column numbers, as well as public and system identifiers for the current event.\u003c/p\u003e\n"],["\u003cp\u003eThe information from \u003ccode\u003eLocator\u003c/code\u003e is primarily for diagnostic purposes and should not be used to edit the XML document's content directly.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eLocator\u003c/code\u003e information is only valid during the scope of the callback method and may yield unpredictable results if used outside of it.\u003c/p\u003e\n"]]],[],null,["# Locator\n\npublic interface **Locator** \n\n|---|---|---|\n| Known Indirect Subclasses [Locator2](../../../../reference/org/xml/sax/ext/Locator2.html), [Locator2Impl](../../../../reference/org/xml/sax/ext/Locator2Impl.html), [LocatorImpl](../../../../reference/org/xml/sax/helpers/LocatorImpl.html) |---------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Locator2](../../../../reference/org/xml/sax/ext/Locator2.html) | SAX2 extension to augment the entity information provided though a [Locator](../../../../reference/org/xml/sax/Locator.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. | | [LocatorImpl](../../../../reference/org/xml/sax/helpers/LocatorImpl.html) | Provide an optional convenience implementation of Locator. | |||\n\nInterface for associating a SAX event with a document location.\n\n\u003e *This module, both source code and documentation, is in the\n\u003e Public Domain, and comes with **NO WARRANTY**.* See \u003chttp://www.saxproject.org\u003e for further information.\n\nIf a SAX parser provides location information to the SAX\napplication, it does so by implementing this interface and then\npassing an instance to the application using the content\nhandler's [setDocumentLocator](../../../../reference/org/xml/sax/ContentHandler.html#setDocumentLocator(org.xml.sax.Locator)) method. The application can use the\nobject to obtain the location of any other SAX event\nin the XML source document.\n\nNote that the results returned by the object will be valid only\nduring the scope of each callback method: the application\nwill receive unpredictable results if it attempts to use the\nlocator at any other time, or after parsing completes.\n\nSAX parsers are not required to supply a locator, but they are\nvery strongly encouraged to do so. If the parser supplies a\nlocator, it must do so before reporting any other document events.\nIf no locator has been set by the time the application receives\nthe [startDocument](../../../../reference/org/xml/sax/ContentHandler.html#startDocument())\nevent, the application should assume that a locator is not\navailable.\n\n\u003cbr /\u003e\n\n##### See Also\n\n- [ContentHandler.setDocumentLocator(Locator)](../../../../reference/org/xml/sax/ContentHandler.html#setDocumentLocator(org.xml.sax.Locator)) \n\n### Public Method Summary\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--------------\n\n#### public abstract int\n**getColumnNumber**\n()\n\nReturn the column number where the current document event ends.\nThis is one-based number of Java `char` values since\nthe last line end.\n\n**Warning:** The return value from the method\nis intended only as an approximation for the sake of diagnostics;\nit is not intended to provide sufficient information\nto edit the character content of the original XML document.\nFor example, when lines contain combining character sequences, wide\ncharacters, surrogate pairs, or bi-directional text, the value may\nnot correspond to the column in a text editor's display.\n\nThe return value is an approximation of the column number\nin the document entity or external parsed entity where the\nmarkup triggering the event appears.\n\nIf possible, the SAX driver should provide the line position\nof the first character after the text associated with the document\nevent. The first column in each line is column 1.\n\n\u003cbr /\u003e\n\n##### Returns\n\n- The column number, or -1 if none is available. \n\n##### See Also\n\n- [getLineNumber()](../../../../reference/org/xml/sax/Locator.html#getLineNumber()) \n\n#### public abstract int\n**getLineNumber**\n()\n\nReturn the line number where the current document event ends.\nLines are delimited by line ends, which are defined in\nthe XML specification.\n\n**Warning:** The return value from the method\nis intended only as an approximation for the sake of diagnostics;\nit is not intended to provide sufficient information\nto edit the character content of the original XML document.\nIn some cases, these \"line\" numbers match what would be displayed\nas columns, and in others they may not match the source text\ndue to internal entity expansion.\n\nThe return value is an approximation of the line number\nin the document entity or external parsed entity where the\nmarkup triggering the event appears.\n\nIf possible, the SAX driver should provide the line position\nof the first character after the text associated with the document\nevent. The first line is line 1.\n\n\u003cbr /\u003e\n\n##### Returns\n\n- The line number, or -1 if none is available. \n\n##### See Also\n\n- [getColumnNumber()](../../../../reference/org/xml/sax/Locator.html#getColumnNumber()) \n\n#### public abstract [String](../../../../reference/java/lang/String.html)\n**getPublicId**\n()\n\nReturn the public identifier for the current document event.\n\nThe return value is the public identifier of the document\nentity or of the external parsed entity in which the markup\ntriggering the event appears.\n\n\u003cbr /\u003e\n\n##### Returns\n\n- A string containing the public identifier, or null if none is available. \n\n##### See Also\n\n- [getSystemId()](../../../../reference/org/xml/sax/Locator.html#getSystemId()) \n\n#### public abstract [String](../../../../reference/java/lang/String.html)\n**getSystemId**\n()\n\nReturn the system identifier for the current document event.\n\nThe return value is the system identifier of the document\nentity or of the external parsed entity in which the markup\ntriggering the event appears.\n\nIf the system identifier is a URL, the parser must resolve it\nfully before passing it to the application. For example, a file\nname must always be provided as a *file:...* URL, and other\nkinds of relative URI are also resolved against their bases.\n\n\u003cbr /\u003e\n\n##### Returns\n\n- A string containing the system identifier, or null if none is available. \n\n##### See Also\n\n- [getPublicId()](../../../../reference/org/xml/sax/Locator.html#getPublicId())"]]