com.android.tools.lint.detector.api
Enum TextFormat

java.lang.Object
  extended by java.lang.Enum<TextFormat>
      extended by com.android.tools.lint.detector.api.TextFormat
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<TextFormat>

public enum TextFormat
extends java.lang.Enum<TextFormat>

Lint error message, issue explanations and location descriptions are described in a RAW format which looks similar to text but which can contain bold, symbols and links. These issues can also be converted to plain text and to HTML markup, using the convertTo(String, TextFormat) method.

See Also:
Issue#getDescription(TextFormat), Issue.getExplanation(TextFormat), Issue.getBriefDescription(TextFormat)

Enum Constant Summary
HTML
          HTML formatted output (note: does not include surrounding <html></html> tags)
HTML_WITH_UNICODE
          HTML formatted output (note: does not include surrounding <html></html> tags).
RAW
          Raw output format which is similar to text but allows some markup: HTTP urls (http://...) Sentences immediately surrounded by * will be shown as bold.
TEXT
          Plain text output
 
Method Summary
 java.lang.String convertTo(java.lang.String message, TextFormat to)
          Converts the given message to the given format.
 java.lang.String toHtml(java.lang.String text)
          Converts the given text to HTML
 java.lang.String toText(java.lang.String text)
          Converts the given text to plain text
static TextFormat valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static TextFormat[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

RAW

public static final TextFormat RAW
Raw output format which is similar to text but allows some markup: Furthermore, newlines are converted to br's when converting newlines. Note: It does not insert <html> tags around the fragment for HTML output.

TODO: Consider switching to the restructured text format - http://docutils.sourceforge.net/docs/user/rst/quickstart.html


TEXT

public static final TextFormat TEXT
Plain text output


HTML

public static final TextFormat HTML
HTML formatted output (note: does not include surrounding <html></html> tags)


HTML_WITH_UNICODE

public static final TextFormat HTML_WITH_UNICODE
HTML formatted output (note: does not include surrounding <html></html> tags). This is like HTML, but it does not escape unicode characters with entities.

(This is used for example in the IDE, where some partial HTML support in some label widgets support some HTML markup, but not numeric code character entities.)

Method Detail

values

public static TextFormat[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (TextFormat c : TextFormat.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static TextFormat valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

toHtml

@NonNull
public java.lang.String toHtml(@NonNull
                                       java.lang.String text)
Converts the given text to HTML

Parameters:
text - the text to format
Returns:
the corresponding text formatted as HTML

toText

@NonNull
public java.lang.String toText(@NonNull
                                       java.lang.String text)
Converts the given text to plain text

Parameters:
text - the tetx to format
Returns:
the corresponding text formatted as HTML

convertTo

public java.lang.String convertTo(@NonNull
                                  java.lang.String message,
                                  @NonNull
                                  TextFormat to)
Converts the given message to the given format. Note that some conversions are lossy; e.g. once converting away from the raw format (which contains all the markup) you can't convert back to it. Note that you can convert to the format it's already in; that just returns the same string.

Parameters:
message - the message to convert
to - the format to convert to
Returns:
a converted message