mauda
Class SimpleExercise

java.lang.Object
  extended by mauda.SimpleExercise
Direct Known Subclasses:
Exercise

public class SimpleExercise
extends java.lang.Object

A central class to hold all relevant exercise-specific values and references to important other classes. If a GUI is needed please use the Exercise-class.

Author:
Markus Krebs

Field Summary
static java.util.Vector availableOperations
          Stores the possible operations on the data-structure
static java.util.Vector availableSubOperations
          Stores the possible suboperations on the data-structure
static OperationExecuter operationExecuter
          Stores the OperationExecuter who maps the Operation-IDs to the corresponding methods in the data-structure.
 
Constructor Summary
SimpleExercise()
          Creates a SimpleExercise
 
Method Summary
 void addExerciseUpdateListener(ExerciseUpdateListener eul)
          Adds an ExerciseUpdateListener to the exercise.
 void addExerciseUpdateListenerFirst(ExerciseUpdateListener eul)
          Adds an ExerciseUpdateListener to the exercise.
 java.util.Vector getAvailableOperations()
          Gets the possible operations for a data-structure
 java.util.Vector getAvailableSubOperations()
          Gets the possible suboperations for a given data-structure.
 java.lang.String getDataDirectory()
          Gets the data-directory
 java.lang.String getDefaultFilename()
          Gets the default exercise-filename
 int getDifficulty()
          Gets the difficulty
 java.lang.Object getDSObject()
          Gets the data-structure
 java.lang.String getFilename()
          Gets the current exercise-filename
 MetaData getMetaData()
          Gets the Meta-Data
 int getMode()
          Gets the mode of the exercise
static OperationExecuter getOperationExecuter()
          Gets the OperationExecuter
 OperationRecorder getOperationRecorder()
          Gets the OperationRecorder
 PlugInHandler getPlugInHandler()
          Gets the PlugInHandler
 void init()
          Initializes the SimpleExercise, so that it can be used
 boolean load(java.util.HashMap ht)
          Loads a unworked exercise
 java.util.HashMap load(java.lang.String filename)
          Loads an exercise
 boolean loadConfig(java.util.HashMap ht)
          Configurates the editor for loading a specific exercise, what means, that e.g. the plug-in was checked, etc.
 void operationExecuted(java.lang.Object obj)
          This method is called, when in JedasPanel an operation was executed.
 void removeExerciseUpdateListener(ExerciseUpdateListener eul)
          Removes an ExerciseUpdateListener from the exercise.
 java.util.HashMap save(java.lang.String filename)
          Saves an exercise.
 void sendExerciseUpdateMessages(ExerciseUpdateEvent event)
          Sends an ExerciseUpdateEvent to all listeners.
 void setAvailableOperations(java.util.Vector v)
          Sets the possible operations for a data-structure.
 void setAvailableSubOperations(java.util.Vector v)
          Sets the possible suboperations for a data-structure.
 void setDataDirectory(java.lang.String directory)
          Sets the directory where plug-specific information is stored e.g. init-operations for automatic generation of exercises, or the knowledge-base for feedback-information
 void setDefaultFilename()
          Sets the current exercise-filename to the default-filename
 void setDifficulty(int difficulty)
          Sets the difficulty
 void setDSObject(java.lang.Object o)
          Sets the data-structure, e.g.
 void setFilename(java.lang.String fn)
          Sets the current exercise-filename
 void setMetaData(MetaData meta)
          Sets the Meta-Data
 void setMode(int mode)
          Sets the mode of the exercise, e.g.
static void setOperationExecuter(OperationExecuter oe)
          Sets the OperationExecuter
 void setPlugInHandler(PlugInHandler pih)
          Sets the PlugInHandler
 void switchTo(java.lang.String plugInName)
          Switches between available PlugIns.
 void updateMetaDataInitTodoRating()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

operationExecuter

public static OperationExecuter operationExecuter
Stores the OperationExecuter who maps the Operation-IDs to the corresponding methods in the data-structure.


availableOperations

public static java.util.Vector availableOperations
Stores the possible operations on the data-structure

See Also:
PlugInHandler

availableSubOperations

public static java.util.Vector availableSubOperations
Stores the possible suboperations on the data-structure

See Also:
PlugInHandler
Constructor Detail

SimpleExercise

public SimpleExercise()
Creates a SimpleExercise

Method Detail

init

public void init()
Initializes the SimpleExercise, so that it can be used


switchTo

public void switchTo(java.lang.String plugInName)
Switches between available PlugIns.

Parameters:
plugInName - The name of the PlugIn

getPlugInHandler

public PlugInHandler getPlugInHandler()
Gets the PlugInHandler

Returns:
PlugInHandler

setPlugInHandler

public void setPlugInHandler(PlugInHandler pih)
Sets the PlugInHandler

Parameters:
pih - PlugInHandler

addExerciseUpdateListener

public void addExerciseUpdateListener(ExerciseUpdateListener eul)
Adds an ExerciseUpdateListener to the exercise. The added listener will receive events for changes in the exercise.

Parameters:
eul - ExerciseUpdateListener

addExerciseUpdateListenerFirst

