de.cau.cs.kieler.sim.kiem.internal
Class DataComponentWrapper

java.lang.Object
  extended by de.cau.cs.kieler.sim.kiem.internal.DataComponentWrapper
All Implemented Interfaces:
Serializable

public class DataComponentWrapper
extends Object
implements Serializable

The Class DataComponentWrapper. Is a wrapper for the AbstractDataComponent class. It should enrich the above class with information that is only needed for instances in the running execution manager and its view. For example whether a DataComponent instance is enabled or disabled or the current pool index for delta observer DataComponents.

See Also:
Serialized Form
Rating yellow
(2009-01-15)

Constructor Summary
DataComponentWrapper(AbstractDataComponent componentParam)
          Instantiates a new DataComponentWrapper wrapping a DataComponent.
 
Method Summary
 void addPoolIndex(long poolIndex, long stepCounter)
          Adds a pool index for a given step.
 void checkProperties(KiemProperty[] propertiesParam)
          Let the DataComponent check its properties.
 String getComponentId()
          Gets a component id to identify DataComponents during loading because the DataComponents itself do not get serialized.
 AbstractDataComponent getDataComponent()
          Gets the contained DataComponent.
 long getDeltaIndex()
          Gets the delta index.
 String getName()
          Gets the name of the DataComponent.
 long getPoolIndex(long stepCounter)
          Gets the pool index of a specific step.
 KiemProperty[] getProperties()
          Gets the KiemProperties of this DataComponent.
 boolean isDeltaObserver()
          Checks whether the DataComponent is a delta observer.
 boolean isEnabled()
          Checks whether the DataComponent is enabled or disabled.
 boolean isHistoryObserver()
          Checks whether the DataComponent is a history observer.
 boolean isHistoryStep()
          Checks if the current step is a history step.
 boolean isJSON()
          Checks whether this DataComponent is a JSON component that is able to handle JSONObjects of the following Java implementation "http://www.json.org/java".
 boolean isMacroStepDone()
          Checks if is a macro step is finished.
 boolean isMaster()
          Checks whether this DataComponent implements a master.
 boolean isMasterImplementingGUI()
          Checks whether the master is implementing GUI buttons.
 boolean isObserver()
          Checks whether the DataComponent is an observer.
 boolean isObserverOnly()
          Checks whether the DataComponent is a pure observer only.
 boolean isProducer()
          Checks whether the DataComponent is an producer.
 boolean isProducerObserver()
          Checks whether the DataComponent is a producer AND an observer at the same time.
 boolean isProducerOnly()
          Checks whether the DataComponent is a pure producer only.
 boolean isUnfolded()
          Checks whether the properties of this DataComponent are unfolded.
 void masterGUI(int command)
          If this is component is a master and implements the GUI it must react to user button hits.

The command can be either:
MASTER_CMD_STEP for the step button
MASTER_CMD_MACROSTEP for the macro step button
MASTER_CMD_RUN for the run button
MASTER_CMD_PAUSE for the pause button
MASTER_CMD_STOP for the stop button
MASTER_CMD_STEPBACK for the back step button

 boolean masterGUIisEnabled(int command)
          If this is component is a master and implements the GUI it must tell KIEM when user buttons are enabled/disabled.
 void noop()
          Noop does nothing.
 String[] provideFilterKeys()
          Gets the filter keys if the DataComponent provides any or null if it is an observer and wants ALL complete data.
 JSONObject provideInitialVariables()
          This method is implemented by the DataComponent if it provides a JSONObject of initial variables.
 void resetPoolIndices()
          Reset pool indices.
 void setDeltaIndex(long deltaIndexParam)
          Sets the delta index.
 void setEnabled(boolean enabledParam)
          Sets the enabled flag of this DataComponent.
 void setHistoryStep(boolean historyStep)
          Flag the current step as a history step.
 void setInitialVariables(JSONObject globalInitialVariables)
          Sets the global initial variables.
 void setProperties(KiemProperty[] propertiesParam)
          Sets the properties for the DataComponent and this DataComponentWrapper instance.
 void setUnfolded(boolean unfoldedParam)
          Sets whether the properties of this DataComponent are unfolded.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataComponentWrapper

