Name

Locator

Synopsis

A XMLReader may pass an object that implements this interface to the application by calling the setDocumentLocator( ) method of the application’s ContentHandler object before it invokes any other methods of that ContentHandler. The ContentHandler can use methods of this Locator object from within any of the other methods called by the parser in order to determine what document the parser is parsing and what line number and column number it is parsing at. This information is particularly useful when displaying error or warning messages, for example. getSystemId( ) and getPublicId( ) return the system and public identifiers of the document being parsed, if this information is available to the parser, and otherwise return null. getLineNumber( ) and getColumnNumber( ) return the line number and column number of the next character that the parser will read (line and column numbers are numbered starting at 1, not at 0). The parser is allowed to return an approximate value from these methods, or to return -1 if it does not track line and column numbers.

public interface Locator {
// Public Instance Methods
     int getColumnNumber( );  
     int getLineNumber( );  
     String getPublicId( );  
     String getSystemId( );  
}

Implementations

org.xml.sax.ext.Locator2, org.xml.sax.helpers.LocatorImpl

Passed To

org.xml.sax.ContentHandler.setDocumentLocator( ), DocumentHandler.setDocumentLocator( ), HandlerBase.setDocumentLocator( ), SAXParseException.SAXParseException( ), org.xml.sax.ext.Locator2Impl.Locator2Impl( ...

Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.