java.lang.Objectucot.ModuleProperties
ucot.core.Core
public class Core
This is the implementation of the core of the UCOT program, the controller unit. The core administrates the whole program by handling the analyze model and keeping track and controlling the usage of all possible modules loaded to the program.
The core component offers a ControlInterface
for
the other components to request different kinds of operations from
the core component.
Nested Class Summary | |
---|---|
private class |
Core.OutputJob
This class is a simple container for single output jobs. |
Field Summary | |
---|---|
private AnalyzeModel |
analyzeModel
|
private static java.lang.String |
CANNOT_ADD_SELECTED_USE_CASE_ERROR
|
private static java.lang.String |
CANNOT_LOAD_FILES_ERROR
|
private HeuristicInterface |
currentHeuristic
|
private ParserInterface |
currentParser
|
private static java.lang.Thread |
EXECUTING_OUTPUT_THREAD
|
private static java.lang.String |
FILE_ALREADY_LOADED
|
private static java.lang.String |
FILE_NOT_SAVED_ERROR
|
private static java.lang.String |
FILE_NOT_WRITABLE_ERROR
|
private static java.lang.String |
FILEFORMAT_NOT_SUPPORTED_ERROR
|
private java.util.Vector<HeuristicInterface> |
heuristics
|
private InputCollection |
inputs
|
private java.util.logging.Logger |
logger
|
private static java.util.Stack<Core.OutputJob> |
OUTPUT_JOB_STACK
|
private java.util.Vector<OutputInterface> |
outputs
|
private java.util.Vector<ParserInterface> |
parsers
|
protected static java.util.Vector<java.lang.Runnable> |
parsingThreads
|
private static java.lang.String |
PLUGIN_NOT_COMPATIBLE_ERROR
|
private ProgressBarInterface |
progressBar
|
private java.lang.String |
rootDir
|
private static boolean |
RUNNING
|
private UseCaseCollection |
useCases
|
private UIInterface |
userInterface
|
Fields inherited from class ucot.ModuleProperties |
---|
properties, propertiesURL |
Fields inherited from interface ucot.core.ControlInterface |
---|
PROPERTY_CURRENT_HEURISTIC, PROPERTY_CURRENT_PARSER |
Constructor Summary | |
---|---|
Core()
Default constructor for UCOT core component. |
Method Summary | |
---|---|
void |
addToAnalyzeModel(java.util.Vector<UseCase> useCases)
Requests core to parse given use cases, perform heuristic on them and add then them to current analyze model. |
void |
addToAnalyzeModel(java.util.Vector<UseCase> useCases,
ParserInterface parser,
HeuristicInterface heuristic)
Requests core to parse use cases, perform heuristic on them and add them to current analyze model. |
void |
applyProperties()
Applies current properties for the module. |
void |
clearAnalyzeModel()
Clears the whole current analyze model. |
private void |
executeOutput()
This method executes the output operations in a separate thread. |
protected void |
finalize()
|
private HeuristicInterface |
findHeuristic(java.lang.String name)
Helper method for applyProperties to find heuristics by name. |
private ParserInterface |
findParser(java.lang.String name)
Helper method for applyProperties to find parsers by name. |
AnalyzeModel |
getAnalyzeModel()
Method for getting a pointer to the current analyze model being handled in the core. |
HeuristicInterface |
getCurrentHeuristic()
Returns the current heuristic. |
ParserInterface |
getCurrentParser()
Returns the current default parser. |
static java.lang.String |
getFileNotFoundMessage(java.net.URL file)
Returns the localized 'file not found' message. |
java.util.Vector<HeuristicInterface> |
getHeuristics()
Returns a vector containing all the heuristics currently available to the UCOT core. |
InputCollection |
getInputs()
Returns all the input adapters currently available to UCOT core. |
java.util.Vector<OutputInterface> |
getOutputs()
Returns a vector containing all the output adapters currently available to the UCOT core. |
java.util.Vector<ParserInterface> |
getParsers()
Returns a vector containing all the parsers currently available to the UCOT core. |
java.lang.String |
getRootDir()
Returns the UCOT root directory. |
UseCaseCollection |
getUseCaseCollection()
Returns all currently loaded use cases in a UseCaseCollection. |
void |
loadAnalyzeModel(java.net.URL url)
Loads serialized analyze model from the given file. |
java.util.Properties |
loadDefaultProperties()
Method which returns the factory default properties for the module. |
void |
loadProperties()
Loads settings from the current properties XML file. |
void |
loadUseCases(java.net.URL url)
Loads use cases from the given file. |
static void |
main(java.lang.String[] args)
Main method that starts the UCOT core. |
void |
output(java.net.URL url,
OutputInterface output,
AnalyzeModel model)
Exports given analyze model to given URL using given output adapter. |
void |
reloadUseCases(java.net.URL url)
Reloads use cases from file. |
private void |
runParserAndHeuristic(java.lang.Runnable runnable,
java.util.Vector<UseCase> useCases,
ParserInterface parser,
HeuristicInterface heuristic)
This method runs the parser and heuristic in a single separate thread. |
void |
saveAnalyzeModel(java.net.URL url)
Saves the current analyze model to a java serialization file which location is pointed by the given URL. |
void |
saveProperties()
Saves current properties to the properties XML file. |
void |
setCurrentHeuristic(HeuristicInterface heuristic)
Sets the default heuristic to used in analyzation progresses. |
void |
setCurrentParser(ParserInterface parser)
Sets the default parser to be used in parsing progresses. |
private void |
setRootDir()
Parses the current location of the Core.class file and updates the class variable to match it. |
void |
shutdown()
Shuts down the program. |
Methods inherited from class ucot.ModuleProperties |
---|
getProperties, setProperties |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface ucot.ModulePropertyInterface |
---|
getProperties, setProperties |
Field Detail |
---|
private static final java.lang.String FILEFORMAT_NOT_SUPPORTED_ERROR
private static final java.lang.String CANNOT_LOAD_FILES_ERROR
private static final java.lang.String CANNOT_ADD_SELECTED_USE_CASE_ERROR
private static final java.lang.String FILE_NOT_SAVED_ERROR
private static final java.lang.String FILE_NOT_WRITABLE_ERROR
private static final java.lang.String PLUGIN_NOT_COMPATIBLE_ERROR
private static final java.lang.String FILE_ALREADY_LOADED
private java.lang.String rootDir
private InputCollection inputs
private UseCaseCollection useCases
private AnalyzeModel analyzeModel
private java.util.Vector<HeuristicInterface> heuristics
private java.util.Vector<ParserInterface> parsers
private java.util.Vector<OutputInterface> outputs
private UIInterface userInterface
private ParserInterface currentParser
private HeuristicInterface currentHeuristic
private ProgressBarInterface progressBar
private java.util.logging.Logger logger
private static boolean RUNNING
private static java.util.Stack<Core.OutputJob> OUTPUT_JOB_STACK
private static java.lang.Thread EXECUTING_OUTPUT_THREAD
protected static java.util.Vector<java.lang.Runnable> parsingThreads
Constructor Detail |
---|
public Core()
Default constructor for UCOT core component. This initializes the core component by loading all available modules.
Method Detail |
---|
public static java.lang.String getFileNotFoundMessage(java.net.URL file)
Returns the localized 'file not found' message.
file
- URL to the file that is not found (to be part of the message).
public static void main(java.lang.String[] args)
Main method that starts the UCOT core.
args
- Command line arguments.private void setRootDir()
Parses the current location of the Core.class file and updates the class variable to match it.
public java.lang.String getRootDir()
ControlInterface
Returns the UCOT root directory. That is either the system directory where the class files are stored under a hierarchical directory structure based on the package definitions or the system directory where the UCOT JAR distribution package is stored. The result depends solely on the fact which distribution is currently used.
getRootDir
in interface ControlInterface
public void shutdown()
ControlInterface
Shuts down the program. The shutdown routine triggers all possible autosave actions and after that the core gets rid of all its modules and prepares itself for getting automatically junkbusted.
shutdown
in interface ControlInterface
ControlInterface.shutdown()
public void loadUseCases(java.net.URL url)
ControlInterface
Loads use cases from the given file.
loadUseCases
in interface ControlInterface
url
- URL to the use case file.ControlInterface.loadUseCases(java.net.URL)
public void loadAnalyzeModel(java.net.URL url) throws java.io.IOException
ControlInterface
Loads serialized analyze model from the given file.
loadAnalyzeModel
in interface ControlInterface
url
- URL to the file containing a serialized analyze model.
java.io.IOException
- If something goes wrong while loading
the analyze model from given URL.ControlInterface.loadAnalyzeModel(java.net.URL)
public UseCaseCollection getUseCaseCollection()
ControlInterface
Returns all currently loaded use cases in a UseCaseCollection.
getUseCaseCollection
in interface ControlInterface
ControlInterface.getUseCaseCollection()
public void clearAnalyzeModel()
ControlInterface
Clears the whole current analyze model. Basically this is similiar to creating a whole new empty analyze model. Notice that the old analyze model is not saved anywhere and the restoration of the old model is impossible without manually backing up the old analyze model before using this function.
clearAnalyzeModel
in interface ControlInterface
ControlInterface.clearAnalyzeModel()
private void runParserAndHeuristic(java.lang.Runnable runnable, java.util.Vector<UseCase> useCases, ParserInterface parser, HeuristicInterface heuristic)
This method runs the parser and heuristic in a single separate thread. The thread waits first for other parsing and analyzation threads invoked earlier to finish and then starts the real execution.
runnable
- Runnable where this thread is running.useCases
- Use cases to be parsed.parser
- Parser to use.heuristic
- Heuristic to use.public void addToAnalyzeModel(java.util.Vector<UseCase> useCases, ParserInterface parser, HeuristicInterface heuristic)
ControlInterface
Requests core to parse use cases, perform heuristic on them and add them to current analyze model.
If either the given parser or heuristic is unknown to the UCOT core, then nothing is done.
addToAnalyzeModel
in interface ControlInterface
useCases
- Use cases to work magic on.parser
- Parser to use.heuristic
- Heuristic to use.public void addToAnalyzeModel(java.util.Vector<UseCase> useCases)
ControlInterface
Requests core to parse given use cases, perform heuristic on them and add then them to current analyze model.
Default parser and heuristic are used for this operation.
addToAnalyzeModel
in interface ControlInterface
useCases
- Use cases to work magic on.public AnalyzeModel getAnalyzeModel()
ControlInterface
Method for getting a pointer to the current analyze model being handled in the core.
Notice that all editing to the analyze model should be done
through the AnalyzeModelEditor which can be easily acquired
with the getEditor()
method from the
AnalyzeModel
itself.
getAnalyzeModel
in interface ControlInterface
ControlInterface.getAnalyzeModel()
public java.util.Vector<ParserInterface> getParsers()
ControlInterface
Returns a vector containing all the parsers currently available to the UCOT core.
getParsers
in interface ControlInterface
ParserInterfaces
.ControlInterface.getParsers()
public java.util.Vector<HeuristicInterface> getHeuristics()
ControlInterface
Returns a vector containing all the heuristics currently available to the UCOT core.
getHeuristics
in interface ControlInterface
HeuristicInterfaces
.ControlInterface.getHeuristics()
public java.util.Vector<OutputInterface> getOutputs()
ControlInterface
Returns a vector containing all the output adapters currently available to the UCOT core.
getOutputs
in interface ControlInterface
OutputInterfaces
.ControlInterface.getOutputs()
public InputCollection getInputs()
ControlInterface
Returns all the input adapters currently available to UCOT core.
getInputs
in interface ControlInterface
InputInterface
.ControlInterface.getInputs()
public void setCurrentParser(ParserInterface parser)
ControlInterface
Sets the default parser to be used in parsing progresses.
setCurrentParser
in interface ControlInterface
parser
- Parser to be used by default.ControlInterface.setCurrentParser(ucot.parser.ParserInterface)
public void setCurrentHeuristic(HeuristicInterface heuristic)
ControlInterface
Sets the default heuristic to used in analyzation progresses.
setCurrentHeuristic
in interface ControlInterface
heuristic
- Default heuristic to be used by default.ControlInterface.setCurrentHeuristic(ucot.heuristic.HeuristicInterface)
public ParserInterface getCurrentParser()
ControlInterface
Returns the current default parser.
getCurrentParser
in interface ControlInterface
ParserInterface
.ControlInterface.getCurrentParser()
public HeuristicInterface getCurrentHeuristic()
ControlInterface
Returns the current heuristic.
getCurrentHeuristic
in interface ControlInterface
HeuristicInterface
.ControlInterface.getCurrentHeuristic()
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
Object.finalize()
private void executeOutput()
This method executes the output operations in a separate thread. This thread keeps on running once started and ends execution when core's finalize method has been called.
public void output(java.net.URL url, OutputInterface output, AnalyzeModel model) throws java.lang.Exception
ControlInterface
Exports given analyze model to given URL using given output adapter.
output
in interface ControlInterface
url
- Destination URL.output
- OutputInterface
of the output adapter to be used.model
- Analyze model to export.
java.lang.Exception
ControlInterface.output(java.net.URL,
ucot.output.OutputInterface, ucot.model.AnalyzeModel)
public void saveAnalyzeModel(java.net.URL url)
ControlInterface
Saves the current analyze model to a java serialization file which location is pointed by the given URL.
saveAnalyzeModel
in interface ControlInterface
url
- URL to the file where the current analyze model
should be serialized and saved.ControlInterface.saveAnalyzeModel(java.net.URL)
public void reloadUseCases(java.net.URL url)
ControlInterface
Reloads use cases from file. First core should remove all use cases that are loaded from the given url, and then it should (re)read the use cases from the given file.
reloadUseCases
in interface ControlInterface
url
- URL of the file to be reloaded.ControlInterface.reloadUseCases(java.net.URL)
public void applyProperties() throws BadPropertyValueException
ModulePropertyInterface
Applies current properties for the module.
applyProperties
in interface ModulePropertyInterface
applyProperties
in class ModuleProperties
BadPropertyValueException
- In this case exception
is thrown only if either the given parser or heuristic
does not exist.ModulePropertyInterface.applyProperties()
private ParserInterface findParser(java.lang.String name)
Helper method for applyProperties to find parsers by name.
name
- Parser to search.
private HeuristicInterface findHeuristic(java.lang.String name)
name
- Heuristic to search.
public java.util.Properties loadDefaultProperties()
ModulePropertyInterface
Method which returns the factory default properties for the module.
loadDefaultProperties
in interface ModulePropertyInterface
loadDefaultProperties
in class ModuleProperties
ModulePropertyInterface.loadDefaultProperties()
public void saveProperties() throws java.io.IOException
ModulePropertyInterface
Saves current properties to the properties XML file.
saveProperties
in interface ModulePropertyInterface
saveProperties
in class ModuleProperties
java.io.IOException
- Exception is thrown if something went wrong.ModulePropertyInterface.saveProperties()
public void loadProperties() throws java.io.IOException
ModulePropertyInterface
Loads settings from the current properties XML file.
loadProperties
in interface ModulePropertyInterface
loadProperties
in class ModuleProperties
java.io.IOException
- Exception is thrown if something went wrong.ModulePropertyInterface.loadProperties()