com.android.tools.lint
Class Reporter

java.lang.Object
  extended by com.android.tools.lint.Reporter
Direct Known Subclasses:
HtmlReporter, TextReporter, XmlReporter

@Beta
public abstract class Reporter
extends java.lang.Object

A reporter is an output generator for lint warnings

NOTE: This is not a public or final API; if you rely on this be prepared to adjust your code for the next tools release.


Field Summary
protected  boolean mBundleResources
           
protected  LintCliClient mClient
           
protected  boolean mDisplayEmpty
           
protected  java.util.Map<java.lang.String,java.io.File> mNameToFile
           
protected  java.io.File mOutput
           
protected  java.io.File mResources
           
protected  java.util.Map<java.io.File,java.lang.String> mResourceUrl
           
protected  boolean mSimpleFormat
           
protected  java.lang.String mTitle
           
protected  java.util.Map<java.lang.String,java.lang.String> mUrlMap
           
 
Constructor Summary
protected Reporter(LintCliClient client, java.io.File output)
           
 
Method Summary
protected  java.lang.String addLocalResources(java.net.URL url)
          Returns a URL to a local copy of the given resource, or null.
protected  java.lang.String getRelativeResourceUrl(java.io.File file)
          Returns a URL to a local copy of the given file, or null
 java.lang.String getTitle()
           
static boolean hasAutoFix(com.android.tools.lint.Reporter.QuickfixHandler tool, com.android.tools.lint.detector.api.Issue issue)
          Returns true if the given issue has an automatic IDE fix.
 boolean isDisplayEmpty()
          Returns whether this report should display info (such as a path to the report) if no issues were found
 boolean isSimpleFormat()
          Returns whether the report should use simple formatting (meaning no JavaScript, embedded images, etc).
 void setBundleResources(boolean bundleResources)
          Sets whether the report should bundle up resources along with the HTML report.
 void setDisplayEmpty(boolean displayEmpty)
          Sets whether this report should display info (such as a path to the report) if no issues were found
 void setSimpleFormat(boolean simpleFormat)
          Sets whether the report should use simple formatting (meaning no JavaScript, embedded images, etc).
 void setTitle(java.lang.String title)
          Sets the report title
 void setUrlMap(java.util.Map<java.lang.String,java.lang.String> urlMap)
          Set mapping of path prefixes to corresponding URLs in the HTML report
abstract  void write(int errorCount, int warningCount, java.util.List<Warning> issues)
          Write the given warnings into the report
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mClient

protected final LintCliClient mClient

mOutput

protected final java.io.File mOutput

mTitle

protected java.lang.String mTitle

mSimpleFormat

protected boolean mSimpleFormat

mBundleResources

protected boolean mBundleResources

mUrlMap

protected java.util.Map<java.lang.String,java.lang.String> mUrlMap

mResources

protected java.io.File mResources

mResourceUrl

protected final java.util.Map<java.io.File,java.lang.String> mResourceUrl

mNameToFile

protected final java.util.Map<java.lang.String,java.io.File> mNameToFile

mDisplayEmpty

protected boolean mDisplayEmpty
Constructor Detail

Reporter

protected Reporter(LintCliClient client,
                   java.io.File output)
Method Detail

write

public abstract void write(int errorCount,
                           int warningCount,
                           java.util.List<Warning> issues)
                    throws java.io.IOException
Write the given warnings into the report

Parameters:
errorCount - the number of errors
warningCount - the number of warnings
issues - the issues to be reported
Throws:
java.io.IOException - if an error occurs

setTitle

public void setTitle(java.lang.String title)
Sets the report title

Parameters:
title - the title of the report

getTitle

public java.lang.String getTitle()
Returns:
the title of the report

setBundleResources

public void setBundleResources(boolean bundleResources)
Sets whether the report should bundle up resources along with the HTML report. This implies a non-simple format (see setSimpleFormat(boolean)).

Parameters:
bundleResources - if true, copy images into a directory relative to the report

setSimpleFormat

public void setSimpleFormat(boolean simpleFormat)
Sets whether the report should use simple formatting (meaning no JavaScript, embedded images, etc).

Parameters:
simpleFormat - whether the formatting should be simple

isSimpleFormat

public boolean isSimpleFormat()
Returns whether the report should use simple formatting (meaning no JavaScript, embedded images, etc).

Returns:
whether the report should use simple formatting

setUrlMap

public void setUrlMap(@Nullable
                      java.util.Map<java.lang.String,java.lang.String> urlMap)
Set mapping of path prefixes to corresponding URLs in the HTML report


getRelativeResourceUrl

protected java.lang.String getRelativeResourceUrl(java.io.File file)
Returns a URL to a local copy of the given file, or null


addLocalResources

protected java.lang.String addLocalResources(java.net.URL url)
                                      throws java.io.IOException
Returns a URL to a local copy of the given resource, or null. There is no filename conflict resolution.

Throws:
java.io.IOException

isDisplayEmpty

public boolean isDisplayEmpty()
Returns whether this report should display info (such as a path to the report) if no issues were found


setDisplayEmpty

public void setDisplayEmpty(boolean displayEmpty)
Sets whether this report should display info (such as a path to the report) if no issues were found


hasAutoFix

public static boolean hasAutoFix(@NonNull
                                 com.android.tools.lint.Reporter.QuickfixHandler tool,
                                 com.android.tools.lint.detector.api.Issue issue)
Returns true if the given issue has an automatic IDE fix.

Parameters:
tool - the name of the tool to be checked
issue - the issue to be checked
Returns:
true if the given tool is known to have an automatic fix for the given issue