org.jwalk.out
Class ProtocolReport

java.lang.Object
  extended by org.jwalk.out.Report
      extended by org.jwalk.out.ProtocolReport
Direct Known Subclasses:
AlgebraReport, StateReport, StatisticalReport

public class ProtocolReport
extends Report

ProtocolReport is a report on the test class's public interface. A ProtocolReport is responsible for formatting the data generated by a ClassInspector. It also provides direct access to the test class and its constructors and methods.

The intention is that client programs will either use the default getContent() method to return the whole textual content; or they will extract individual elements and format them separately. As a convenience, several toString(object) methods are provided to convert classes, constructors and methods into a standard printable representation.

Version:
1.0
Author:
Anthony Simons

Field Summary
 
Fields inherited from class org.jwalk.out.Report
edition, walker
 
Constructor Summary
  ProtocolReport(ClassInspector walker)
          Creates a ProtocolReport.
protected ProtocolReport(Edition edition, ClassInspector walker)
          Secretly initialises the edition and walker.
 
Method Summary
protected  java.lang.String banner()
          Creates a text banner to use at the start of the report.
 java.util.List<java.lang.Enum<?>> getConstants()
          Returns the public enumerated constants of the test class.
 java.util.List<java.lang.reflect.Constructor<?>> getConstructors()
          Returns the public constructors of the test class.
 java.lang.String getContent()
          Returns the content of this ProtocolReport as formatted text.
 ClassInspector getJWalker()
          Return the ClassInspector which was the source of this report.
 java.util.List<java.lang.reflect.Method> getMethods()
          Returns the public methods of the test class.
 java.lang.Class<?> getTestClass()
          Returns the test class.
protected  boolean isAbstract(java.lang.reflect.Method method)
          Reports whether a method is abstract.
 java.lang.String toString(java.lang.Class<?> aClass)
          Returns a formatted version of a given class's name.
 java.lang.String toString(java.lang.reflect.Constructor<?> constructor)
          Returns a formatted constructor signature.
 java.lang.String toString(java.lang.reflect.Method method)
          Returns a formatted method signature.
 
Methods inherited from class org.jwalk.out.Report
getEdition, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProtocolReport

public ProtocolReport(ClassInspector walker)
Creates a ProtocolReport. This ProtocolReport will extract all of its report data from a supplied ClassInspector, which has inspected the protocols of the test class.

Parameters:
walker - a ClassInspector.

ProtocolReport

protected ProtocolReport(Edition edition,
                         ClassInspector walker)
Secretly initialises the edition and walker. This constructor is used by subclasses to forward the edition and walker arguments.

Parameters:
edition - an indicator of the kind of Report.
walker - a JWalker that inspected the test class.
Method Detail

getJWalker

public ClassInspector getJWalker()
Return the ClassInspector which was the source of this report. This method narrows the return type from JWalker to ClassInspector.

Overrides:
getJWalker in class Report
Returns:
the ClassInspector which dispatched this report.

getConstants

public java.util.List<java.lang.Enum<?>> getConstants()
Returns the public enumerated constants of the test class. Allows client programs to access each of the enumerated objects directly.


getConstructors

public java.util.List<java.lang.reflect.Constructor<?>> getConstructors()
Returns the public constructors of the test class. Allows client programs to access each of the constructors directly. These can be individually formatted later for output using toString(Constructor).

Returns:
the list of public constructors.

getMethods

public java.util.List<java.lang.reflect.Method> getMethods()
Returns the public methods of the test class. Allows client programs to access each of the methods directly. These can be individually formatted later for output using toString(Method).

Returns:
the list of public methods.

getTestClass

public java.lang.Class<?> getTestClass()
Returns the test class. Allows client programs to access the test class directly. The test class can be formatted later for output using toString(Class).

Returns:
the test class.

banner

protected java.lang.String banner()
Creates a text banner to use at the start of the report. This is sensitive to whether the test class was a public class, an abstract class, or an interface.


getContent

public java.lang.String getContent()
Returns the content of this ProtocolReport as formatted text. The returned text has a banner announcing the test class, then two subsections listing the public constructors, and the public methods of the test class. This method implements toString() for ProtocolReport.

Specified by:
getContent in class Report
Returns:
a formatted textual report.

isAbstract

protected boolean isAbstract(java.lang.reflect.Method method)
Reports whether a method is abstract.

Parameters:
method - a method to inspect.
Returns:
true if the method is declared abstract.

toString

public java.lang.String toString(java.lang.Class<?> aClass)
Returns a formatted version of a given class's name. This is a pretty-printed format using the unqualified short name of the class.

Parameters:
aClass - the Class to format.
Returns:
a formatted version of the class's name.

toString

public java.lang.String toString(java.lang.reflect.Constructor<?> constructor)
Returns a formatted constructor signature. This is a pretty-printed format showing the unqualified name of the constructor, followed by the comma-separated formal parameter types in parentheses. Each parameter type is recursively formatted. Class types appear using their short names, array types appear in a readable format showing the element-type and the number of dimensions with square brackets and simple types appear using their standard names.

Parameters:
constructor - the Constructor to format.
Returns:
a formatted constructor signature.

toString

public java.lang.String toString(java.lang.reflect.Method method)
Returns a formatted method signature. This is a pretty-printed format showing the unqualified name of the return type, followed by a space and the method name and then the comma-separated formal parameter types in parentheses. Each parameter type is recursively formatted. Class types appear using their short names, array types appear in a readable format showing the element-type and the number of dimensions with square brackets and simple types appear using their standard names.

Parameters:
method - the Method to format.
Returns:
a formatted method signature.