public class Corrector
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Corrector.AlgorithmStrategy
Enumeration of all implemented correction algorithm strategies.
|
static class |
Corrector.ExecutionApproach
Enumeration of all implemented execution approaches.
|
static class |
Corrector.SignatureHandling
Enumeration of all implemented signature handling behaviours.
|
Modifier and Type | Field and Description |
---|---|
protected Tree |
dataTree
Data tree object representing the input XML document.
|
static java.util.EnumSet<Intent.Type> |
defaultIntents
Default choice of intent types allowed in the correction.
|
protected java.util.EnumSet<Intent.Type> |
enabledIntents
Set of selected intent types allowed in the correction.
|
protected Report |
profilingReport
Optional reference to the prepared profiling results.
|
protected boolean |
profilingStats
Flag of activated profiling of various statistics.
|
protected boolean |
profilingTimes
Flag of activated profiling of execution times.
|
protected Store<Repair> |
repairsCache
Internal store for managing computed repairs by their signatures.
|
protected Store<Task> |
tasksCache
Internal store for managing existing tasks.
|
protected Grammar |
treeGrammar
Single type tree grammar object reference.
|
protected Repair |
treeRepair
Reference to the repair of the entire data tree.
|
protected Pool |
workersPool
Instance of the pool with workers used for the execution of handlers.
|
Modifier | Constructor and Description |
---|---|
protected |
Corrector(Tree dataTree,
Grammar treeGrammar,
Corrector.AlgorithmStrategy algorithmStrategy,
Corrector.ExecutionApproach executionApproach,
Corrector.SignatureHandling signatureHandling,
boolean profilingTimes,
boolean profilingStats)
Internal constructor for the universal corrector implementation.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
composeAlgorithmCode(Corrector.AlgorithmStrategy algorithmStrategy,
Corrector.ExecutionApproach executionApproach,
Corrector.SignatureHandling signatureHandling)
Composes the algorithm code.
|
static Corrector |
createCorrectorInstance(Tree dataTree,
Grammar treeGrammar,
Corrector.AlgorithmStrategy algorithmStrategy,
Corrector.ExecutionApproach executionApproach,
Corrector.SignatureHandling signatureHandling,
boolean profilingTimes,
boolean profilingStats)
Prepares and executes the required correction algorithm.
|
Task |
createExtendedTask(Intent correctionIntent)
Creates a new instance of an extended task.
|
protected Handler |
createHandlerInstance(Task associatedTask)
Creates a new instance of the correction handler.
|
Task |
createSimpleTask(Intent correctionIntent)
Creates a new instance of a simple task.
|
Repair |
fetchStoredRepair(Intent requiredIntent)
Attempts to fetch the required intent repair from the store.
|
java.lang.String |
getAlgorithmCode()
Returns the composed algorithm code.
|
Corrector.AlgorithmStrategy |
getAlgorithmStrategy()
Returns the selected algorithm strategy.
|
Corrector.ExecutionApproach |
getExecutionApproach()
Returns the selected execution approach.
|
Report |
getProfilingReport()
Returns the reference to the profiling report container.
|
Corrector.SignatureHandling |
getSignatureHandling()
Returns the selected signature handling mode.
|
Repair |
getTreeRepair()
Returns the reference to the repair of the entire data tree.
|
boolean |
hasApproach(Corrector.ExecutionApproach selectedApproach)
Tests whether the given execution approach is activated.
|
boolean |
hasInvokingApproach()
Detects whether the execution approach belongs to the invoking family.
|
boolean |
hasMultipleApproach()
Detects whether the associated approach permits multiple requests.
|
boolean |
hasSchedulingApproach()
Detects whether the execution approach belongs to the scheduling family.
|
boolean |
hasSignatures(Corrector.SignatureHandling selectedMode)
Tests whether the given signatures handling mode is activated.
|
boolean |
hasSignaturesEnabled()
Detects whether the signature handling is enabled by the corrector.
|
boolean |
hasSingleApproach()
Detects whether the associated approach permits only 1 request at a time.
|
boolean |
hasStrategy(Corrector.AlgorithmStrategy selectedStrategy)
Tests whether the given algorithm strategy is activated.
|
boolean |
hasTasksCaching()
Detects whether tasks need to be used to avoid concurrency conflicts.
|
boolean |
hasWorkersEnabled()
Detects whether the worker pool is required by the corrector.
|
Wrapper |
provideExtendedWrapper(Intent requestedIntent)
Fetches the required repair, existing or newly created extended task.
|
java.util.List<Wrapper> |
provideExtendedWrappers(java.util.List<Intent> requestedIntents)
Fetches the required repairs, existing or newly created extended tasks.
|
protected Wrapper |
provideSimpleWrapper(Intent requestedIntent)
Fetches the required repair or creates a new simple task.
|
void |
removeCachedTask(Task cachedTask)
Removes the provided task from the cache of tasks.
|
void |
requestHandlerExecution(Handler requestedHandler)
Executes the given prepared correction handler.
|
void |
storeComputedRepair(Repair computedRepair)
Inserts the provided computed repair into the repairs cache.
|
protected Tree dataTree
protected Grammar treeGrammar
protected java.util.EnumSet<Intent.Type> enabledIntents
public static java.util.EnumSet<Intent.Type> defaultIntents
protected Repair treeRepair
protected Pool workersPool
protected Store<Repair> repairsCache
protected Store<Task> tasksCache
protected final boolean profilingTimes
Report
protected final boolean profilingStats
Report
protected final Report profilingReport
profilingTimes
,
profilingStats
protected Corrector(Tree dataTree, Grammar treeGrammar, Corrector.AlgorithmStrategy algorithmStrategy, Corrector.ExecutionApproach executionApproach, Corrector.SignatureHandling signatureHandling, boolean profilingTimes, boolean profilingStats)
dataTree
- Data tree to be corrected.treeGrammar
- Single type tree grammar.algorithmStrategy
- Selected correction algorithm strategy.executionApproach
- Selected execution approach.signatureHandling
- Selected signature handling mode.profilingTimes
- Flag of activated execution time profiling.profilingStats
- Flag of activated statistics profiling.createCorrectorInstance(cz.cuni.mff.corrector.tree.Tree, cz.cuni.mff.corrector.grammar.Grammar, cz.cuni.mff.corrector.corrector.Corrector.AlgorithmStrategy, cz.cuni.mff.corrector.corrector.Corrector.ExecutionApproach, cz.cuni.mff.corrector.corrector.Corrector.SignatureHandling, boolean, boolean)
public static Corrector createCorrectorInstance(Tree dataTree, Grammar treeGrammar, Corrector.AlgorithmStrategy algorithmStrategy, Corrector.ExecutionApproach executionApproach, Corrector.SignatureHandling signatureHandling, boolean profilingTimes, boolean profilingStats)
dataTree
- Data tree to be corrected.treeGrammar
- Single type tree grammar.algorithmStrategy
- Selected correction algorithm strategy.executionApproach
- Selected execution approach.signatureHandling
- Selected signature handling mode.profilingTimes
- Flag of activated execution time profiling.profilingStats
- Flag of activated statistics profiling.public Report getProfilingReport()
null
reference.profilingTimes
,
profilingStats
protected Handler createHandlerInstance(Task associatedTask)
associatedTask
- Task object to be associated with the handler.public final Corrector.AlgorithmStrategy getAlgorithmStrategy()
public final Corrector.ExecutionApproach getExecutionApproach()
public final Corrector.SignatureHandling getSignatureHandling()
public boolean hasStrategy(Corrector.AlgorithmStrategy selectedStrategy)
selectedStrategy
- Algorithm strategy to be tested.true
if the strategy corresponds.public boolean hasApproach(Corrector.ExecutionApproach selectedApproach)
selectedApproach
- Execution approach to be tested.true
if the approach corresponds.public boolean hasSignatures(Corrector.SignatureHandling selectedMode)
selectedMode
- Signature handling mode to be tested.true
if the mode corresponds.public final java.lang.String getAlgorithmCode()
public static java.lang.String composeAlgorithmCode(Corrector.AlgorithmStrategy algorithmStrategy, Corrector.ExecutionApproach executionApproach, Corrector.SignatureHandling signatureHandling)
algorithmStrategy
- Selected correction algorithm strategy.executionApproach
- Selected execution approach.signatureHandling
- Selected signature handling mode.public Repair getTreeRepair()
public final boolean hasWorkersEnabled()
true
when workers pool is used.public void requestHandlerExecution(Handler requestedHandler)
requestedHandler
- Correction handler instance to be executed.Also note that this method does not need to be synchronised, since
it just invokes the execution but is not responsible to decide
whether this execution should or should not be requested.
public final boolean hasSignaturesEnabled()
true
when signatures are enabled.public Repair fetchStoredRepair(Intent requiredIntent)
requiredIntent
- Intent for which the repair should be fetched.null
on failure.This method is not synchronised, so it can only be used in approaches
that do not suffer from concurrency problems. In particular, only the
following execution approaches are suitable for direct calls:
NESTING_SINGLE, INVOKING_SINGLE, and SCHEDULING_SINGLE.
Otherwise, more complex and synchronised operations that are able
to fetch repairs and tasks depending on their state of existence
should be used.
public void storeComputedRepair(Repair computedRepair)
computedRepair
- Newly computed repair to be registered.Also note that this method does not need to be synchronised, since
repeated insertions cannot be avoided and do not cause difficulties.
public final boolean hasTasksCaching()
true
when tasks caching is enabled.public void removeCachedTask(Task cachedTask)
cachedTask
- Task to be removed from the tasks cache.hasTasksCaching()
public Task createSimpleTask(Intent correctionIntent)
correctionIntent
- Associated correction intent reference.public Task createExtendedTask(Intent correctionIntent)
correctionIntent
- Associated correction intent reference.protected Wrapper provideSimpleWrapper(Intent requestedIntent)
requestedIntent
- Reference to the requested intent.public Wrapper provideExtendedWrapper(Intent requestedIntent)
requestedIntent
- Reference to the requested intent.public java.util.List<Wrapper> provideExtendedWrappers(java.util.List<Intent> requestedIntents)
requestedIntents
- Container with all nested correction intents.public final boolean hasInvokingApproach()
true
for invoking approaches.public final boolean hasSchedulingApproach()
true
for scheduling approaches.public final boolean hasSingleApproach()
true
for single type approaches.hasMultipleApproach()
public final boolean hasMultipleApproach()
true
for multiple type approaches.hasSingleApproach()