Diagnostic.java 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /* Diagnostic.java --
  2. Copyright (C) 2008 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package javax.tools;
  32. import java.util.Locale;
  33. /**
  34. * Encapsulates diagnostic information from a tool. This usually includes
  35. * (but is not required) a position in a source file, line and column number
  36. * information and a message.
  37. *
  38. * @author Roman Kennke (roman@kennke.org)
  39. *
  40. * @param <S> the type of the source object
  41. *
  42. * @since 1.6
  43. */
  44. public interface Diagnostic<S>
  45. {
  46. /**
  47. * The kind of diagnostic information.
  48. */
  49. public static enum Kind
  50. {
  51. /**
  52. * Indicates and error.
  53. */
  54. ERROR,
  55. /**
  56. * Indicates a warning.
  57. */
  58. WARNING,
  59. /**
  60. * Indicates a mandatory warning.
  61. */
  62. MANDATORY_WARNING,
  63. /**
  64. * Indicates a note.
  65. */
  66. NOTE,
  67. /**
  68. * Indicates something else.
  69. */
  70. OTHER
  71. }
  72. /**
  73. * Indicates that this diagnostic object doesn't carry position information.
  74. */
  75. public static final long NOPOS = -1L;
  76. /**
  77. * Returns the kind of this diagnostic object.
  78. *
  79. * @return the kind of this diagnostic object
  80. */
  81. Kind getKind();
  82. /**
  83. * Returns the source of this diagnostic object.
  84. *
  85. * @return the source of this diagnostic object
  86. */
  87. S getSource();
  88. /**
  89. * Returns the position in the source object. This is a zero based value,
  90. * or {@link # NOPOS}, indicating that this doesn't carry position
  91. * information.
  92. *
  93. * @return the position in the source object
  94. */
  95. long getPosition();
  96. /**
  97. * Returns the start position in the source object. This is a zero based
  98. * value, or {@link #NOPOS}, indicating that this doesn't carry position
  99. * information.
  100. *
  101. * @return the start position in the source object
  102. */
  103. long getStartPosition();
  104. /*
  105. * Returns the end position in the source object. This is a zero based
  106. * value, or {@link #NOPOS}, indicating that this doesn't carry position
  107. * information.
  108. *
  109. * @return the end position in the source object
  110. */
  111. long getEndPosition();
  112. /**
  113. * Returns the line number or {@link #NOPOS}, indicating that this doesn't
  114. * carry position information. This is a 1-based value indicating the line
  115. * in the source object.
  116. *
  117. * @return the line number
  118. */
  119. long getLineNumber();
  120. /**
  121. * Returns the column number or {@link #NOPOS}, indicating that this doesn't
  122. * carry position information. This is a 1-based value indicating the column
  123. * in the source object.
  124. *
  125. * @return the column number
  126. */
  127. long getColumnNumber();
  128. /**
  129. * Return a diagnostic code. This is implementation dependend and might
  130. * be <code>null</code>.
  131. *
  132. * @return a diagnostic code or <code>null</code>
  133. */
  134. String getCode();
  135. /**
  136. * Returns a localized message. This is implementation dependend. If
  137. * <code>locale</code> is <code>null</code> this uses the default locale.
  138. *
  139. * @param locale the locale, or <code>null</code>
  140. *
  141. * @return a localized message
  142. */
  143. String getMessage(Locale locale);
  144. }