com.jstatcom.model
Class JSCDataEvent

java.lang.Object
  extended by com.jstatcom.model.JSCDataEvent

public class JSCDataEvent
extends java.lang.Object

Events of this type are fired by JSCData objects to notify listeners like JSCSymbol objects about changes of various kinds. Instances of this class are constructed via the static valueOf factory methods.

Usage Note:
The events that are fired by the JSCData objects are intended for internal communication only. Events do not occur in the EventDispatchingThread. Clients should rather listen to changes in JSCSymbol objects, especially if GUI related actions are performed.

Author:
Markus Kraetzig

Constructor Summary
JSCDataEvent(JSCData source, JSCDataEventTypes type, java.lang.Object oldValue, java.lang.Object newValue)
          Creates a JSCDataEvent.
 
Method Summary
 java.lang.Object getNewValue()
          Gets the value after the change.
 java.lang.Object getOldValue()
          Gets the value before the change.
 JSCData getSource()
          Gets the data object where the event was fired from.
 JSCDataEventTypes getType()
          Gets the type of this event.
 boolean isSourceEmpty()
          Gets the value after the change as a boolean.
 java.lang.String toString()
          Gets a string representation of this.
static JSCDataEvent valueOfChanged(JSCData source, java.lang.Object oldValue, java.lang.Object newValue)
          Gets an instance of this for events of type JSCDataEventTypes.VALUE_CHANGED.
static JSCDataEvent valueOfEmptyState(JSCData source, boolean isEmptyNow)
          Gets an instance of this for events of type JSCDataEventTypes.EMPTY_STATE.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JSCDataEvent

public JSCDataEvent(JSCData source,
                    JSCDataEventTypes type,
                    java.lang.Object oldValue,
                    java.lang.Object newValue)
Creates a JSCDataEvent.

Parameters:
source - the source data object
type - the type of this event
oldValue - the value before the change
newValue - the value after the change
Method Detail

getNewValue

public final java.lang.Object getNewValue()
Gets the value after the change.

Returns:
an arbitrary object

getOldValue

public final java.lang.Object getOldValue()
Gets the value before the change.

Returns:
an arbitrary object

getSource

public final JSCData getSource()
Gets the data object where the event was fired from.

Returns:
a JSCData object

getType

public final JSCDataEventTypes getType()
Gets the type of this event.

Returns:
one of JSCDataEventTypes

toString

public java.lang.String toString()
Gets a string representation of this.

Overrides:
toString in class java.lang.Object
Returns:
informative string representation

valueOfChanged

public static JSCDataEvent valueOfChanged(JSCData source,
                                          java.lang.Object oldValue,
                                          java.lang.Object newValue)
Gets an instance of this for events of type JSCDataEventTypes.VALUE_CHANGED.

Parameters:
source - the source from which the event is fired
oldValue - the value before the change
newValue - the value after the change
Returns:
a changed event

valueOfEmptyState

public static JSCDataEvent valueOfEmptyState(JSCData source,
                                             boolean isEmptyNow)
Gets an instance of this for events of type JSCDataEventTypes.EMPTY_STATE.

Parameters:
source - the source from which the event is fired
isEmptyNow - true if source is empty
Returns:
a cleared event

isSourceEmpty

public final boolean isSourceEmpty()
Gets the value after the change as a boolean.

Returns:
true if new value is a Boolean that is true, false otherwise