ucot.core
Class Core

java.lang.Object
  extended by ucot.ModuleProperties
      extended by ucot.core.Core
All Implemented Interfaces:
ControlInterface, ModulePropertyInterface

public class Core
extends ModuleProperties
implements ControlInterface

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.

Author:
UCOT

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

FILEFORMAT_NOT_SUPPORTED_ERROR

private static final java.lang.String FILEFORMAT_NOT_SUPPORTED_ERROR

CANNOT_LOAD_FILES_ERROR

private static final java.lang.String CANNOT_LOAD_FILES_ERROR

CANNOT_ADD_SELECTED_USE_CASE_ERROR

private static final java.lang.String CANNOT_ADD_SELECTED_USE_CASE_ERROR

FILE_NOT_SAVED_ERROR

private static final java.lang.String FILE_NOT_SAVED_ERROR

FILE_NOT_WRITABLE_ERROR

private static final java.lang.String FILE_NOT_WRITABLE_ERROR

PLUGIN_NOT_COMPATIBLE_ERROR

private static final java.lang.String PLUGIN_NOT_COMPATIBLE_ERROR

FILE_ALREADY_LOADED

private static final java.lang.String FILE_ALREADY_LOADED

rootDir

private java.lang.String rootDir

inputs

private InputCollection inputs

useCases

private UseCaseCollection useCases

analyzeModel

private AnalyzeModel analyzeModel

heuristics

private java.util.Vector<HeuristicInterface> heuristics

parsers

private java.util.Vector<ParserInterface> parsers

outputs

private java.util.Vector<OutputInterface> outputs

userInterface

private UIInterface userInterface

currentParser

private ParserInterface currentParser

currentHeuristic

private HeuristicInterface currentHeuristic

progressBar

private ProgressBarInterface progressBar

logger

private java.util.logging.Logger logger

RUNNING

private static boolean RUNNING

OUTPUT_JOB_STACK

private static java.util.Stack<Core.OutputJob> OUTPUT_JOB_STACK

EXECUTING_OUTPUT_THREAD

private static java.lang.Thread EXECUTING_OUTPUT_THREAD

parsingThreads

protected static java.util.Vector<java.lang.Runnable> parsingThreads
Constructor Detail

Core

public Core()

Default constructor for UCOT core component. This initializes the core component by loading all available modules.

Method Detail

getFileNotFoundMessage

public static java.lang.String getFileNotFoundMessage(java.net.URL file)

Returns the localized 'file not found' message.

Parameters:
file - URL to the file that is not found (to be part of the message).
Returns:
Localized text as a String saying File *given file* not found!.

main

public static void main(java.lang.String[] args)

Main method that starts the UCOT core.

Parameters:
args - Command line arguments.

setRootDir

private void setRootDir()

Parses the current location of the Core.class file and updates the class variable to match it.


getRootDir

public java.lang.String getRootDir()
Description copied from interface: 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.

Specified by:
getRootDir in interface ControlInterface
Returns:
The path to the UCOT root directory as a String.

shutdown

public void shutdown()
Description copied from interface: 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.

Specified by:
shutdown in interface ControlInterface
See Also:
ControlInterface.shutdown()

loadUseCases

public void loadUseCases(java.net.URL url)
Description copied from interface: ControlInterface

Loads use cases from the given file.

Specified by:
loadUseCases in interface ControlInterface
Parameters:
url - URL to the use case file.
See Also:
ControlInterface.loadUseCases(java.net.URL)

loadAnalyzeModel

public void loadAnalyzeModel(java.net.URL url)
                      throws java.io.IOException
Description copied from interface: ControlInterface

Loads serialized analyze model from the given file.

Specified by:
loadAnalyzeModel in interface ControlInterface
Parameters:
url - URL to the file containing a serialized analyze model.
Throws:
java.io.IOException - If something goes wrong while loading the analyze model from given URL.
See Also:
ControlInterface.loadAnalyzeModel(java.net.URL)