public DataComponentWrapper(AbstractDataComponent componentParam)
Instantiates a new DataComponentWrapper wrapping a DataComponent.

Parameters:
componentParam - the contained DataComponent
Method Detail

getComponentId

public String getComponentId()
Gets a component id to identify DataComponents during loading because the DataComponents itself do not get serialized.

Returns:
the component id

setProperties

public void setProperties(KiemProperty[] propertiesParam)
Sets the properties for the DataComponent and this DataComponentWrapper instance. These are just too links to the same properties.

Parameters:
propertiesParam - the new properties

isJSON

public boolean isJSON()
Checks whether this DataComponent is a JSON component that is able to handle JSONObjects of the following Java implementation "http://www.json.org/java".

Returns:
true, if this DataComponent is JSON capable

isUnfolded

public boolean isUnfolded()
Checks whether the properties of this DataComponent are unfolded.

Returns:
true, if properties are unfolded

setUnfolded

public void setUnfolded(boolean unfoldedParam)
Sets whether the properties of this DataComponent are unfolded.

Parameters:
unfoldedParam - set to true if they are unfolded

getDataComponent

public AbstractDataComponent getDataComponent()
Gets the contained DataComponent.

Returns:
the contained DataComponent

isEnabled

public boolean isEnabled()
Checks whether the DataComponent is enabled or disabled.

Returns:
true, if is enabled

setEnabled

public void setEnabled(boolean enabledParam)
Sets the enabled flag of this DataComponent. This is also reflected by the KiemView GUI whenever a refresh is triggered.

Parameters:
enabledParam - true, if the DataComponent is enabled

resetPoolIndices

public void resetPoolIndices()
Reset pool indices. This is called whenever the execution is reset.


addPoolIndex

public void addPoolIndex(long poolIndex,
                         long stepCounter)
Adds a pool index for a given step. This is necessary to recover delta pool indices of a history step.

Parameters:
poolIndex - the pool index to add
stepCounter - the related step counter

getPoolIndex

public long getPoolIndex(long stepCounter)
Gets the pool index of a specific step. This is necessary to recover delta pool indices of a history step.

Parameters:
stepCounter - the step counter to find the related pool index
Returns:
the related pool index

getDeltaIndex

public long getDeltaIndex()
Gets the delta index. This is used for delta DataComponents only. The delta index is the last pool index when this DataComponent as an observer did not get skipped.

Returns:
the delta index

setDeltaIndex

public void setDeltaIndex(long deltaIndexParam)
Sets the delta index. This is used for delta DataComponents only. The delta index is the last pool index when this DataComponent as an observer did not get skipped.

Parameters:
deltaIndexParam - the new delta index

isProducerObserver

public boolean isProducerObserver()
Checks whether the DataComponent is a producer AND an observer at the same time.

Returns:
true, if it is a producer and an observer

isProducerOnly

public boolean isProducerOnly()
Checks whether the DataComponent is a pure producer only.

Returns:
true, if it is a producer only

isObserverOnly

public boolean isObserverOnly()
Checks whether the DataComponent is a pure observer only.

Returns:
true, if it is an observer only

isProducer

public boolean isProducer()
Checks whether the DataComponent is an producer.

Returns:
true, if it is a producer
See Also:
IDataComponent.isProducer()

isObserver

public boolean isObserver()
Checks whether the DataComponent is an observer.

Returns:
true, if it is an observer
See Also:
IDataComponent.isObserver()

getName

public String getName()
Gets the name of the DataComponent.

Returns:
the name
See Also:
AbstractDataComponent.getName()

provideFilterKeys

public String[] provideFilterKeys()
Gets the filter keys if the DataComponent provides any or null if it is an observer and wants ALL complete data.

Returns:
the filter keys
See Also:
AbstractDataComponent.provideFilterKeys()

