org.nakedobjects.object.value
Class AbstractNakedValue

java.lang.Object
  extended byorg.nakedobjects.object.value.AbstractNakedValue
All Implemented Interfaces:
Naked, NakedValue, java.io.Serializable
Direct Known Subclasses:
Currency, Logical, Magnitude, Option, TextString, URLString

public abstract class AbstractNakedValue
extends java.lang.Object
implements NakedValue

See Also:
Serialized Form

Constructor Summary
AbstractNakedValue()
           
 
Method Summary
 About about()
          Returns the objects About object.
 void addNakedValueListener(NakedValueListener l)
          Registers an object as a listener of this naked value.
protected  void checkCanOperate()
          Throws an exception if the ojbect is null
 java.lang.String contextualTitle()
           
 AbstractNakedValue deepCopy()
          Returns a deep copy of this object.
 java.lang.String dumpObject()
           
 void fireValueChanged()
          Overridden version of fireValueChanged(NakedValue) that passes null for the old value.
 void fireValueChanged(NakedValue oldValue)
          Allows subclasses (indeed any class) to notify listeners when they are about to change the state of the naked value.
 java.lang.String getClassName()
          Returns the class name without package details e.g., Transaction for the class accounts.Transaction
 java.lang.String getFullClassName()
          Returns the full class name including package details e.g., accounts.Transaction
protected  org.apache.log4j.Logger getLogger()
          subclasses can override (didn't make abstract so that existing subclasses won't break)
 java.lang.String getObjectHelpText()
          Returns a textual desctiption of the object - its contents and possible uses.
 boolean isNull()
          Deprecated.  
 boolean isValid()
          Returns true if the object contains valid data
 java.util.Enumeration nakedValueListeners()
          Returns enumeration of all registered naked value listeners
 void removeNakedValueListener(NakedValueListener l)
          Removes an object as a listener of this naked value.
 void setAbout(About newAbout)
           
 void setNull()
          Deprecated.  
 void setValidity(Validity strategy)
           
 java.lang.String summary()
          Returns a String summarising the state of the object.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.nakedobjects.object.NakedValue
clear, parse, reset, restoreString, saveString
 
Methods inherited from interface org.nakedobjects.object.Naked
copyObject, isEmpty, isSameAs, title
 

Constructor Detail

AbstractNakedValue

public AbstractNakedValue()
Method Detail

getLogger

protected org.apache.log4j.Logger getLogger()
subclasses can override (didn't make abstract so that existing subclasses won't break)


about

public About about()
Returns the objects About object. If none is set up then it returns the default one, namely FieldAbout.READ_WRITE

Specified by:
about in interface Naked

checkCanOperate

protected void checkCanOperate()
Throws an exception if the ojbect is null


contextualTitle

public java.lang.String contextualTitle()

dumpObject

public java.lang.String dumpObject()

getClassName

public java.lang.String getClassName()
Description copied from interface: Naked
Returns the class name without package details e.g., Transaction for the class accounts.Transaction

Specified by:
getClassName in interface Naked

getFullClassName

public java.lang.String getFullClassName()
Description copied from interface: Naked
Returns the full class name including package details e.g., accounts.Transaction

Specified by:
getFullClassName in interface Naked

getObjectHelpText

public java.lang.String getObjectHelpText()
Description copied from interface: Naked
Returns a textual desctiption of the object - its contents and possible uses.

Specified by:
getObjectHelpText in interface Naked

isNull

public boolean isNull()
Deprecated.  

Specified by:
isNull in interface NakedValue
See Also:
Naked.isEmpty()

isValid

public boolean isValid()
Description copied from interface: Naked
Returns true if the object contains valid data

Specified by:
isValid in interface Naked

setAbout

public void setAbout(About newAbout)

setNull

public void setNull()
Deprecated.  

Specified by:
setNull in interface NakedValue
See Also:
NakedValue.clear()

setValidity

public void setValidity(Validity strategy)

summary

public java.lang.String summary()
Description copied from interface: Naked
Returns a String summarising the state of the object.

Specified by:
summary in interface Naked

toString

public java.lang.String toString()
Returns a string representation of this object.

The specification of this string representation is not fixed, but, at the time of writing, consists of title [shortNakedClassName]

Returns:
string representation of object.

addNakedValueListener

public final void addNakedValueListener(NakedValueListener l)
Registers an object as a listener of this naked value. Whenever the naked value's state changes, then all listeners will be notified.

CAVEAT: only objects that are resolved and instantiated will be notified. In general, this means that it is okay for the owning object of a naked value to register itself as a listener, but not for other objects unless it can be arranged for them to have already been resolved from the object store.


removeNakedValueListener

public final void removeNakedValueListener(NakedValueListener l)
Removes an object as a listener of this naked value. The listener will no longer be notified of changes to the naked value's state.


fireValueChanged

public final void fireValueChanged(NakedValue oldValue)
Allows subclasses (indeed any class) to notify listeners when they are about to change the state of the naked value. Typical usage is:

See Also:
deepCopy()

fireValueChanged

public final void fireValueChanged()
Overridden version of fireValueChanged(NakedValue) that passes null for the old value.

This was added since it was noted that some value objects are not in fact serializable.

See Also:
fireValueChanged(NakedValue)

nakedValueListeners

public final java.util.Enumeration nakedValueListeners()
Returns enumeration of all registered naked value listeners


deepCopy

public final AbstractNakedValue deepCopy()
Returns a deep copy of this object.

Alternatively, could have implemented clone(). However, that is a much misunderstood method.

Implementation note: exploits fact that AbstractNakedValue is serializable. Serializes the object to a byte stream, and the deserializes.

See Also:
Serializable, Object.clone()