getUseCaseCollection

public UseCaseCollection getUseCaseCollection()
Description copied from interface: ControlInterface

Returns all currently loaded use cases in a UseCaseCollection.

Specified by:
getUseCaseCollection in interface ControlInterface
Returns:
UseCaseColletion containing all currently loaded use cases.
See Also:
ControlInterface.getUseCaseCollection()

clearAnalyzeModel

public void clearAnalyzeModel()
Description copied from interface: 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.

Specified by:
clearAnalyzeModel in interface ControlInterface
See Also:
ControlInterface.clearAnalyzeModel()

runParserAndHeuristic

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.

Parameters:
runnable - Runnable where this thread is running.
useCases - Use cases to be parsed.
parser - Parser to use.
heuristic - Heuristic to use.

addToAnalyzeModel

public void addToAnalyzeModel(java.util.Vector<UseCase> useCases,
                              ParserInterface parser,
                              HeuristicInterface heuristic)
Description copied from interface: 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.

Specified by:
addToAnalyzeModel in interface ControlInterface
Parameters:
useCases - Use cases to work magic on.
parser - Parser to use.
heuristic - Heuristic to use.

addToAnalyzeModel

public void addToAnalyzeModel(java.util.Vector<UseCase> useCases)
Description copied from interface: 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.

Specified by:
addToAnalyzeModel in interface ControlInterface
Parameters:
useCases - Use cases to work magic on.

getAnalyzeModel

public AnalyzeModel getAnalyzeModel()
Description copied from interface: 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.

Specified by:
getAnalyzeModel in interface ControlInterface
Returns:
Current analyze model.
See Also:
ControlInterface.getAnalyzeModel()

getParsers

public java.util.Vector<ParserInterface> getParsers()
Description copied from interface: ControlInterface

Returns a vector containing all the parsers currently available to the UCOT core.

Specified by:
getParsers in interface ControlInterface
Returns:
Vector containing all known parser adapters as ParserInterfaces.
See Also:
ControlInterface.getParsers()

getHeuristics

public java.util.Vector<HeuristicInterface> getHeuristics()
Description copied from interface: ControlInterface

Returns a vector containing all the heuristics currently available to the UCOT core.

Specified by:
getHeuristics in interface ControlInterface
Returns:
Vector containing all known heuristic adapters as HeuristicInterfaces.
See Also:
ControlInterface.getHeuristics()

getOutputs

public java.util.Vector<OutputInterface> getOutputs()
Description copied from interface: ControlInterface

Returns a vector containing all the output adapters currently available to the UCOT core.

Specified by:
getOutputs in interface ControlInterface
Returns:
Vector containing all known output adapters as OutputInterfaces.
See Also:
ControlInterface.getOutputs()

getInputs

public InputCollection getInputs()
Description copied from interface: ControlInterface

Returns all the input adapters currently available to UCOT core.

Specified by:
getInputs in interface ControlInterface
Returns:
InputCollection which contains all known input adapters as InputInterface.
See Also:
ControlInterface.getInputs()

setCurrentParser

public void setCurrentParser(ParserInterface parser)
Description copied from interface: ControlInterface

Sets the default parser to be used in parsing progresses.

Specified by:
setCurrentParser in interface ControlInterface
Parameters:
parser - Parser to be used by default.
See Also:
ControlInterface.setCurrentParser(ucot.parser.ParserInterface)

setCurrentHeuristic

public void setCurrentHeuristic(HeuristicInterface heuristic)
Description copied from interface: ControlInterface

Sets the default heuristic to used in analyzation progresses.

Specified by:
setCurrentHeuristic in interface ControlInterface
Parameters:
heuristic - Default heuristic to be used by default.
See Also:
ControlInterface.setCurrentHeuristic(ucot.heuristic.HeuristicInterface)

getCurrentParser

public ParserInterface getCurrentParser()
Description copied from interface: ControlInterface

