Wed, 13 Apr 2011 11:35:43 -0700
7032975: API files in javax.annotation.processing need to be updated for references to JLS
7032972: API files in javax.tools need to updated for references to JVM Spec with editions/hyperlinks
7032978: API files in javax.tools need to be updated for references to JLS with editions/hyperlinks
Summary: Removed URLs and 'edition' references
Reviewed-by: jjg, darcy
duke@1 | 1 | /* |
ohair@554 | 2 | * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@554 | 7 | * published by the Free Software Foundation. Oracle designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@554 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
duke@1 | 10 | * |
duke@1 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | * accompanied this code). |
duke@1 | 16 | * |
duke@1 | 17 | * You should have received a copy of the GNU General Public License version |
duke@1 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | * |
ohair@554 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 23 | * questions. |
duke@1 | 24 | */ |
duke@1 | 25 | |
duke@1 | 26 | package javax.tools; |
duke@1 | 27 | |
duke@1 | 28 | import java.util.Locale; |
duke@1 | 29 | |
duke@1 | 30 | /** |
duke@1 | 31 | * Interface for diagnostics from tools. A diagnostic usually reports |
duke@1 | 32 | * a problem at a specific position in a source file. However, not |
duke@1 | 33 | * all diagnostics are associated with a position or a file. |
duke@1 | 34 | * |
duke@1 | 35 | * <p>A position is a zero-based character offset from the beginning of |
duke@1 | 36 | * a file. Negative values (except {@link #NOPOS}) are not valid |
duke@1 | 37 | * positions. |
duke@1 | 38 | * |
duke@1 | 39 | * <p>Line and column numbers begin at 1. Negative values (except |
duke@1 | 40 | * {@link #NOPOS}) and 0 are not valid line or column numbers. |
duke@1 | 41 | * |
duke@1 | 42 | * @param <S> the type of source object used by this diagnostic |
duke@1 | 43 | * |
duke@1 | 44 | * @author Peter von der Ahé |
duke@1 | 45 | * @author Jonathan Gibbons |
duke@1 | 46 | * @since 1.6 |
duke@1 | 47 | */ |
duke@1 | 48 | public interface Diagnostic<S> { |
duke@1 | 49 | |
duke@1 | 50 | /** |
duke@1 | 51 | * Kinds of diagnostics, for example, error or warning. |
duke@1 | 52 | */ |
duke@1 | 53 | enum Kind { |
duke@1 | 54 | /** |
duke@1 | 55 | * Problem which prevents the tool's normal completion. |
duke@1 | 56 | */ |
duke@1 | 57 | ERROR, |
duke@1 | 58 | /** |
duke@1 | 59 | * Problem which does not usually prevent the tool from |
duke@1 | 60 | * completing normally. |
duke@1 | 61 | */ |
duke@1 | 62 | WARNING, |
duke@1 | 63 | /** |
duke@1 | 64 | * Problem similar to a warning, but is mandated by the tool's |
duke@1 | 65 | * specification. For example, the Java™ Language |
duke@1 | 66 | * Specification, 3rd Ed. mandates warnings on certain |
duke@1 | 67 | * unchecked operations and the use of deprecated methods. |
duke@1 | 68 | */ |
duke@1 | 69 | MANDATORY_WARNING, |
duke@1 | 70 | /** |
duke@1 | 71 | * Informative message from the tool. |
duke@1 | 72 | */ |
duke@1 | 73 | NOTE, |
duke@1 | 74 | /** |
duke@1 | 75 | * Diagnostic which does not fit within the other kinds. |
duke@1 | 76 | */ |
duke@1 | 77 | OTHER, |
duke@1 | 78 | } |
duke@1 | 79 | |
duke@1 | 80 | /** |
duke@1 | 81 | * Used to signal that no position is available. |
duke@1 | 82 | */ |
duke@1 | 83 | public final static long NOPOS = -1; |
duke@1 | 84 | |
duke@1 | 85 | /** |
duke@1 | 86 | * Gets the kind of this diagnostic, for example, error or |
duke@1 | 87 | * warning. |
duke@1 | 88 | * @return the kind of this diagnostic |
duke@1 | 89 | */ |
duke@1 | 90 | Kind getKind(); |
duke@1 | 91 | |
duke@1 | 92 | /** |
duke@1 | 93 | * Gets the source object associated with this diagnostic. |
duke@1 | 94 | * |
duke@1 | 95 | * @return the source object associated with this diagnostic. |
duke@1 | 96 | * {@code null} if no source object is associated with the |
duke@1 | 97 | * diagnostic. |
duke@1 | 98 | */ |
duke@1 | 99 | S getSource(); |
duke@1 | 100 | |
duke@1 | 101 | /** |
duke@1 | 102 | * Gets a character offset from the beginning of the source object |
duke@1 | 103 | * associated with this diagnostic that indicates the location of |
duke@1 | 104 | * the problem. In addition, the following must be true: |
duke@1 | 105 | * |
duke@1 | 106 | * <p>{@code getStartPostion() <= getPosition()} |
duke@1 | 107 | * <p>{@code getPosition() <= getEndPosition()} |
duke@1 | 108 | * |
duke@1 | 109 | * @return character offset from beginning of source; {@link |
duke@1 | 110 | * #NOPOS} if {@link #getSource()} would return {@code null} or if |
duke@1 | 111 | * no location is suitable |
duke@1 | 112 | */ |
duke@1 | 113 | long getPosition(); |
duke@1 | 114 | |
duke@1 | 115 | /** |
duke@1 | 116 | * Gets the character offset from the beginning of the file |
duke@1 | 117 | * associated with this diagnostic that indicates the start of the |
duke@1 | 118 | * problem. |
duke@1 | 119 | * |
duke@1 | 120 | * @return offset from beginning of file; {@link #NOPOS} if and |
duke@1 | 121 | * only if {@link #getPosition()} returns {@link #NOPOS} |
duke@1 | 122 | */ |
duke@1 | 123 | long getStartPosition(); |
duke@1 | 124 | |
duke@1 | 125 | /** |
duke@1 | 126 | * Gets the character offset from the beginning of the file |
duke@1 | 127 | * associated with this diagnostic that indicates the end of the |
duke@1 | 128 | * problem. |
duke@1 | 129 | * |
duke@1 | 130 | * @return offset from beginning of file; {@link #NOPOS} if and |
duke@1 | 131 | * only if {@link #getPosition()} returns {@link #NOPOS} |
duke@1 | 132 | */ |
duke@1 | 133 | long getEndPosition(); |
duke@1 | 134 | |
duke@1 | 135 | /** |
duke@1 | 136 | * Gets the line number of the character offset returned by |
duke@1 | 137 | * {@linkplain #getPosition()}. |
duke@1 | 138 | * |
duke@1 | 139 | * @return a line number or {@link #NOPOS} if and only if {@link |
duke@1 | 140 | * #getPosition()} returns {@link #NOPOS} |
duke@1 | 141 | */ |
duke@1 | 142 | long getLineNumber(); |
duke@1 | 143 | |
duke@1 | 144 | /** |
duke@1 | 145 | * Gets the column number of the character offset returned by |
duke@1 | 146 | * {@linkplain #getPosition()}. |
duke@1 | 147 | * |
duke@1 | 148 | * @return a column number or {@link #NOPOS} if and only if {@link |
duke@1 | 149 | * #getPosition()} returns {@link #NOPOS} |
duke@1 | 150 | */ |
duke@1 | 151 | long getColumnNumber(); |
duke@1 | 152 | |
duke@1 | 153 | /** |
duke@1 | 154 | * Gets a diagnostic code indicating the type of diagnostic. The |
duke@1 | 155 | * code is implementation-dependent and might be {@code null}. |
duke@1 | 156 | * |
duke@1 | 157 | * @return a diagnostic code |
duke@1 | 158 | */ |
duke@1 | 159 | String getCode(); |
duke@1 | 160 | |
duke@1 | 161 | /** |
duke@1 | 162 | * Gets a localized message for the given locale. The actual |
duke@1 | 163 | * message is implementation-dependent. If the locale is {@code |
duke@1 | 164 | * null} use the default locale. |
duke@1 | 165 | * |
duke@1 | 166 | * @param locale a locale; might be {@code null} |
duke@1 | 167 | * @return a localized message |
duke@1 | 168 | */ |
duke@1 | 169 | String getMessage(Locale locale); |
duke@1 | 170 | } |