provideInitialVariables

public JSONObject provideInitialVariables()
                                   throws KiemInitializationException
This method is implemented by the DataComponent if it provides a JSONObject of initial variables.

Returns:
the JSONObject of initial variables
Throws:
KiemInitializationException - the KIEM initialization exception
See Also:
JSONObjectDataComponent.provideInitialVariables(), JSONStringDataComponent.provideInitialVariables()

getProperties

public KiemProperty[] getProperties()
Gets the KiemProperties of this DataComponent.

Returns:
the KiemProperties
See Also:
AbstractDataComponent.getProperties()

isDeltaObserver

public boolean isDeltaObserver()
Checks whether the DataComponent is a delta observer.

Returns:
true, if DataComponent is a delta observer
See Also:
AbstractDataComponent.isDeltaObserver()

isHistoryObserver

public boolean isHistoryObserver()
Checks whether the DataComponent is a history observer.

Returns:
true, if DataComponent is a history observer
See Also:
AbstractDataComponent.isHistoryObserver()

isHistoryStep

public boolean isHistoryStep()
Checks if the current step is a history step. Normally only called by the DataConsumer itself to implement special behavior within its step() method.

Returns:
true, if current step is a history step
See Also:
AbstractDataComponent.isHistoryStep()

setHistoryStep

public void setHistoryStep(boolean historyStep)
Flag the current step as a history step. Called by the execution manager.

Parameters:
historyStep - true, if the step is a history step
See Also:
AbstractDataComponent.setHistoryStep(boolean)

isMaster

public boolean isMaster()
Checks whether this DataComponent implements a master.

Returns:
true, if the DataComponent is a master
See Also:
AbstractDataComponent.isMaster()

isMacroStepDone

public boolean isMacroStepDone()
Checks if is a macro step is finished.

Returns:
true, if checks if is macro step done
See Also:
AbstractDataComponent.isMacroStepDone()

checkProperties

public void checkProperties(KiemProperty[] propertiesParam)
                     throws KiemPropertyException
Let the DataComponent check its properties. It is supposed to throw an error if a property is not set correctly.

Parameters:
propertiesParam - the KiemProperties of this component
Throws:
KiemPropertyException - an Exception in case of an error
See Also:
AbstractDataComponent.checkProperties(KiemProperty[])

setInitialVariables

public void setInitialVariables(JSONObject globalInitialVariables)
Sets the global initial variables. This method is called by the execution manager after it collects the union of initial variables of all DataComponents.

Parameters:
globalInitialVariables - all interface variable keys
See Also:
JSONObjectDataComponent.setInitialVariables(JSONObject), JSONStringDataComponent.setInitialVariables(String)

isMasterImplementingGUI

public boolean isMasterImplementingGUI()
Checks whether the master is implementing GUI buttons.

Returns:
true, if is master DataComponent is implementing GUI buttons
See Also:
AbstractDataComponent.isMasterImplementingGUI()

masterGUI

public void masterGUI(int command)
If this is component is a master and implements the GUI it must react to user button hits.

The command can be either:
MASTER_CMD_STEP for the step button
MASTER_CMD_MACROSTEP for the macro step button
MASTER_CMD_RUN for the run button
MASTER_CMD_PAUSE for the pause button
MASTER_CMD_STOP for the stop button
MASTER_CMD_STEPBACK for the back step button

Parameters:
command - the command

masterGUIisEnabled

public boolean masterGUIisEnabled(int command)
If this is component is a master and implements the GUI it must tell KIEM when user buttons are enabled/disabled.

The command can be either:
MASTER_CMD_STEP for the step button
MASTER_CMD_MACROSTEP for the macro step button
MASTER_CMD_RUN for the run button
MASTER_CMD_PAUSE for the pause button
MASTER_CMD_STOP for the stop button
MASTER_CMD_STEPBACK for the back step button

Parameters:
command - the command
Returns:
true, if the specific button is enabled

noop

public void noop()
Noop does nothing. It is used in switch/if branches to satisfy checkstyle.