Returns the current default parser.

Specified by:
getCurrentParser in interface ControlInterface
Returns:
Default parser as a ParserInterface.
See Also:
ControlInterface.getCurrentParser()

getCurrentHeuristic

public HeuristicInterface getCurrentHeuristic()
Description copied from interface: ControlInterface

Returns the current heuristic.

Specified by:
getCurrentHeuristic in interface ControlInterface
Returns:
Current heuristic as a HeuristicInterface.
See Also:
ControlInterface.getCurrentHeuristic()

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable
See Also:
Object.finalize()

executeOutput

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.


output

public void output(java.net.URL url,
                   OutputInterface output,
                   AnalyzeModel model)
            throws java.lang.Exception
Description copied from interface: ControlInterface

Exports given analyze model to given URL using given output adapter.

Specified by:
output in interface ControlInterface
Parameters:
url - Destination URL.
output - OutputInterface of the output adapter to be used.
model - Analyze model to export.
Throws:
java.lang.Exception
See Also:
ControlInterface.output(java.net.URL, ucot.output.OutputInterface, ucot.model.AnalyzeModel)

saveAnalyzeModel

public void saveAnalyzeModel(java.net.URL url)
Description copied from interface: ControlInterface

Saves the current analyze model to a java serialization file which location is pointed by the given URL.

Specified by:
saveAnalyzeModel in interface ControlInterface
Parameters:
url - URL to the file where the current analyze model should be serialized and saved.
See Also:
ControlInterface.saveAnalyzeModel(java.net.URL)

reloadUseCases

public void reloadUseCases(java.net.URL url)
Description copied from interface: 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.

Specified by:
reloadUseCases in interface ControlInterface
Parameters:
url - URL of the file to be reloaded.
See Also:
ControlInterface.reloadUseCases(java.net.URL)

applyProperties

public void applyProperties()
                     throws BadPropertyValueException
Description copied from interface: ModulePropertyInterface

Applies current properties for the module.

Specified by:
applyProperties in interface ModulePropertyInterface
Overrides:
applyProperties in class ModuleProperties
Throws:
BadPropertyValueException - In this case exception is thrown only if either the given parser or heuristic does not exist.
See Also:
ModulePropertyInterface.applyProperties()

findParser

private ParserInterface findParser(java.lang.String name)

Helper method for applyProperties to find parsers by name.

Parameters:
name - Parser to search.
Returns:
Found parser or null if no parser with given name existed.

findHeuristic

private HeuristicInterface findHeuristic(java.lang.String name)
Helper method for applyProperties to find heuristics by name.

Parameters:
name - Heuristic to search.
Returns:
Found heuristic or null if no heuristic with given name existed.

loadDefaultProperties

public java.util.Properties loadDefaultProperties()
Description copied from interface: ModulePropertyInterface

Method which returns the factory default properties for the module.

Specified by:
loadDefaultProperties in interface ModulePropertyInterface
Overrides:
loadDefaultProperties in class ModuleProperties
Returns:
Default properties.
See Also:
ModulePropertyInterface.loadDefaultProperties()

saveProperties

public void saveProperties()
                    throws java.io.IOException
Description copied from interface: ModulePropertyInterface

Saves current properties to the properties XML file.

Specified by:
saveProperties in interface ModulePropertyInterface
Overrides:
saveProperties in class ModuleProperties
Throws:
java.io.IOException - Exception is thrown if something went wrong.
See Also:
ModulePropertyInterface.saveProperties()

loadProperties

public void loadProperties()
                    throws java.io.IOException
Description copied from interface: ModulePropertyInterface

Loads settings from the current properties XML file.

Specified by:
loadProperties in interface ModulePropertyInterface
Overrides:
loadProperties in class ModuleProperties
Throws:
java.io.IOException - Exception is thrown if something went wrong.
See Also:
ModulePropertyInterface.loadProperties()