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

java.lang.Object
  extended bycom.sdm.quasar.client.core.states.AbstractState
      extended bycom.sdm.quasar.client.core.states.AbstractBooleanState
          extended bycom.sdm.quasar.client.core.states.AbstractCombinedBooleanState
All Implemented Interfaces:
BooleanState, Disposable, State
Direct Known Subclasses:
ANDBooleanState, ORBooleanState, XORBooleanState

public class AbstractCombinedBooleanState
extends AbstractBooleanState

Abstract base class for boolean states that perform boolean operations on a set of other boolean states.

Version:
1.0
Author:
Thomas Wolf

Field Summary
protected static byte OPERATION_AND
          Operation-constant: The BooleanState values will be combined in an conjunctive way (AND-operation).
protected static byte OPERATION_OR
          Operation-constant: The Operation values will be combined in an disjunctive way (OR-operation).
protected static byte OPERATION_XOR
          Operation-constant: The Operation values will be combined with the XOR-operation.
 
Constructor Summary
AbstractCombinedBooleanState(java.lang.String name, byte operation)
          Creates a new AbstractCombinedBooleanState.
AbstractCombinedBooleanState(java.lang.String name, byte operation, BooleanState[] states, boolean[] signs)
          Creates a new AbstractCombinedBooleanState.
 
Method Summary
 void add(BooleanState booleanState, boolean sign)
          Adds the given BooleanState to this AbstractCombinedBooleanState.
 void dispose()
          Disposes the component.
 BooleanState get(int index)
          Returns the BooleanState combining with the given index.
 int getCount()
          Returns the number of States combining.
 byte getOperation()
          Returns the operation identifier of this AbstractCombinedBooleanState (one of OPERATION_OR, OPERATION_AND or OPERATION_XOR).
 boolean getSign(int index)
          Returns the sign of the BooleanState combining with the given index.
 void remove(BooleanState booleanState)
          Removes the BooleanState from this AbstractCombinedBooleanState.
 void remove(BooleanState booleanState, boolean sign)
          Removes the BooleanState from this AbstractCombinedBooleanState.
 java.lang.String toString()
           
 
Methods inherited from class com.sdm.quasar.client.core.states.AbstractBooleanState
getValue, isValueTrue, setValue, setValueWithoutNotification
 
Methods inherited from class com.sdm.quasar.client.core.states.AbstractState
addStateListener, appendParametersToString, fireStateChanged, getName, removeStateListener, setName, stateValueToString, toString
 
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
addStateListener, getName, removeStateListener, setName
 

Field Detail

OPERATION_AND

protected static final byte OPERATION_AND
Operation-constant: The BooleanState values will be combined in an conjunctive way (AND-operation).

See Also:
Constant Field Values

OPERATION_OR

protected static final byte OPERATION_OR
Operation-constant: The Operation values will be combined in an disjunctive way (OR-operation).

See Also:
Constant Field Values

OPERATION_XOR

protected static final byte OPERATION_XOR
Operation-constant: The Operation values will be combined with the XOR-operation.

See Also:
Constant Field Values
Constructor Detail

AbstractCombinedBooleanState

public AbstractCombinedBooleanState(java.lang.String name,
                                    byte operation)
Creates a new AbstractCombinedBooleanState.

Parameters:
name - the name of this AbstractCombinedBooleanState (not null)

AbstractCombinedBooleanState

public AbstractCombinedBooleanState(java.lang.String name,
                                    byte operation,
                                    BooleanState[] states,
                                    boolean[] signs)
Creates a new AbstractCombinedBooleanState.

Parameters:
name - the name of this AbstractCombinedBooleanState (not null)
operation - the operation identifier of this AbstractCombinedBooleanState (one of OPERATION_OR, OPERATION_AND or OPERATION_XOR)
states - an array of States to watch (if null, no states are watched).
signs - an array of signs for the States (if the array is null or the length does not match the one of the states array, missing signs are threated as true, too many signs are ignored)
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
Overrides:
dispose in class AbstractState
Throws:
DisposeException
See Also:
AbstractState.dispose()

getOperation

public byte getOperation()
Returns the operation identifier of this AbstractCombinedBooleanState (one of OPERATION_OR, OPERATION_AND or OPERATION_XOR).


getCount

public int getCount()
Returns the number of States combining.


get

public BooleanState get(int index)
Returns the BooleanState combining with the given index.

Parameters:
index - the index of the state (must be valid; 0<=index<getCount())

getSign

public boolean getSign(int index)
Returns the sign of the BooleanState combining with the given index.

Parameters:
index - the index of the state (must be valid; 0<=index<getCount())

add

public void add(BooleanState booleanState,
                boolean sign)
Adds the given BooleanState to this AbstractCombinedBooleanState.

Note: A state can be added maximum two times: positive and inverted (even if this makes no sence in most cases).

Parameters:
booleanState - the BooleanState to add
sign - the sign to add (true for positive, false for negation)

remove

public void remove(BooleanState booleanState)
Removes the BooleanState from this AbstractCombinedBooleanState.

Note: This method removes the positive and the negated occurence of the state (if there are two).

Parameters:
booleanState - the BooleanState to remove

remove

public void remove(BooleanState booleanState,
                   boolean sign)
Removes the BooleanState from this AbstractCombinedBooleanState.

Parameters:
booleanState - the BooleanState to remove
sign - the sign to remove (true for the positive, false for negated occurence)

toString

public java.lang.String toString()
Overrides:
toString in class AbstractState