org.anadix
Class Anadix

java.lang.Object
  extended by org.anadix.Anadix

public final class Anadix
extends Object

Main class to interact with Anadix analyzing engine. The basic methods are provided for creation of analyzer, report formatting and setting the implementations of Parser, ConditionSet and ReportFormatter used. All operations are done either with default implementations (Section508, Swingparser and SimpleRepportFormatter) or with the implementations provided.

Since:
0.4.0
Version:
$Id: $
Author:
tomason

Method Summary
static Report deserializeReport(File source)
          Deserializes the serialized report from a file.
static boolean formatReport(Report report)
          Tries to format given report and store it in report directory.
static boolean formatReport(Report report, String fileName)
          Tries to format given report and store it in the report directory under specified name.
static Analyzer newAnalyzer()
          Creates a new Analyzer instance.
static Analyzer newAnalyzer(ConditionSet conditions)
          Creates a new Analyzer instance.
static Analyzer newAnalyzer(ConditionSet conditions, Parser parser)
          Creates a new Analyzer instance.
static void serializeReport(Report report, File target)
          Serializes the report to a file for later use.
static boolean setDefaultConditionSet(Class<? extends ConditionSet> clazz)
          Sets the ConditionSet class that is to be used by default
static boolean setDefaultConditionSet(String clazz)
          Sets the ConditionSet class that is to be used by default
static boolean setDefaultFormatter(Class<? extends ReportFormatter> clazz)
          Sets the ReportFormatter class that is to be used by default
static boolean setDefaultFormatter(String clazz)
          Sets the ReportFormatter class that is to be used by default
static boolean setDefaultParser(Class<? extends Parser> clazz)
          Sets the Parser class that is to be used by default
static boolean setDefaultParser(String clazz)
          Sets the Parser class that is to be used by default
static boolean setReportDirectory(File path)
          Sets the directory where all reports are stored
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newAnalyzer

public static Analyzer newAnalyzer()
                            throws InstantiationException
Creates a new Analyzer instance. For creation of Analyzer are used ConditionSet and Parser classes that were set before of the default ones (Section508, Swingparser).

Returns:
new instance of Analyzer
Throws:
InstantiationException - when problem occurs during Analyzer creation

newAnalyzer

public static Analyzer newAnalyzer(ConditionSet conditions)
                            throws InstantiationException
Creates a new Analyzer instance. For creation of Analyzer is used ConditionSet instance passed as a parameter and Parser class that was set before or the default one defined in ConditionSet in method getDefaultParser.

Parameters:
conditions - - instance of ConditionSet used to analyze parsed sources
Returns:
new instance of Analyzer
Throws:
InstantiationException - when problem occurs during Analyzer creation

newAnalyzer

public static Analyzer newAnalyzer(ConditionSet conditions,
                                   Parser parser)
                            throws InstantiationException
Creates a new Analyzer instance. For creation of Analyzer are used ConditionSet and Parser instances passed as parameters.

Parameters:
conditions - - instance of ConditionSet used to analyze parsed sources
parser - - instance of Parser used to parse sources
Returns:
new instance of Analyzer
Throws:
InstantiationException - when problem occurs during Analyzer creation

formatReport

public static boolean formatReport(Report report)
Tries to format given report and store it in report directory. ReportFormatter class used is the one set before or the default one (SimpleReportFormatter). Reports are stored either to directory set before via setReportDirectory method or to the default one (./reports). The default name is report_{counter}.{formatter.getDefaultExtension}.

Parameters:
report - - instance of Report received upon successful analysis
Returns:
true if the Report was formatted and saved, false otherwise

formatReport

public static boolean formatReport(Report report,
                                   String fileName)
Tries to format given report and store it in the report directory under specified name. The name is appended with _{counter} so if the file with given name already exists it is not replaced. ReportFormatter class used is the one set before or the default one (SimpleReportFormatter). Reports are stored either to directory set before via setReportDirectory method or to the default one (./reports).

Parameters:
report - - instance of Report received upon successful analysis
fileName - - name of the file to store results to
Returns:
true if the Report was formatted and saved, false otherwise

setDefaultParser

public static boolean setDefaultParser(String clazz)
Sets the Parser class that is to be used by default

Parameters:
clazz - Parser class
Returns:
true if the default Parser was changed, false otherwise

setDefaultParser

public static boolean setDefaultParser(Class<? extends Parser> clazz)
Sets the Parser class that is to be used by default

Parameters:
clazz - instance of class extending Parser
Returns:
true if the default Parser was changed, false otherwise

setDefaultConditionSet

public static boolean setDefaultConditionSet(String clazz)
Sets the ConditionSet class that is to be used by default

Parameters:
clazz - ConditionSet class
Returns:
true if the default ConditionSet was changed, false otherwise

setDefaultConditionSet

public static boolean setDefaultConditionSet(Class<? extends ConditionSet> clazz)
Sets the ConditionSet class that is to be used by default

Parameters:
clazz - - instance of class extending ConditionSet
Returns:
true if the default ConditionSet was changed, false otherwise

setDefaultFormatter

public static boolean setDefaultFormatter(String clazz)
Sets the ReportFormatter class that is to be used by default

Parameters:
clazz - - instance of class extending ReportFormatter
Returns:
true if the default ReportFormatter was changed, false otherwise

setDefaultFormatter

public static boolean setDefaultFormatter(Class<? extends ReportFormatter> clazz)
Sets the ReportFormatter class that is to be used by default

Parameters:
clazz - - instance of class extending ReportFormatter
Returns:
true if the default ReportFormatter was changed, false otherwise

setReportDirectory

public static boolean setReportDirectory(File path)
Sets the directory where all reports are stored

Parameters:
path - - instance of File pointing to a directory
Returns:
true if the directory was changed, false otherwise

serializeReport

public static void serializeReport(Report report,
                                   File target)
                            throws FileNotFoundException
Serializes the report to a file for later use.

Parameters:
report - Report to serialize
target - file to store report to
Throws:
FileNotFoundException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason

deserializeReport

public static Report deserializeReport(File source)
Deserializes the serialized report from a file.

Parameters:
source - file from which the report should be deserialized
Returns:
instance of Report


Copyright © 2011. All Rights Reserved.