aQute.libg.reporter
Class ReporterAdapter

java.lang.Object
  extended by aQute.libg.reporter.ReporterAdapter
All Implemented Interfaces:
Report, Reporter, Runnable
Direct Known Subclasses:
Env, ReplacerAdapter

public class ReporterAdapter
extends Object
implements Reporter, Report, Runnable

Mainly used for testing where reporters are needed.


Nested Class Summary
 
Nested classes/interfaces inherited from interface aQute.service.reporter.Reporter
Reporter.SetLocation
 
Nested classes/interfaces inherited from interface aQute.service.reporter.Report
Report.Location
 
Constructor Summary
ReporterAdapter()
           
ReporterAdapter(Appendable app)
           
 
Method Summary
 void addErrors(String prefix, Collection<String> errors)
          Add a number of errors
 void addWarnings(String prefix, Collection<String> warnings)
          Add a number of warnings
 boolean check(String... pattern)
           
 Reporter.SetLocation error(String s, Object... args)
          Create an error.
 Reporter.SetLocation exception(Throwable t, String s, Object... args)
          Dedicated message for an exception.
 List<String> getErrors()
          Return the errors.
 boolean getInfo(Report other)
           
 boolean getInfo(Report other, String prefix)
           
 Report.Location getLocation(String msg)
          Return the errors for the given error or warning.
<T> T
getMessages(Class<T> c)
          Return a messages object bound to this adapter
 Formatter getOut()
           
 List<String> getWarnings()
          Return the warnings.
 boolean isExceptions()
           
 boolean isOk()
          Check if this report has any relevant errors that should make the run associated with this report invalid.
 boolean isPedantic()
          The provider of the reporter wants pedantic reporting, meaning every possible warning should be reported.
 boolean isPerfect()
           
 boolean isTrace()
           
 void progress(float progress, String s, Object... args)
          Create a warning.
 void report(Appendable out)
          Report the errors and warnings
 void run()
          Handy routine that can be extended by subclasses so they can run inside the context
 void setExceptions(boolean exceptions)
           
 void setPedantic(boolean pedantic)
           
 void setTrace(boolean b)
           
 void trace(String s, Object... args)
          Create a warning.
 Reporter.SetLocation warning(String s, Object... args)
          Create a warning.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReporterAdapter

public ReporterAdapter()

ReporterAdapter

public ReporterAdapter(Appendable app)
Method Detail

isExceptions

public boolean isExceptions()
Returns:
the exceptions

setExceptions

public void setExceptions(boolean exceptions)
Parameters:
exceptions - the exceptions to set

getOut

public Formatter getOut()
Returns:
the out

isTrace

public boolean isTrace()
Returns:
the trace

setPedantic

public void setPedantic(boolean pedantic)
Parameters:
pedantic - the pedantic to set

error

public Reporter.SetLocation error(String s,
                                  Object... args)
Description copied from interface: Reporter
Create an error. Implementations must ensure that the given args are not prevented from garbage collecting. The args must have a proper toString method.

Specified by:
error in interface Reporter
Parameters:
s - The format of the error
args - The arguments of the error
Returns:
a SetLocation to set the location

exception

public Reporter.SetLocation exception(Throwable t,
                                      String s,
                                      Object... args)
Description copied from interface: Reporter
Dedicated message for an exception.

Specified by:
exception in interface Reporter
Parameters:
t - The exception
args - The arguments

warning

public Reporter.SetLocation warning(String s,
                                    Object... args)
Description copied from interface: Reporter
Create a warning. Implementations must ensure that the given args are not prevented from garbage collecting. The args must have a proper toString method.

Specified by:
warning in interface Reporter
Parameters:
s - The format of the error
args - The arguments of the error
Returns:
a SetLocation to set the location

progress

public void progress(float progress,
                     String s,
                     Object... args)
Description copied from interface: Reporter
Create a warning. Implementations must ensure that the given args are not prevented from garbage collecting. The args must have a proper toString method.

Specified by:
progress in interface Reporter
Parameters:
progress - A value between 0 and 1 indicating the progress. 0 is starting and >=1 is done.
s - The format of the error
args - The arguments of the error

trace

public void trace(String s,
                  Object... args)
Description copied from interface: Reporter
Create a warning. Implementations must ensure that the given args are not prevented from garbage collecting. The args must have a proper toString method.

Specified by:
trace in interface Reporter
Parameters:
s - The format of the error
args - The arguments of the error

getWarnings

public List<String> getWarnings()
Description copied from interface: Report
Return the warnings. This list must not be changed and may be immutable.

Specified by:
getWarnings in interface Report
Returns:
the warnings

getErrors

public List<String> getErrors()
Description copied from interface: Report
Return the errors. This list must not be changed and may be immutable.

Specified by:
getErrors in interface Report
Returns:
the errors

isPedantic

public boolean isPedantic()
Description copied from interface: Reporter
The provider of the reporter wants pedantic reporting, meaning every possible warning should be reported.

Specified by:
isPedantic in interface Reporter
Returns:
if this is a pedantic reporter.

setTrace

public void setTrace(boolean b)

isOk

public boolean isOk()
Description copied from interface: Report
Check if this report has any relevant errors that should make the run associated with this report invalid. I.e. if this returns false then the run should be disregarded.

Specified by:
isOk in interface Report
Returns:
true if this run should be disregarded due to errors

isPerfect

public boolean isPerfect()

check

public boolean check(String... pattern)

report

public void report(Appendable out)
Report the errors and warnings


getInfo

public boolean getInfo(Report other)

getInfo

public boolean getInfo(Report other,
                       String prefix)

getLocation

public Report.Location getLocation(String msg)
Description copied from interface: Report
Return the errors for the given error or warning. Can return null.

Specified by:
getLocation in interface Report
Parameters:
msg - The message
Returns:
null or the location of the message

run

public void run()
Handy routine that can be extended by subclasses so they can run inside the context

Specified by:
run in interface Runnable

getMessages

public <T> T getMessages(Class<T> c)
Return a messages object bound to this adapter


addErrors

public void addErrors(String prefix,
                      Collection<String> errors)
Add a number of errors


addWarnings

public void addWarnings(String prefix,
                        Collection<String> warnings)
Add a number of warnings



Copyright © 2014 aQute SARL. All rights reserved.