com.sdm.quasar.client.core.states
Class AbstractState

java.lang.Object
  extended bycom.sdm.quasar.client.core.states.AbstractState
All Implemented Interfaces:
Disposable, State
Direct Known Subclasses:
AbstractBooleanState, MutableState, NOTBooleanState, ThresholdCounterBooleanState, WrapperBooleanState

public abstract class AbstractState
extends java.lang.Object
implements State

A abstract uncomplete implementation of State which support listeners and adds a fireStateChanged() method to notify them.

Version:
1.0
Author:
Thomas Wolf

Constructor Summary
AbstractState()
          Creates a new AbstractState.
AbstractState(java.lang.String name)
          Creates a new AbstractState.
 
Method Summary
 void addStateListener(StateListener listener)
          Registers the given StateListenerto listen to state changes of this State.
protected  void appendParametersToString(java.lang.StringBuffer str)
          Overwrite this method to display additional parameters in the toString() representation of this State.
 void dispose()
          Disposes the component.
protected  void fireStateChanged()
          Fires a state change to all registered listeners.
 java.lang.String getName()
          Return the name of this State.
 void removeStateListener(StateListener listener)
          Unregisters the given StateListenerfrom this State.
 void setName(java.lang.String name)
          Set the name of the state.
 java.lang.String stateValueToString()
          Converts the current state value to a string representation and returns it.
 java.lang.String toString()
           
 java.lang.String toString(boolean display_listeners)
          Returns a string representation of this State.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.sdm.quasar.client.core.states.State
getValue
 

Constructor Detail

AbstractState

public AbstractState()
Creates a new AbstractState.


AbstractState

public AbstractState(java.lang.String name)
Creates a new AbstractState.

Parameters:
name - the name of this State (not null)
Method Detail

dispose

public void dispose()
             throws DisposeException
Description copied from interface: Disposable
Disposes the component.

Important:
This method is called by an administrating component and must never be called directly.

The implementation should release any resources or objects allocated and any services registered. Furthermore, this method should be developed carefully to free a maximum of resources even when the system may have become unstable. In case of one or multiple errors, you should collect them in a DisposeException, continue with the execution, and throw it at the end of the method.

Note: The implementation must not return before the component is disposed. Any threads or asynchronous calls started must be completed before this method returns.

Specified by:
dispose in interface Disposable
Throws:
DisposeException - if there was one or more errors while disposing the component.
See Also:
Disposable.dispose()

getName

public java.lang.String getName()
Description copied from interface: State
Return the name of this State.

Specified by:
getName in interface State
Returns:
the name of this State (never null)
See Also:
State.getName()

setName

public void setName(java.lang.String name)
Description copied from interface: State
Set the name of the state.

Specified by:
setName in interface State
Parameters:
name - the name of the state (must not be null)
See Also:
State.setName(java.lang.String)

fireStateChanged

protected void fireStateChanged()
Fires a state change to all registered listeners.

Note: It is guaranteed, that the listeners are called back in the event dispatch thread. If the caller calls this method outside the EDT, it switches to the EDT, calls the listeners, switches back to the original thread and returns.


addStateListener

public void addStateListener(StateListener listener)
Description copied from interface: State
Registers the given StateListenerto listen to state changes of this State.

Specified by:
addStateListener in interface State
Parameters:
listener - the StateListenerto add

removeStateListener

public void removeStateListener(StateListener listener)
Description copied from interface: State
Unregisters the given StateListenerfrom this State.

Specified by:
removeStateListener in interface State
Parameters:
listener - the StateListenerto remove

toString

public java.lang.String toString()

stateValueToString

public java.lang.String stateValueToString()
Converts the current state value to a string representation and returns it.


toString

public java.lang.String toString(boolean display_listeners)
Returns a string representation of this State.

Parameters:
display_listeners - if true, the registered listeners will be displayed

appendParametersToString

protected void appendParametersToString(java.lang.StringBuffer str)
Overwrite this method to display additional parameters in the toString() representation of this State.

Parameters:
str - the StringBuffer to append the string representation to