jaxp/src/share/classes/org/xml/sax/Locator.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 6 7f561c08de6b
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
     2
 * Copyright 2000-2005 Sun Microsystems, Inc.  All Rights Reserved.
7f561c08de6b Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7f561c08de6b Initial load
duke
parents:
diff changeset
     4
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
7f561c08de6b Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
7f561c08de6b Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
7f561c08de6b Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
7f561c08de6b Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
7f561c08de6b Initial load
duke
parents:
diff changeset
    10
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
7f561c08de6b Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7f561c08de6b Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7f561c08de6b Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
7f561c08de6b Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
7f561c08de6b Initial load
duke
parents:
diff changeset
    16
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
7f561c08de6b Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
7f561c08de6b Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7f561c08de6b Initial load
duke
parents:
diff changeset
    20
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
 * have any questions.
7f561c08de6b Initial load
duke
parents:
diff changeset
    24
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
// SAX locator interface for document events.
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
// http://www.saxproject.org
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
// No warranty; no copyright -- use this as you will.
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
// $Id: Locator.java,v 1.2 2004/11/03 22:55:32 jsuttor Exp $
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
package org.xml.sax;
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
 * Interface for associating a SAX event with a document location.
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
 * <blockquote>
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
 * <em>This module, both source code and documentation, is in the
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
 * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
 * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
 * for further information.
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
 * </blockquote>
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
 * <p>If a SAX parser provides location information to the SAX
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
 * application, it does so by implementing this interface and then
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
 * passing an instance to the application using the content
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
 * handler's {@link org.xml.sax.ContentHandler#setDocumentLocator
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
 * setDocumentLocator} method.  The application can use the
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
 * object to obtain the location of any other SAX event
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
 * in the XML source document.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
 * <p>Note that the results returned by the object will be valid only
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
 * during the scope of each callback method: the application
