12005
|
1 |
/*
|
58247
|
2 |
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
|
12005
|
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;
|
|
27 |
|
|
28 |
|
|
29 |
/**
|
|
30 |
* Interface for associating a SAX event with a document location.
|
|
31 |
*
|
|
32 |
* <p>If a SAX parser provides location information to the SAX
|
|
33 |
* application, it does so by implementing this interface and then
|
|
34 |
* passing an instance to the application using the content
|
|
35 |
* handler's {@link org.xml.sax.ContentHandler#setDocumentLocator
|
|
36 |
* setDocumentLocator} method. The application can use the
|
|
37 |
* object to obtain the location of any other SAX event
|
|
38 |
* in the XML source document.</p>
|
|
39 |
*
|
|
40 |
* <p>Note that the results returned by the object will be valid only
|
|
41 |
* during the scope of each callback method: the application
|
|
42 |
* will receive unpredictable results if it attempts to use the
|
|
43 |
* locator at any other time, or after parsing completes.</p>
|
|
44 |
*
|
|
45 |
* <p>SAX parsers are not required to supply a locator, but they are
|
|
46 |
* very strongly encouraged to do so. If the parser supplies a
|
|
47 |
* locator, it must do so before reporting any other document events.
|
|
48 |
* If no locator has been set by the time the application receives
|
|
49 |
* the {@link org.xml.sax.ContentHandler#startDocument startDocument}
|
|
50 |
* event, the application should assume that a locator is not
|
|
51 |
* available.</p>
|
|
52 |
*
|
25262
|
53 |
* @since 1.4, SAX 1.0
|
12005
|
54 |
* @author David Megginson
|
|
55 |
* @see org.xml.sax.ContentHandler#setDocumentLocator
|
|
56 |
*/
|
|
57 |
public interface Locator {
|
|
58 |
|
|
59 |
|
|
60 |
/**
|
|
61 |
* Return the public identifier for the current document event.
|
|
62 |
*
|
|
63 |
* <p>The return value is the public identifier of the document
|
|
64 |
* entity or of the external parsed entity in which the markup
|
|
65 |
* triggering the event appears.</p>
|
|
66 |
*
|
|
67 |
* @return A string containing the public identifier, or
|
|
68 |
* null if none is available.
|
|
69 |
* @see #getSystemId
|
|
70 |
*/
|
|
71 |
public abstract String getPublicId ();
|
|
72 |
|
|
73 |
|
|
74 |
/**
|
|
75 |
* Return the system identifier for the current document event.
|
|
76 |
*
|
|
77 |
* <p>The return value is the system identifier of the document
|
|
78 |
* entity or of the external parsed entity in which the markup
|
|
79 |
* triggering the event appears.</p>
|
|
80 |
*
|
|
81 |
* <p>If the system identifier is a URL, the parser must resolve it
|
|
82 |
* fully before passing it to the application. For example, a file
|
|
83 |
* name must always be provided as a <em>file:...</em> URL, and other
|
|
84 |
* kinds of relative URI are also resolved against their bases.</p>
|
|
85 |
*
|
|
86 |
* @return A string containing the system identifier, or null
|
|
87 |
* if none is available.
|
|
88 |
* @see #getPublicId
|
|
89 |
*/
|
|
90 |
public abstract String getSystemId ();
|
|
91 |
|
|
92 |
|
|
93 |
/**
|
|
94 |
* Return the line number where the current document event ends.
|
|
95 |
* Lines are delimited by line ends, which are defined in
|
|
96 |
* the XML specification.
|
|
97 |
*
|
|
98 |
* <p><strong>Warning:</strong> The return value from the method
|
|
99 |
* is intended only as an approximation for the sake of diagnostics;
|
|
100 |
* it is not intended to provide sufficient information
|
|
101 |
* to edit the character content of the original XML document.
|
|
102 |
* In some cases, these "line" numbers match what would be displayed
|
|
103 |
* as columns, and in others they may not match the source text
|
|
104 |
* due to internal entity expansion. </p>
|
|
105 |
*
|
|
106 |
* <p>The return value is an approximation of the line number
|
|
107 |
* in the document entity or external parsed entity where the
|
|
108 |
* markup triggering the event appears.</p>
|
|
109 |
*
|
|
110 |
* <p>If possible, the SAX driver should provide the line position
|
|
111 |
* of the first character after the text associated with the document
|
|
112 |
* event. The first line is line 1.</p>
|
|
113 |
*
|
|
114 |
* @return The line number, or -1 if none is available.
|
|
115 |
* @see #getColumnNumber
|
|
116 |
*/
|
|
117 |
public abstract int getLineNumber ();
|
|
118 |
|
|
119 |
|
|
120 |
/**
|
|
121 |
* Return the column number where the current document event ends.
|
|
122 |
* This is one-based number of Java <code>char</code> values since
|
|
123 |
* the last line end.
|
|
124 |
*
|
|
125 |
* <p><strong>Warning:</strong> The return value from the method
|
|
126 |
* is intended only as an approximation for the sake of diagnostics;
|
|
127 |
* it is not intended to provide sufficient information
|
|
128 |
* to edit the character content of the original XML document.
|
|
129 |
* For example, when lines contain combining character sequences, wide
|
|
130 |
* characters, surrogate pairs, or bi-directional text, the value may
|
|
131 |
* not correspond to the column in a text editor's display. </p>
|
|
132 |
*
|
|
133 |
* <p>The return value is an approximation of the column number
|
|
134 |
* in the document entity or external parsed entity where the
|
|
135 |
* markup triggering the event appears.</p>
|
|
136 |
*
|
|
137 |
* <p>If possible, the SAX driver should provide the line position
|
|
138 |
* of the first character after the text associated with the document
|
|
139 |
* event. The first column in each line is column 1.</p>
|
|
140 |
*
|
|
141 |
* @return The column number, or -1 if none is available.
|
|
142 |
* @see #getLineNumber
|
|
143 |
*/
|
|
144 |
public abstract int getColumnNumber ();
|
|
145 |
|
|
146 |
}
|
|
147 |
|
|
148 |
// end of Locator.java
|