com.jstatcom.model
Class JSCDRange
- java.lang.Object
-
- com.jstatcom.model.AbstractJSCData
-
- com.jstatcom.model.JSCDRange
-
- All Implemented Interfaces:
- JSCData
public final class JSCDRange extends AbstractJSCData
Adapter toTSDateRangeobjects that conforms to theJSCDatainterface. Everytime something changes, a newTSDateRangeobject is created, because range 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:
TSDateRange
-
-
Field Summary
Fields Modifier and Type Field and Description static XmlFormat<JSCDRange>JSCDRange_XMLXML format field for (de)serialization.
-
Constructor Summary
Constructors Constructor and Description JSCDRange(java.lang.String name)Creates an emptyJSCDRange.JSCDRange(java.lang.String name, TSDateRange tsRange)Creates aJSCDRangefor a givenTSDateRange.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclear()Clearsthisdata object.JSCDRangecopy()Gets a copy of the current object.booleanencloses(JSCDate date)Gets whetherdateis enclosed by this range.booleanencloses(JSCDRange dRange)Gets whetherdRangeis enclosed by this range.TSDateRangegetTSDateRange()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(TSDateRange newRange)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 aTSDateRange.-
Methods inherited from class com.jstatcom.model.AbstractJSCData
addJSCDataListener, display, getJSCProperty, removeJSCDataListener, removeJSCProperty, setJSCProperty, toString
-
-
-
-
Constructor Detail
-
JSCDRange
public JSCDRange(java.lang.String name)
Creates an emptyJSCDRange.- Parameters:
name- the identifier of that object- Throws:
java.lang.IllegalArgumentException- ifnameis not valid orif (name == null)- See Also:
JSCConstants.isValidName(java.lang.String)
-
JSCDRange
public JSCDRange(java.lang.String name, TSDateRange tsRange)Creates aJSCDRangefor a givenTSDateRange.- Parameters:
name- the identifier of that objecttsRange- the date value- Throws:
java.lang.IllegalArgumentException- ifnameis not valid orif (name == null)- See Also:
JSCConstants.isValidName(java.lang.String)
-
-
Method Detail
-
clear
public void clear()
Clearsthisdata object. Fires:JSCDataEventTypes.EMPTY_STATEeventJSCDataEventTypes.VALUE_CHANGEDevent
isEmptyreturnstrue.
-
copy
public JSCDRange 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
-
encloses
public boolean encloses(JSCDate date)
Gets whetherdateis enclosed by this range.- Parameters:
date- theJSCDateto be checked- Returns:
trueifdateist enclosed bythis- Throws:
java.lang.IllegalArgumentException-if (date == null)orif (date.isEmpty())orif (isEmpty())
-
encloses
public boolean encloses(JSCDRange dRange)
Gets whetherdRangeis enclosed by this range.- Parameters:
dRange- theJSCDRangeto be checked- Returns:
trueifdRangeist enclosed bythis- Throws:
java.lang.IllegalArgumentException-if (dRange == null)orif (dRange.isEmpty())orif (isEmpty())
-
getTSDateRange
public TSDateRange getTSDateRange()
Gets the stored date object.- Returns:
- the used
TSDateRangeornullif 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(TSDateRange newRange)
Sets a new value to this date adapter. Fires aJSCDataEventof type:JSCDataEventTypes.VALUE_CHANGEDif!newRange.equals(getTSDateRange())JSCDataEventTypes.EMPTY_STATEifnewRange != nulland this was empty beforeJSCDataEventTypes.EMPTY_STATEifnewRange == nulland this was not empty before
- Parameters:
newRange- the new range, ifnullit is similar toclear
-
type
public JSCTypes type()
Gets the type of thisJSCDataobject.- Returns:
JSCTypes.DRANGE- See Also:
JSCTypes
-
value
public java.lang.Object value()
Gets the underlying value, which is stored as aTSDateRange.- Returns:
- the value object or
nullifthisis empty
-
-
DMelt 3.0 © DataMelt by jWork.ORG