7f561c08de6b Initial load
duke
parents:
diff changeset
    54
 * will receive unpredictable results if it attempts to use the
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
 * locator at any other time, or after parsing completes.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
 * <p>SAX parsers are not required to supply a locator, but they are
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
 * very strongly encouraged to do so.  If the parser supplies a
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
 * locator, it must do so before reporting any other document events.
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
 * If no locator has been set by the time the application receives
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
 * the {@link org.xml.sax.ContentHandler#startDocument startDocument}
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
 * event, the application should assume that a locator is not
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
 * available.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
 * @since SAX 1.0
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
 * @author David Megginson
7f561c08de6b Initial load
duke
parents:
diff changeset
    67
 * @see org.xml.sax.ContentHandler#setDocumentLocator
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
public interface Locator {
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
     * Return the public identifier for the current document event.
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
     * <p>The return value is the public identifier of the document
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
     * entity or of the external parsed entity in which the markup
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
     * triggering the event appears.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
     * @return A string containing the public identifier, or
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
     *         null if none is available.
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
     * @see #getSystemId
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
    public abstract String getPublicId ();
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
     * Return the system identifier for the current document event.
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
     * <p>The return value is the system identifier of the document
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
     * entity or of the external parsed entity in which the markup
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
     * triggering the event appears.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
     * <p>If the system identifier is a URL, the parser must resolve it
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
     * fully before passing it to the application.  For example, a file
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
     * name must always be provided as a <em>file:...</em> URL, and other
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
     * kinds of relative URI are also resolved against their bases.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    97
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
     * @return A string containing the system identifier, or null
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
     *         if none is available.
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
     * @see #getPublicId
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
    public abstract String getSystemId ();
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
7f561c08de6b Initial load
duke
parents:
diff changeset
   105
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
     * Return the line number where the current document event ends.
7f561c08de6b Initial load
duke
parents:
diff changeset
   107
     * Lines are delimited by line ends, which are defined in
7f561c08de6b Initial load
duke
parents:
diff changeset
   108
     * the XML specification.
7f561c08de6b Initial load
duke
parents:
diff changeset
   109
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   110
     * <p><strong>Warning:</strong> The return value from the method
7f561c08de6b Initial load
duke
parents:
diff changeset
   111
     * is intended only as an approximation for the sake of diagnostics;
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
     * it is not intended to provide sufficient information
7f561c08de6b Initial load
duke
parents:
diff changeset
   113
     * to edit the character content of the original XML document.
7f561c08de6b Initial load
duke
parents:
diff changeset
   114
     * In some cases, these "line" numbers match what would be displayed
7f561c08de6b Initial load
duke
parents:
diff changeset
   115
     * as columns, and in others they may not match the source text
7f561c08de6b Initial load
duke
parents:
diff changeset
   116
     * due to internal entity expansion.  </p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   117
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   118
     * <p>The return value is an approximation of the line number
7f561c08de6b Initial load
duke
parents:
diff changeset
   119
     * in the document entity or external parsed entity where the
7f561c08de6b Initial load
duke
parents:
diff changeset
   120
     * markup triggering the event appears.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   121
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
     * <p>If possible, the SAX driver should provide the line position
7f561c08de6b Initial load
duke
parents:
diff changeset
   123
     * of the first character after the text associated with the document
7f561c08de6b Initial load
duke
parents:
diff changeset
   124
     * event.  The first line is line 1.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   125
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   126
     * @return The line number, or -1 if none is available.
7f561c08de6b Initial load
duke
parents:
diff changeset
   127
     * @see #getColumnNumber
7f561c08de6b Initial load
duke
parents:
diff changeset
   128
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   129
    public abstract int getLineNumber ();
7f561c08de6b Initial load
duke
parents:
diff changeset
   130
7f561c08de6b Initial load
duke
parents:
diff changeset
   131
7f561c08de6b Initial load
duke
parents:
diff changeset
   132
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   133
     * Return the column number where the current document event ends.
7f561c08de6b Initial load
duke
parents:
diff changeset
   134
     * This is one-based number of Java <code>char</code> values since
7f561c08de6b Initial load
duke
parents:
diff changeset
   135
     * the last line end.
7f561c08de6b Initial load
duke
parents:
diff changeset
   136
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   137
     * <p><strong>Warning:</strong> The return value from the method
7f561c08de6b Initial load
duke
parents:
diff changeset
   138
     * is intended only as an approximation for the sake of diagnostics;
7f561c08de6b Initial load
duke
parents:
diff changeset
   139
     * it is not intended to provide sufficient information
7f561c08de6b Initial load
duke
parents:
diff changeset
   140
     * to edit the character content of the original XML document.
7f561c08de6b Initial load
duke
parents:
diff changeset
   141
     * For example, when lines contain combining character sequences, wide
7f561c08de6b Initial load
duke
parents:
diff changeset
   142
     * characters, surrogate pairs, or bi-directional text, the value may
7f561c08de6b Initial load
duke
parents:
diff changeset
   143
     * not correspond to the column in a text editor's display. </p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   144
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   145
     * <p>The return value is an approximation of the column number
7f561c08de6b Initial load
duke
parents:
diff changeset
   146
     * in the document entity or external parsed entity where the
7f561c08de6b Initial load
duke
parents:
diff changeset
   147
     * markup triggering the event appears.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   148
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   149
     * <p>If possible, the SAX driver should provide the line position
7f561c08de6b Initial load
duke
parents:
diff changeset
   150
     * of the first character after the text associated with the document
7f561c08de6b Initial load
duke
parents:
diff changeset
   151
     * event.  The first column in each line is column 1.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   152
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   153
     * @return The column number, or -1 if none is available.
7f561c08de6b Initial load
duke
parents:
diff changeset
   154
     * @see #getLineNumber
7f561c08de6b Initial load
duke
parents:
diff changeset
   155
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   156
    public abstract int getColumnNumber ();
7f561c08de6b Initial load
duke
parents:
diff changeset
   157
7f561c08de6b Initial load
duke
parents:
diff changeset
   158
}
7f561c08de6b Initial load
duke
parents:
diff changeset
   159
7f561c08de6b Initial load
duke
parents:
diff changeset
   160
// end of Locator.java