T - the type of the value we containpublic abstract class AbstractValueModel<T> extends Object implements ValueModel<T>, ExternalUpdate
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractValueModel()
Creates internal listener lists.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChangeListener(ChangeListener pDependent)
Add an dependent listener to a ValueModel, "Java style".
|
boolean |
booleanValue()
Converts our value to a boolean.
|
protected void |
checkDisposed()
Helper method to throw a IllegalStateException if we are disposed.
|
void |
dispose()
Cleanup all resources: disconnect from any input sources (like
other ValueModel's ...), and remove all listeners.
|
double |
doubleValue()
Converts our value to a double.
|
protected void |
fireStateChanged()
Helper method for our subclasses to fire ChangeEvents.
|
float |
floatValue()
Converts our value to a float.
|
List<Object> |
getDependents()
Return a immutable list of all direct dependents of the value model.
|
String |
getName()
Return the name of the state.
|
int |
intValue()
Converts our value to an int.
|
boolean |
isDisposed()
Check if the value model is disposed.
|
protected boolean |
isInSetValue()
Marker method that indicates if the object is just firing a state change
due to a call of setValue().
|
boolean |
isSetForced()
Returns true if setValueForced() was called, only useful during a callback.
|
long |
longValue()
Converts our value to an long.
|
void |
onChangeSend(Object pDependent,
String pMethodName)
Add an dependent listener to a ValueModel, "Smalltalk style".
|
void |
removeChangeListener(ChangeListener pDependent)
Remove a dependent listener, "Java style".
|
void |
retractInterestsFor(Object pDependent)
Remove a dependent listener, "Smalltalk style".
|
protected void |
setInSetValue(boolean pInSetValue,
boolean pIsSetForced)
Pendant to isInSetValue() including the "forced" flag.
|
void |
setName(String pName)
Set the name of the state.
|
void |
setObjectValue(Object pValue)
Needed since we generified everything, if we have no type given.
|
void |
setValue(boolean pValue)
Converts the given
boolean to an object and
sets it as new value. |
void |
setValue(double pValue)
Converts the given
double to an object and
sets it as new value. |
void |
setValue(float pValue)
Converts the given
float to an object and
sets it as new value. |
void |
setValue(int pValue)
Converts the given
int to an object and
sets it as new value. |
void |
setValue(long pValue)
Converts the given
long to an object and
sets it as new value. |
void |
setValue(T pValue)
Set a new value, this will call setValue(pValue, false) for the real
work.
|
void |
setValueForced(T pValue)
Set a new value, this will call setValue(pValue, true) for the real
work.
|
void |
signalExternalUpdate()
Signal this object that portions of its data changed.
|
String |
stringValue()
Converts our value to a String.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetValue, isEditable, setValueprotected AbstractValueModel()
public void onChangeSend(Object pDependent, String pMethodName)
onChangeSend in interface ValueModel<T>pDependent - the object to callpMethodName - the method name to call backIllegalArgumentException - if pDependent or pMethod is null,
or no method with the signature
"public void pMethodName(ChangeEvent e)"
is found for pDependent.public void addChangeListener(ChangeListener pDependent)
addChangeListener in interface ValueModel<T>pDependent - the object to callIllegalArgumentException - if pDependent is nullpublic void retractInterestsFor(Object pDependent)
retractInterestsFor in interface ValueModel<T>pDependent - object to de-registerpublic void removeChangeListener(ChangeListener pDependent)
removeChangeListener in interface ValueModel<T>pDependent - object to de-registerpublic void dispose()
dispose in interface ValueModel<T>public boolean isDisposed()
isDisposed in interface ValueModel<T>protected void checkDisposed()
throws IllegalStateException
IllegalStateException - if the value model is disposedpublic List<Object> getDependents()
getDependents in interface ValueModel<T>public String getName()
getName in interface ValueModel<T>public void setName(String pName)
setName in interface ValueModel<T>pName - the name of the state (must not be null)IllegalArgumentException - if pState is nullpublic void setValue(T pValue)
setValue in interface ValueModel<T>pValue - the new value (null is o.k.)UnsupportedOperationException - if this ValueModel is not mutablepublic void setObjectValue(Object pValue)
setObjectValue in interface ValueModel<T>pValue - the value to be casted and set as new valuepublic void setValueForced(T pValue)
setValueForced in interface ValueModel<T>pValue - the new value (null is o.k.)UnsupportedOperationException - if this ValueModel is not mutablepublic void signalExternalUpdate()
signalExternalUpdate in interface ExternalUpdateprotected void fireStateChanged()
protected boolean isInSetValue()
protected void setInSetValue(boolean pInSetValue,
boolean pIsSetForced)
pInSetValue - true or falsepIsSetForced - true or falsepublic boolean isSetForced()
isSetForced in interface ValueModel<T>public boolean booleanValue()
booleanValue in interface ValueModel<T>public void setValue(boolean pValue)
boolean to an object and
sets it as new value.setValue in interface ValueModel<T>pValue - the value to be converted and set as new valuepublic int intValue()
intValue in interface ValueModel<T>public void setValue(int pValue)
int to an object and
sets it as new value.setValue in interface ValueModel<T>pValue - the value to be converted and set as new valuepublic long longValue()
longValue in interface ValueModel<T>public void setValue(long pValue)
long to an object and
sets it as new value.setValue in interface ValueModel<T>pValue - the value to be converted and set as new valuepublic float floatValue()
floatValue in interface ValueModel<T>public void setValue(float pValue)
float to an object and
sets it as new value.setValue in interface ValueModel<T>pValue - the value to be converted and set as new valuepublic double doubleValue()
doubleValue in interface ValueModel<T>public void setValue(double pValue)
double to an object and
sets it as new value.setValue in interface ValueModel<T>pValue - the value to be converted and set as new valuepublic String stringValue()
stringValue in interface ValueModel<T>Copyright © 2017 Jürgen Zeller (privat). All rights reserved.