0N/A/*
553N/A * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
553N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
553N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
553N/A * or visit www.oracle.com if you need additional information or have any
553N/A * questions.
0N/A */
0N/A
0N/Apackage javax.tools;
0N/A
0N/Aimport java.util.Locale;
0N/A
0N/A/**
0N/A * Interface for diagnostics from tools. A diagnostic usually reports
0N/A * a problem at a specific position in a source file. However, not
0N/A * all diagnostics are associated with a position or a file.
0N/A *
0N/A * <p>A position is a zero-based character offset from the beginning of
0N/A * a file. Negative values (except {@link #NOPOS}) are not valid
0N/A * positions.
0N/A *
0N/A * <p>Line and column numbers begin at 1. Negative values (except
0N/A * {@link #NOPOS}) and 0 are not valid line or column numbers.
0N/A *
0N/A * @param <S> the type of source object used by this diagnostic
0N/A *
0N/A * @author Peter von der Ah&eacute;
0N/A * @author Jonathan Gibbons
0N/A * @since 1.6
0N/A */
0N/Apublic interface Diagnostic<S> {
0N/A
0N/A /**
0N/A * Kinds of diagnostics, for example, error or warning.
0N/A */
0N/A enum Kind {
0N/A /**
0N/A * Problem which prevents the tool's normal completion.
0N/A */
0N/A ERROR,
0N/A /**
0N/A * Problem which does not usually prevent the tool from
0N/A * completing normally.
0N/A */
0N/A WARNING,
0N/A /**
0N/A * Problem similar to a warning, but is mandated by the tool's
0N/A * specification. For example, the Java&trade; Language
0N/A * Specification, 3rd Ed. mandates warnings on certain
0N/A * unchecked operations and the use of deprecated methods.
0N/A */
0N/A MANDATORY_WARNING,
0N/A /**
0N/A * Informative message from the tool.
0N/A */
0N/A NOTE,
0N/A /**
0N/A * Diagnostic which does not fit within the other kinds.
0N/A */
0N/A OTHER,
0N/A }
0N/A
0N/A /**
0N/A * Used to signal that no position is available.
0N/A */
0N/A public final static long NOPOS = -1;
0N/A
0N/A /**
0N/A * Gets the kind of this diagnostic, for example, error or
0N/A * warning.
0N/A * @return the kind of this diagnostic
0N/A */
0N/A Kind getKind();
0N/A
0N/A /**
0N/A * Gets the source object associated with this diagnostic.
0N/A *
0N/A * @return the source object associated with this diagnostic.
0N/A * {@code null} if no source object is associated with the
0N/A * diagnostic.
0N/A */
0N/A S getSource();
0N/A
0N/A /**
0N/A * Gets a character offset from the beginning of the source object
0N/A * associated with this diagnostic that indicates the location of
0N/A * the problem. In addition, the following must be true:
0N/A *
0N/A * <p>{@code getStartPostion() <= getPosition()}
0N/A * <p>{@code getPosition() <= getEndPosition()}
0N/A *
0N/A * @return character offset from beginning of source; {@link
0N/A * #NOPOS} if {@link #getSource()} would return {@code null} or if
0N/A * no location is suitable
0N/A */
0N/A long getPosition();
0N/A
0N/A /**
0N/A * Gets the character offset from the beginning of the file
0N/A * associated with this diagnostic that indicates the start of the
0N/A * problem.
0N/A *
0N/A * @return offset from beginning of file; {@link #NOPOS} if and
0N/A * only if {@link #getPosition()} returns {@link #NOPOS}
0N/A */
0N/A long getStartPosition();
0N/A
0N/A /**
0N/A * Gets the character offset from the beginning of the file
0N/A * associated with this diagnostic that indicates the end of the
0N/A * problem.
0N/A *
0N/A * @return offset from beginning of file; {@link #NOPOS} if and
0N/A * only if {@link #getPosition()} returns {@link #NOPOS}
0N/A */
0N/A long getEndPosition();
0N/A
0N/A /**
0N/A * Gets the line number of the character offset returned by
0N/A * {@linkplain #getPosition()}.
0N/A *
0N/A * @return a line number or {@link #NOPOS} if and only if {@link
0N/A * #getPosition()} returns {@link #NOPOS}
0N/A */
0N/A long getLineNumber();
0N/A
0N/A /**
0N/A * Gets the column number of the character offset returned by
0N/A * {@linkplain #getPosition()}.
0N/A *
0N/A * @return a column number or {@link #NOPOS} if and only if {@link
0N/A * #getPosition()} returns {@link #NOPOS}
0N/A */
0N/A long getColumnNumber();
0N/A
0N/A /**
0N/A * Gets a diagnostic code indicating the type of diagnostic. The
0N/A * code is implementation-dependent and might be {@code null}.
0N/A *
0N/A * @return a diagnostic code
0N/A */
0N/A String getCode();
0N/A
0N/A /**
0N/A * Gets a localized message for the given locale. The actual
0N/A * message is implementation-dependent. If the locale is {@code
0N/A * null} use the default locale.
0N/A *
0N/A * @param locale a locale; might be {@code null}
0N/A * @return a localized message
0N/A */
0N/A String getMessage(Locale locale);
0N/A}