com.jstatcom.model
Class JSCDate

java.lang.Object
  extended by com.jstatcom.model.AbstractJSCData
      extended by com.jstatcom.model.JSCDate
All Implemented Interfaces:
JSCData

public final class JSCDate
extends AbstractJSCData

Adapter to TSDate objects that conforms to the JSCData interface. Everytime something changes, a new TSDate object is created, because date objects are immutable.

Whenever the value of this data object changes, registered JSCDataListeners are notified via a JSCDataEvent. If not otherwise stated, the event objects always contain the values before the change and after the change.

This class is thread-safe. All access to mutable data is synchronized. All events are fired outside the synchronized blocks.

Author:
Markus Kraetzig
See Also:
TSDate

Field Summary
static javolution.xml.XmlFormat<JSCDate> JSCDate_XML
          XML format field for (de)serialization.
 
Constructor Summary
JSCDate(java.lang.String name)
          Creates an empty JSCDate.
JSCDate(java.lang.String name, TSDate tsDate)
          Creates a JSCDate for a given TSDate.
 
Method Summary
 void addPeriods(int i)
          Adds i periods to this date.
 void clear()
          Clears this data object.
 JSCDate copy()
          Gets a copy of the current object.
 TSDate getTSDate()
          Gets the stored date object.
 boolean isEmpty()
          Gets whether this is empty.
 boolean isEqual(JSCData o)
          Gets whether the values of this data object and other are logically equal.
 java.lang.String name()
          Gets the name of the data object.
 void setVal(TSDate newDate)
          Sets a new value to this date adapter.
 JSCTypes type()
          Gets the type of this JSCData object.
 java.lang.Object value()
          Gets the underlying value, which is stored as a TSDate.
 
Methods inherited from class com.jstatcom.model.AbstractJSCData
addJSCDataListener, display, getJSCProperty, removeJSCDataListener, removeJSCProperty, setJSCProperty, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

JSCDate_XML

public static final javolution.xml.XmlFormat<JSCDate> JSCDate_XML
XML format field for (de)serialization.

Constructor Detail

JSCDate

public JSCDate(java.lang.String name)
Creates an empty JSCDate.

Parameters:
name - the identifier of that object
Throws:
java.lang.IllegalArgumentException - if name is not valid or if (name == null)
See Also:
JSCConstants.isValidName(java.lang.String)

JSCDate

public JSCDate(java.lang.String name,
               TSDate tsDate)
Creates a JSCDate for a given TSDate.

Parameters:
name - the identifier of that object
tsDate - the date value
Throws:
java.lang.IllegalArgumentException - if name is not valid or if (name == null)
See Also:
JSCConstants.isValidName(java.lang.String)
Method Detail

addPeriods

public void addPeriods(int i)
Adds i periods to this date.

Parameters:
i - number of periods, can also be negative, nothing changes if (i == 0)
Throws:
java.lang.IllegalStateException - isEmpty

clear

public void clear()
Clears this data object. Fires: if it was not empty before. After calling this method isEmpty returns true.


copy

public JSCDate copy()
Description copied from interface: JSCData
Gets a copy of the current object. Implementations of this method must fulfil the two conditions: JSCDataListeners attached to the original object should not be copied.

Returns:
a clonelike copy of the original object
See Also:
JSCData

getTSDate

public TSDate getTSDate()
Gets the stored date object.

Returns:
the used TSDate or null if empty

isEmpty

public boolean isEmpty()
Gets whether this is empty. This method returns true, if value returns null.

Returns:
true if empty

isEqual

public boolean isEqual(JSCData o)
Description copied from interface: JSCData
Gets whether the values of this data object and other are logically equal.

Returns:
true if considered equal according to the logic of the representation
See Also:
JSCData

name

public java.lang.String name()
Description copied from interface: JSCData
Gets the name of the data object. It must fulfil the requirements for variable names defined in JSCConstants.

Returns:
the name
See Also:
JSCData

setVal

public void setVal(TSDate newDate)
Sets a new value to this date adapter. Fires a JSCDataEvent of type:

Parameters:
newDate - the new date, if null it is similar to clear

type

public JSCTypes type()
Gets the type of this JSCData object.

Returns:
JSCTypes.DATE
See Also:
JSCTypes

value

public java.lang.Object value()
Gets the underlying value, which is stored as a TSDate.

Returns:
the value object or null if this is empty