com.jstatcom.model
Class JSCDate
- java.lang.Object
-
- com.jstatcom.model.AbstractJSCData
-
- com.jstatcom.model.JSCDate
-
- All Implemented Interfaces:
- JSCData
public final class JSCDate extends AbstractJSCData
Adapter toTSDateobjects that conforms to theJSCDatainterface. Everytime something changes, a newTSDateobject is created, because date objects are immutable.Whenever the value of this data object changes, registered
JSCDataListenersare notified via aJSCDataEvent. 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.
- See Also:
TSDate
-
-
Field Summary
Fields Modifier and Type Field and Description static XmlFormat<JSCDate>JSCDate_XMLXML format field for (de)serialization.
-
Constructor Summary
Constructors Constructor and Description JSCDate(java.lang.String name)Creates an emptyJSCDate.JSCDate(java.lang.String name, TSDate tsDate)Creates aJSCDatefor a givenTSDate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddPeriods(int i)Addsiperiods to this date.voidclear()Clearsthisdata object.JSCDatecopy()Gets a copy of the current object.TSDategetTSDate()Gets the stored date object.booleanisEmpty()Gets whetherthisis empty.booleanisEqual(JSCData o)Gets whether the values of this data object andotherare logically equal.java.lang.Stringname()Gets the name of the data object.voidsetVal(TSDate newDate)Sets a new value to this date adapter.JSCTypestype()Gets the type of thisJSCDataobject.java.lang.Objectvalue()Gets the underlying value, which is stored as aTSDate.-
Methods inherited from class com.jstatcom.model.AbstractJSCData
addJSCDataListener, display, getJSCProperty, removeJSCDataListener, removeJSCProperty, setJSCProperty, toString
-
-
-
-
Constructor Detail
-
JSCDate
public JSCDate(java.lang.String name)
Creates an emptyJSCDate.- Parameters:
name- the identifier of that object- Throws:
java.lang.IllegalArgumentException- ifnameis not valid orif (name == null)- See Also:
JSCConstants.isValidName(java.lang.String)
-
JSCDate
public JSCDate(java.lang.String name, TSDate tsDate)Creates aJSCDatefor a givenTSDate.- Parameters:
name- the identifier of that objecttsDate- the date value- Throws:
java.lang.IllegalArgumentException- ifnameis not valid orif (name == null)- See Also:
JSCConstants.isValidName(java.lang.String)
-
-
Method Detail
-
addPeriods
public void addPeriods(int i)
Addsiperiods to this date.- Parameters:
i- number of periods, can also be negative, nothing changesif (i == 0)- Throws:
java.lang.IllegalStateException-isEmpty
-
clear
public void clear()
Clearsthisdata object. Fires:JSCDataEventTypes.EMPTY_STATEeventJSCDataEventTypes.VALUE_CHANGEDevent
isEmptyreturnstrue.
-
copy
public JSCDate copy()
Description copied from interface:JSCDataGets a copy of the current object. Implementations of this method must fulfil the two conditions:a.isEqual(a.copy())- compares valuesa.getName().equals(a.copy().getName())- compares name
JSCDataListenersattached 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
TSDateornullif empty
-
isEmpty
public boolean isEmpty()
Gets whetherthisis empty. This method returnstrue, ifvaluereturnsnull.- Returns:
trueif empty
-
isEqual
public boolean isEqual(JSCData o)
Description copied from interface:JSCDataGets whether the values of this data object andotherare logically equal.- Returns:
trueif considered equal according to the logic of the representation- See Also:
JSCData
-
name
public java.lang.String name()
Description copied from interface:JSCDataGets the name of the data object. It must fulfil the requirements for variable names defined inJSCConstants.- Returns:
- the name
- See Also:
JSCData
-
setVal
public void setVal(TSDate newDate)
Sets a new value to this date adapter. Fires aJSCDataEventof type:JSCDataEventTypes.VALUE_CHANGEDif!newDate.equals(getTSDate())JSCDataEventTypes.EMPTY_STATEifnewDate != nulland this was empty beforeJSCDataEventTypes.EMPTY_STATEifnewDate == nulland this was not empty before
- Parameters:
newDate- the new date, ifnullit is similar toclear
-
type
public JSCTypes type()
Gets the type of thisJSCDataobject.- Returns:
JSCTypes.DATE- See Also:
JSCTypes
-
value
public java.lang.Object value()
Gets the underlying value, which is stored as aTSDate.- Returns:
- the value object or
nullifthisis empty
-
-
DMelt 3.0 © DataMelt by jWork.ORG