Class AbstractAssessment<DOC extends Document>
- java.lang.Object
-
- gov.nist.secauto.decima.core.assessment.AbstractAssessment<DOC>
-
- Type Parameters:
DOC- the type of document that is the target of the assessment
- All Implemented Interfaces:
Assessment<DOC>
- Direct Known Subclasses:
AbstractLogicAssessment,SchemaAssessment,SchematronAssessment
public abstract class AbstractAssessment<DOC extends Document> extends Object implements Assessment<DOC>
Provides basic functions common to allAssessmentimplementations. A concrete implementations of this class must provide implementations of theexecuteInternal(Document, AssessmentResultBuilder)andgetNameDetails()methods to provide evaluation logic and descriptive label information respectively. Implementations of this class are expected to be thread safe when theexecuteInternal(Document, AssessmentResultBuilder)method is invoked from different calling contexts.
-
-
Constructor Summary
Constructors Constructor Description AbstractAssessment()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidexecute(DOC document, AssessmentResultBuilder builder)If a result directory has been provided by callingsetResultDirectory(File), this method ensures that that directory exists before callingexecuteInternal(Document, AssessmentResultBuilder).protected abstract voidexecuteInternal(DOC document, AssessmentResultBuilder builder)Implementations of this method will conduct an assessment over the provided target document, writing any results to the providedAssessmentResultBuilder.List<Assessment<DOC>>getExecutableAssessments(DOC document)intgetId()StringgetName(boolean includeDetail)Retrieves a human-readable label for the assessment.protected abstract StringgetNameDetails()Retrieves basic naming details used to build a human-readable label for the assessment.protected static intgetNextId()FilegetResultDirectory()Retrieves the result directory set using thesetResultDirectory(File)method.voidsetResultDirectory(File resultDirectory)Sets an output directory to write assessment artifacts to.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface gov.nist.secauto.decima.core.assessment.Assessment
getAssessmentType
-
-
-
-
Method Detail
-
getNextId
protected static int getNextId()
-
getId
public int getId()
-
getResultDirectory
public File getResultDirectory()
Retrieves the result directory set using thesetResultDirectory(File)method.- Returns:
- the set result directory or
nullotherwise
-
setResultDirectory
public void setResultDirectory(File resultDirectory)
Sets an output directory to write assessment artifacts to. An assessment is not required to create (and write) assessment artifacts. If there is a need to write artifacts and a directory is provided, the assessment must write these artifacts under the provided directory. Calls toFile.createTempFile(String, String, File)(or an equivalent method) may be used if the last argument is passed using the provided directory. If no directory is provided using this method, then the assessment may create temporary files instead by callingFile.createTempFile(String, String)or an equivalent method.- Parameters:
resultDirectory- if notnull, the directory to write assessment artifacts to
-
getExecutableAssessments
public final List<Assessment<DOC>> getExecutableAssessments(DOC document)
- Specified by:
getExecutableAssessmentsin interfaceAssessment<DOC extends Document>
-
execute
public void execute(DOC document, AssessmentResultBuilder builder) throws AssessmentException
If a result directory has been provided by callingsetResultDirectory(File), this method ensures that that directory exists before callingexecuteInternal(Document, AssessmentResultBuilder).- Specified by:
executein interfaceAssessment<DOC extends Document>- Parameters:
document- the XML document to assessbuilder- theAssessmentResultBuilderused to eventually generate aAssessmentResultsonce all assessments have been performed- Throws:
AssessmentException- if an error occurs while performing the assessment
-
executeInternal
protected abstract void executeInternal(DOC document, AssessmentResultBuilder builder) throws AssessmentException
Implementations of this method will conduct an assessment over the provided target document, writing any results to the providedAssessmentResultBuilder.- Parameters:
document- the target document to assessbuilder- theAssessmentResultBuilderused to eventually generate aAssessmentResultsonce all assessments have been performed- Throws:
AssessmentException- if an error occurs while performing the assessment
-
getName
public String getName(boolean includeDetail)
Description copied from interface:AssessmentRetrieves a human-readable label for the assessment.- Specified by:
getNamein interfaceAssessment<DOC extends Document>- Parameters:
includeDetail- iftrue, include identifying details- Returns:
- a human-readable label for the assessment.
-
getNameDetails
protected abstract String getNameDetails()
Retrieves basic naming details used to build a human-readable label for the assessment.- Returns:
- the details or
nullif none exist
-
-