com.jstatcom.model
Class JSCString
- java.lang.Object
-
- com.jstatcom.model.AbstractJSCData
-
- com.jstatcom.model.JSCString
-
- All Implemented Interfaces:
- JSCData
public final class JSCString extends AbstractJSCData
A string wrapper that conforms to theJSCDatainterface.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.
-
-
Field Summary
Fields Modifier and Type Field and Description static XmlFormat<JSCString>JSCString_XMLXML format field for (de)serialization.
-
Constructor Summary
Constructors Constructor and Description JSCString(java.lang.String name)Creates an emptyJSCString.JSCString(java.lang.String name, java.lang.String value)Creates aJSCStringfromvalue.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclear()Clearsthisdata object.JSCStringcopy()Gets a copy of the current 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(java.lang.String newValue)Sets the value of this tonewValue.java.lang.Stringstring()Gets the stored string value.JSCTypestype()Gets the type of thisJSCDataobject.java.lang.Objectvalue()Gets the underlying value, which is stored as aString.-
Methods inherited from class com.jstatcom.model.AbstractJSCData
addJSCDataListener, display, getJSCProperty, removeJSCDataListener, removeJSCProperty, setJSCProperty, toString
-
-
-
-
Constructor Detail
-
JSCString
public JSCString(java.lang.String name)
Creates an emptyJSCString.- Parameters:
name- the identifier of that object- Throws:
java.lang.IllegalArgumentException- ifnameis not valid orif (name == null)- See Also:
JSCConstants.isValidName(java.lang.String)
-
JSCString
public JSCString(java.lang.String name, java.lang.String value)Creates aJSCStringfromvalue.- Parameters:
name- the identifier of that objectvalue- theStringto be used as 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 JSCString 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
-
isEmpty
public boolean isEmpty()
Gets whetherthisis empty. This method returnstrue, ifvaluereturnsnull. It does not check whether the value string has a length > 0.- 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(java.lang.String newValue)
Sets the value of this tonewValue. Fires aJSCDataEventof type:JSCDataEventTypes.VALUE_CHANGEDif!newValue.equals(getString())JSCDataEventTypes.EMPTY_STATEifnewValue != nulland this was empty beforeJSCDataEventTypes.EMPTY_STATEifnewValue == nulland this was not empty before
- Parameters:
newValue- the new value
-
string
public java.lang.String string()
Gets the stored string value.- Returns:
- a
Stringornullif empty
-
type
public JSCTypes type()
Gets the type of thisJSCDataobject.- Returns:
JSCTypes.STRING- See Also:
JSCTypes
-
value
public java.lang.Object value()
Gets the underlying value, which is stored as aString.- Returns:
- the value object or
nullifthisis empty
-
-
DMelt 3.0 © DataMelt by jWork.ORG