public void addExerciseUpdateListenerFirst(ExerciseUpdateListener eul)
Adds an ExerciseUpdateListener to the exercise. The added listener will receive events for changes in the exercise. Important: This method will, in contrast to addExerciseUpdateListener(ExerciseUpdateListener) place the Listener at the beginning of the Listener-Vector. This is necessary, because OperationRecorder and UndoRedo, have to notified before all other listeners, because other listeners request the actual state of e.g. the OperationRecorder's current operation. So there must be entered an operation in the OperationRecorder before other listeners perform a readout of that information.
In the case of UndoRedo, other listeners requests the actual data-structure, so UndoRedo must also placed at the beginning of the listeners.
Because OperationRecorder and UndoRedo doesn't readout one another, their position doesn't matter.

Parameters:
eul - ExerciseUpdateListener

removeExerciseUpdateListener

public void removeExerciseUpdateListener(ExerciseUpdateListener eul)
Removes an ExerciseUpdateListener from the exercise.

Parameters:
eul - ExerciseUpdateListener

sendExerciseUpdateMessages

public void sendExerciseUpdateMessages(ExerciseUpdateEvent event)
Sends an ExerciseUpdateEvent to all listeners.

Parameters:
event - ExerciseUpdateEvent

getFilename

public java.lang.String getFilename()
Gets the current exercise-filename

Returns:
filename

getDefaultFilename

public java.lang.String getDefaultFilename()
Gets the default exercise-filename

Returns:
default-filename

setFilename

public void setFilename(java.lang.String fn)
Sets the current exercise-filename

Parameters:
fn - filename

setDefaultFilename

public void setDefaultFilename()
Sets the current exercise-filename to the default-filename


setDataDirectory

public void setDataDirectory(java.lang.String directory)
Sets the directory where plug-specific information is stored e.g. init-operations for automatic generation of exercises, or the knowledge-base for feedback-information

Parameters:
directory - Data-Directory
See Also:
PlugInHandler

getDataDirectory

public java.lang.String getDataDirectory()
Gets the data-directory

Returns:
Data-Directory
See Also:
setDataDirectory(String)

setAvailableOperations

public void setAvailableOperations(java.util.Vector v)
Sets the possible operations for a data-structure. This is used by e.g. input-dialogs like in init-tab, where different operations can be added.

Parameters:
v - Vector of operation-IDs
See Also:
PlugInHandler

getAvailableOperations

public java.util.Vector getAvailableOperations()
Gets the possible operations for a data-structure

Returns:
Vector of operation-IDs
See Also:
setAvailableOperations(Vector)

setAvailableSubOperations

public void setAvailableSubOperations(java.util.Vector v)
Sets the possible suboperations for a data-structure. This is used by e.g. new generated plugins to initialize the rating.xml-file.

Parameters:
v - Vector of suboperation-IDs
See Also:
PlugInHandler

getAvailableSubOperations

public java.util.Vector getAvailableSubOperations()
Gets the possible suboperations for a given data-structure.

Returns:
Vector of suboperation-IDs

setOperationExecuter

public static void setOperationExecuter(OperationExecuter oe)
Sets the OperationExecuter

Parameters:
oe - OperationExecuter
See Also:
PlugInHandler

getOperationExecuter

public static OperationExecuter getOperationExecuter()
Gets the OperationExecuter

Returns:
OperationExecuter

getMetaData

public MetaData getMetaData()
Gets the Meta-Data

Returns:
Meta-Data

setMetaData

public void setMetaData(MetaData meta)
Sets the Meta-Data

Parameters:
meta - Meta-Data

updateMetaDataInitTodoRating

public void updateMetaDataInitTodoRating()

setMode

public void setMode(int mode)
Sets the mode of the exercise, e.g. NORMAL or FAULT

Parameters:
mode - mode-ID
See Also:
ExerciseMode

getMode

public int getMode()
Gets the mode of the exercise

Returns:
mode-ID
See Also:
setMode(int)

setDifficulty

public void setDifficulty(int difficulty)
Sets the difficulty

Parameters:
difficulty - difficulty-ID
See Also:
Difficulties

getDifficulty

public int getDifficulty()
Gets the difficulty

Returns:
Difficulty-ID
See Also:
setDifficulty(int)

setDSObject

public void setDSObject(java.lang.Object o)
Sets the data-structure, e.g. FibHeap.

Parameters:
o - The data-structure-object

getDSObject

public java.lang.Object getDSObject()
Gets the data-structure

Returns:
data-structure-object
See Also:
setDSObject(Object)

getOperationRecorder

public OperationRecorder getOperationRecorder()
Gets the OperationRecorder

Returns:
OperationRecorder

operationExecuted

public void operationExecuted(java.lang.Object obj)
This method is called, when in JedasPanel an operation was executed.

Parameters:
obj - The executed operation

load

public java.util.HashMap load(java.lang.String filename)
Loads an exercise

Parameters:
filename - Filename
Returns:
HashMap-representation of the exercise

loadConfig

public boolean loadConfig(java.util.HashMap ht)
Configurates the editor for loading a specific exercise, what means, that e.g. the plug-in was checked, etc.

Parameters:
ht - HashMap-representation of the exercise
Returns:
true if loading was successful, false otherwise

load

public boolean load(java.util.HashMap ht)
Loads a unworked exercise

Parameters:
ht - HashMap-representation of the exercise
Returns:
true if loading successful, false otherwise

save

public java.util.HashMap save(java.lang.String filename)
Saves an exercise. If the filename is null, the exercise won't be saved to disc, but returned as an HashMap.

Parameters:
filename - Filename
Returns:
HashMap-representation of the exercise