com.jstatcom.engine
Class EngineTypes

java.lang.Object
  extended by com.jstatcom.engine.EngineTypes
Direct Known Subclasses:
GaussEngineType, GRTEType, MatlabEngineType, MLabEngineType, OxEngineType, RStatEngineType, StubEngineType, StubMlabEngineType

public abstract class EngineTypes
extends java.lang.Object

This class is a Mediator that binds the various classes and resources together that belong to an engine implementation. It also contains an enumeration of engine types that are implemented for convenience.

Every Engine implementation define its corresponding concrete engine type. The name of an engine type must be unique. If it already exists for a different instance of EngineTypes, the constructor will throw an exception.

Engine types should always be implemented as Singletons.

The name of an engine type also defines the resource directory to be used for everything related to that engine. Therefore the conventions for variable names defined in com.jstatcom.model.JSCConstants are enforced for engine type names as well.

This class implements the typesave enum pattern (Joshua Bloch, "Effective Java", Item 21) . If you compare EngineTypes, always use the == operator.

Author:
Markus Kraetzig

Field Summary
 java.lang.String DIR_NAME
           
static EngineTypes GAUSS
          Reference to the GAUSS engine type.
static EngineTypes GRTE
          Reference to the Gauss Runtime Engine type.
static EngineTypes MATLAB
          Reference to the newer Matlab Engine type.
static EngineTypes MLAB
          Reference to the older Matlab Engine type.
 java.lang.String name
          The name of this runtype.
static EngineTypes OX
          Reference to the Ox Engine type.
static EngineTypes RSTAT
          Reference to the R Engine type.
static EngineTypes STUB
          Reference to the Stub Engine type.
 
Method Summary
 java.lang.String checkConfig(ConfigHolder configHolder)
          Checks all configuration data for validity.
abstract  java.lang.String checkSettings(ConfigHolder configHolder)
          This method should be overwritten by clients, if further checks of the settings have to be specified.
static java.util.Iterator engineIterator()
          Gets an iterator over all loaded engines.
 boolean equals(java.lang.Object o)
          Override prevention method to enforce a.equals(b) if and only if a==b.
 java.lang.String getConfigFile()
          Returns the config file location for the respective engine.
abstract  java.util.Map<java.lang.String,ConfigKeys> getConfigKeys()
          Gets a map with all config keys for that specific engine.
 AbstractConfigPanel getConfigPanel()
          Gets the configuration panel for the respective engine.
abstract  Engine getEngine()
          Gets a concrete implementation of the Engine interface.
 int hashCode()
          Override prevention method invokes super method.
 java.lang.String toString()
          Returns a string that represents the value of this object.
static EngineTypes valueOf(java.lang.String name)
          Gets the type for the given name.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

name

public final java.lang.String name
The name of this runtype.


DIR_NAME

public final java.lang.String DIR_NAME

GAUSS

public static final EngineTypes GAUSS
Reference to the GAUSS engine type. This used to manage communication with the GAUSS software by Aptech. The software has to be installed on the machine.


GRTE

public static final EngineTypes GRTE
Reference to the Gauss Runtime Engine type. This can be used to execute GAUSS code that has been compiled with the matching Gauss Engine.


STUB

public static final EngineTypes STUB
Reference to the Stub Engine type. This can be used to execute methods in arbitrary system libraries without the need for a distinguished JNI wrapper.


MATLAB

public static final EngineTypes MATLAB
Reference to the newer Matlab Engine type. This can be used to execute methods in system libraries that have been generated from Matlab .m files with Matlab Compiler versions release 4 and later.


RSTAT

public static final EngineTypes RSTAT
Reference to the R Engine type. Allows full control over R execution, see www.r-project.org.


MLAB

public static final EngineTypes MLAB
Reference to the older Matlab Engine type. This can be used to execute methods in system libraries that have been generated from Matlab .m files with Matlab Compiler versions prior to release 4.


OX

public static final EngineTypes OX
Reference to the Ox Engine type. This can be used to execute methods in .ox or .oxo modules.

Method Detail

checkConfig

public final java.lang.String checkConfig(ConfigHolder configHolder)
Checks all configuration data for validity. This method performs a general check that should be true for all engines: One can add further tests by overriding the method:

public String checkSettings()

It is called from this method after all other checks succeeded and can be used to validate conditions between engine settings.

Parameters:
configHolder - the config settings to check
Returns:
null if ok, error string otherwise
Throws:
java.lang.IllegalArgumentException - if (configHolder == null)

checkSettings

public abstract java.lang.String checkSettings(ConfigHolder configHolder)
This method should be overwritten by clients, if further checks of the settings have to be specified.

Parameters:
configHolder - the config settings to check
Returns:
null if ok, error string otherwise

equals

public final boolean equals(java.lang.Object o)
Override prevention method to enforce a.equals(b) if and only if a==b.

Overrides:
equals in class java.lang.Object
Parameters:
o - object to compare with
Returns:
true if equal, false otherwise

getConfigFile

public java.lang.String getConfigFile()
Returns the config file location for the respective engine. The filename is constructed as:

"j" + name.toLowerCase() + "/" + CONFIG_FILE;

If the directory "j" + name.toLowerCase() does not exist yet in the resource path, it will be created by this method.

Subclasses can overwrite this method if this is not the desired behaviour.

Returns:
the relative location of the XML config file to the resource directory

getConfigKeys

public abstract java.util.Map<java.lang.String,ConfigKeys> getConfigKeys()
Gets a map with all config keys for that specific engine.

Example:
Implementations of a Foo engine this class could use:

return ConfigKeys.getAllKeys(FooConfigKeys.class);

where Foo stands for the name of the engine and FooConfigKeys is the engine specific implementation of ConfigKeys.

Returns:
Map containing the ConfigKeys with the respective names as keys

getConfigPanel

public AbstractConfigPanel getConfigPanel()
Gets the configuration panel for the respective engine. This default implementation creates an edit dialog for the XML file. It works for all settings. This can be overwritten to provide a costumized settings dialogs for a specific engine.

Returns:
the user panel containing the user input mask for configuration

getEngine

public abstract Engine getEngine()
Gets a concrete implementation of the Engine interface.

Returns:
engine that is initialized and ready to run

hashCode

public final int hashCode()
Override prevention method invokes super method.

Overrides:
hashCode in class java.lang.Object
Returns:
hash code

toString

public final java.lang.String toString()
Returns a string that represents the value of this object.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this

valueOf

public static EngineTypes valueOf(java.lang.String name)
Gets the type for the given name. The case of name makes no difference.

Parameters:
name - the name of the type
Returns:
reference to an instance of EngineTypes with name or null if it does not exist
Throws:
java.lang.IllegalArgumentException - if (name == null)

engineIterator

public static java.util.Iterator engineIterator()
Gets an iterator over all loaded engines.

Returns:
iterator