001    // SAX locator interface for document events.
002    // http://www.saxproject.org
003    // No warranty; no copyright -- use this as you will.
004    // $Id: Locator.java,v 1.1 2004/12/23 22:38:42 mark Exp $
005    
006    package org.xml.sax;
007    
008    
009    /**
010     * Interface for associating a SAX event with a document location.
011     *
012     * <blockquote>
013     * <em>This module, both source code and documentation, is in the
014     * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
015     * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
016     * for further information.
017     * </blockquote>
018     *
019     * <p>If a SAX parser provides location information to the SAX
020     * application, it does so by implementing this interface and then
021     * passing an instance to the application using the content
022     * handler's {@link org.xml.sax.ContentHandler#setDocumentLocator
023     * setDocumentLocator} method.  The application can use the
024     * object to obtain the location of any other SAX event
025     * in the XML source document.</p>
026     *
027     * <p>Note that the results returned by the object will be valid only
028     * during the scope of each callback method: the application
029     * will receive unpredictable results if it attempts to use the
030     * locator at any other time, or after parsing completes.</p>
031     *
032     * <p>SAX parsers are not required to supply a locator, but they are
033     * very strongly encouraged to do so.  If the parser supplies a
034     * locator, it must do so before reporting any other document events.
035     * If no locator has been set by the time the application receives
036     * the {@link org.xml.sax.ContentHandler#startDocument startDocument}
037     * event, the application should assume that a locator is not 
038     * available.</p>
039     *
040     * @since SAX 1.0
041     * @author David Megginson
042     * @version 2.0.1 (sax2r2)
043     * @see org.xml.sax.ContentHandler#setDocumentLocator 
044     */
045    public interface Locator {
046        
047        
048        /**
049         * Return the public identifier for the current document event.
050         *
051         * <p>The return value is the public identifier of the document
052         * entity or of the external parsed entity in which the markup
053         * triggering the event appears.</p>
054         *
055         * @return A string containing the public identifier, or
056         *         null if none is available.
057         * @see #getSystemId
058         */
059        public abstract String getPublicId ();
060        
061        
062        /**
063         * Return the system identifier for the current document event.
064         *
065         * <p>The return value is the system identifier of the document
066         * entity or of the external parsed entity in which the markup
067         * triggering the event appears.</p>
068         *
069         * <p>If the system identifier is a URL, the parser must resolve it
070         * fully before passing it to the application.  For example, a file
071         * name must always be provided as a <em>file:...</em> URL, and other
072         * kinds of relative URI are also resolved against their bases.</p>
073         *
074         * @return A string containing the system identifier, or null
075         *         if none is available.
076         * @see #getPublicId
077         */
078        public abstract String getSystemId ();
079        
080        
081        /**
082         * Return the line number where the current document event ends.
083         * Lines are delimited by line ends, which are defined in
084         * the XML specification.
085         *
086         * <p><strong>Warning:</strong> The return value from the method
087         * is intended only as an approximation for the sake of diagnostics;
088         * it is not intended to provide sufficient information
089         * to edit the character content of the original XML document.
090         * In some cases, these "line" numbers match what would be displayed
091         * as columns, and in others they may not match the source text
092         * due to internal entity expansion.  </p>
093         *
094         * <p>The return value is an approximation of the line number
095         * in the document entity or external parsed entity where the
096         * markup triggering the event appears.</p>
097         *
098         * <p>If possible, the SAX driver should provide the line position 
099         * of the first character after the text associated with the document 
100         * event.  The first line is line 1.</p>
101         *
102         * @return The line number, or -1 if none is available.
103         * @see #getColumnNumber
104         */
105        public abstract int getLineNumber ();
106        
107        
108        /**
109         * Return the column number where the current document event ends.
110         * This is one-based number of Java <code>char</code> values since
111         * the last line end.
112         *
113         * <p><strong>Warning:</strong> The return value from the method
114         * is intended only as an approximation for the sake of diagnostics;
115         * it is not intended to provide sufficient information
116         * to edit the character content of the original XML document.
117         * For example, when lines contain combining character sequences, wide
118         * characters, surrogate pairs, or bi-directional text, the value may
119         * not correspond to the column in a text editor's display. </p>
120         *
121         * <p>The return value is an approximation of the column number
122         * in the document entity or external parsed entity where the
123         * markup triggering the event appears.</p>
124         *
125         * <p>If possible, the SAX driver should provide the line position 
126         * of the first character after the text associated with the document 
127         * event.  The first column in each line is column 1.</p>
128         *
129         * @return The column number, or -1 if none is available.
130         * @see #getLineNumber
131         */
132        public abstract int getColumnNumber ();
133        
134    }
135    
136    // end of Locator.java