Tue, 20 Jan 2009 18:23:13 -0800
6795903: fix latent build warnings in langtools repository
Reviewed-by: darcy
1 /*
2 * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
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. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25 package com.sun.tools.javac.api;
27 import java.util.Locale;
28 import javax.tools.Diagnostic;
30 /**
31 * Provides simple functionalities for javac diagnostic formatting
32 * @param <D> type of diagnostic handled by this formatter
33 */
34 public interface DiagnosticFormatter<D extends Diagnostic<?>> {
36 /**
37 * Whether the source code output for this diagnostic is to be displayed
38 *
39 * @param diag diagnostic to be formatted
40 * @return true if the source line this diagnostic refers to is to be displayed
41 */
42 boolean displaySource(D diag);
44 /**
45 * Format the contents of a diagnostics
46 *
47 * @param diag the diagnostic to be formatted
48 * @param l locale object to be used for i18n
49 * @return a string representing the diagnostic
50 */
51 public String format(D diag, Locale l);
53 /**
54 * Controls the way in which a diagnostic message is displayed.
55 *
56 * @param diag diagnostic to be formatted
57 * @param l locale object to be used for i18n
58 * @return string representation of the diagnostic message
59 */
60 public String formatMessage(D diag,Locale l);
62 /**
63 * Controls the way in which a diagnostic kind is displayed.
64 *
65 * @param diag diagnostic to be formatted
66 * @param l locale object to be used for i18n
67 * @return string representation of the diagnostic prefix
68 */
69 public String formatKind(D diag, Locale l);
71 /**
72 * Controls the way in which a diagnostic source is displayed.
73 *
74 * @param diag diagnostic to be formatted
75 * @param l locale object to be used for i18n
76 * @param fullname whether the source fullname should be printed
77 * @return string representation of the diagnostic source
78 */
79 public String formatSource(D diag, boolean fullname, Locale l);
81 /**
82 * Controls the way in which a diagnostic position is displayed.
83 *
84 * @param diag diagnostic to be formatted
85 * @param pk enum constant representing the position kind
86 * @param l locale object to be used for i18n
87 * @return string representation of the diagnostic position
88 */
89 public String formatPosition(D diag, PositionKind pk, Locale l);
90 //where
91 /**
92 * This enum defines a set of constants for all the kinds of position
93 * that a diagnostic can be asked for. All positions are intended to be
94 * relative to a given diagnostic source.
95 */
96 public enum PositionKind {
97 /**
98 * Start position
99 */
100 START,
101 /**
102 * End position
103 */
104 END,
105 /**
106 * Line number
107 */
108 LINE,
109 /**
110 * Column number
111 */
112 COLUMN,
113 /**
114 * Offset position
115 */
116 OFFSET
117 }
118 }