public abstract class AbstractScienceObject extends Object implements ScienceObjectModel, Cloneable, Serializable, Comparable
This code was originally developed by NASA, Goddard Space Flight Center, Code 588 for the Scientist's Expert Assistant (SEA) project for Next Generation Space Telescope (NGST).
Modifier and Type | Class and Description |
---|---|
static interface |
AbstractScienceObject.EventMonitor |
NAME_PROPERTY, PENDING_PROPERTY, VALID_PROPERTY
Constructor and Description |
---|
AbstractScienceObject() |
AbstractScienceObject(String inName) |
Modifier and Type | Method and Description |
---|---|
static void |
addEventMonitor(AbstractScienceObject.EventMonitor listener)
add an event monitor, each monitor will be notified of of all
PropertyChangeEvents fired by this object.
|
void |
addPropertyChangeListener(ReplaceablePropertyChangeListener listener)
add a listener
|
protected boolean |
areNamesEqual(ScienceObjectModel target)
checks equality of the Name property.
|
void |
clearAllListeners()
Convenience method for cloning.
|
Object |
clone()
default implementation: fires superclass (Object)'s clone and suppresses the
CloneNotSupportedException, returning null if super.clone() fails
|
int |
compareTo(Object o)
Default implementation: compares the Names of the objects if they
are ScienceObjectModels.
|
protected String |
createDefaultName()
Creates and returns a default name for an object.
|
boolean |
equals(Object obj)
Default implementation: checks for same name only
|
void |
firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
Report a bound property update to any registered listeners.
|
void |
firePropertyChange(String propertyName,
Object oldValue,
Object newValue,
boolean trace)
Report a bound property update to any registered listeners.
|
void |
fireReplaceObject(Object oldObject,
Object newObject)
Report a replaceObject event to any registered ReplaceablePropertyChangeListeners
that are also ReplaceablePropertyChangeListeners
No events are sent if the old and new objects are '=='.
|
void |
fireReplaceObject(Object oldObject,
Object newObject,
boolean trace)
Report a replaceObject event to any registered ReplaceablePropertyChangeListeners
that are also ReplaceablePropertyChangeListeners
No events are sent if the old and new objects are '=='.
|
void |
fireReplaceObject(ReplaceablePropertyChangeListener newObject)
Report a replaceObject event to any registered propertyChangelisteners
that are also ReplaceablePropertyChangeListeners
No events are sent if the old and new objects are '=='.
|
void |
fireVetoableChange(String propertyName,
Object oldValue,
Object newValue)
Report a bound property update to any registered listeners.
|
void |
fireVetoableChange(String propertyName,
Object oldValue,
Object newValue,
boolean trace)
Report a bound property update to any registered fListeners.
|
Exception |
getException()
returns the local exception (if any).
|
String |
getLabel()
Convenience method for storing a "user friendly" name for an object.
|
String |
getName()
returns the Name property.
|
String |
getObjectIdString()
Useful for debugging output, returns a String containing the class and hashcode of
the specified object.
|
static String |
getObjectIdString(Object obj)
Useful for debugging output, returns a String containing the class and hashcode of
the specified object.
|
ScienceObjectNodeModel |
getParent()
Returns the parent object in a hierarchy of objects.
|
boolean |
isHolding()
default implementation: always returns false, should be overridden by
subclasses that want to implement a delayed updating capability
|
boolean |
isPending()
default implement: always returns false.
|
boolean |
isTracing()
Returns the current tracing mode, @see setTracing()
|
boolean |
isValid()
default implementation: the object is valid if and only if there is
no specified local exception
|
void |
notifyEventMonitors(Object target,
EventObject event) |
void |
propertyChange(PropertyChangeEvent ev)
default implementation.
|
static void |
removeEventMonitor(AbstractScienceObject.EventMonitor listener)
Remove a listener
|
void |
removePropertyChangeListener(ReplaceablePropertyChangeListener listener)
Remove a listener
|
void |
replaceObject(ReplacementEvent ev)
Default implementation.
|
static void |
replaceObjectNYI(Object source,
ReplacementEvent event)
Convenience debugging method for classes that do not support replaceObject() but
find it has been called anyway.
|
void |
setException(Exception e)
sets an exception.
|
void |
setHolding(boolean hold)
default implementation: does nothing
|
void |
setName(String inName)
Sets the Name property.
|
void |
setParent(ScienceObjectNodeModel model)
Sets the parent in the hierarchy.
|
static void |
setTraceAll(boolean t)
Sets a global tracing flag to turn tracing on for all AbstractScienceObjects.
|
void |
setTracing(boolean onOff)
Sets debugging tracing on or off.
|
String |
toString()
local implementation: returns the name of the object, unless thats null
in which case it returns call the superclass (Object)'s toString()
|
protected void |
writeDebug(Object source,
Object message)
default implementation.
|
protected void |
writeError(Object source,
Object message)
default implementation.
|
public AbstractScienceObject()
public AbstractScienceObject(String inName)
public String toString()
public ScienceObjectNodeModel getParent()
getParent
in interface ScienceObjectModel
public void setParent(ScienceObjectNodeModel model)
setParent
in interface ScienceObjectModel
public boolean isPending()
public Exception getException()
getException
in interface ScienceObjectModel
public void setException(Exception e)
setException
in interface ScienceObjectModel
public boolean isValid()
isValid
in interface ScienceObjectModel
public boolean isHolding()
isHolding
in interface ScienceObjectModel
public void setHolding(boolean hold)
setHolding
in interface ScienceObjectModel
public Object clone()
clone
in interface ScienceObjectModel
clone
in class Object
public int compareTo(Object o)
compareTo
in interface Comparable
public boolean equals(Object obj)
public String getName()
getName
in interface ScienceObjectModel
protected boolean areNamesEqual(ScienceObjectModel target)
protected String createDefaultName()
public void setName(String inName)
setName
in interface ScienceObjectModel
public String getLabel()
getLabel
in interface ScienceObjectModel
public boolean isTracing()
isTracing
in interface ScienceObjectModel
public static void setTraceAll(boolean t)
setTracing(boolean)
public void setTracing(boolean onOff)
This is particularly useful for tracking down problems in clone() or replaceObject().
setTracing
in interface ScienceObjectModel
ScienceObjectModel.isTracing()
public void clearAllListeners()
clearAllListeners
in interface ScienceObjectModel
public void addPropertyChangeListener(ReplaceablePropertyChangeListener listener)
addPropertyChangeListener
in interface ScienceObjectModel
listener
- The ReplaceablePropertyChangeListener to be addedpublic void removePropertyChangeListener(ReplaceablePropertyChangeListener listener)
removePropertyChangeListener
in interface ScienceObjectModel
listener
- The ReplaceablePropertyChangeListener to be removedpublic static void addEventMonitor(AbstractScienceObject.EventMonitor listener)
listener
- An event monitor to be addedpublic static void removeEventMonitor(AbstractScienceObject.EventMonitor listener)
listener
- The ReplaceablePropertyChangeListener to be removedpublic void notifyEventMonitors(Object target, EventObject event)
public void propertyChange(PropertyChangeEvent ev)
propertyChange
in interface PropertyChangeListener
public static void replaceObjectNYI(Object source, ReplacementEvent event)
public void replaceObject(ReplacementEvent ev) throws ReplacementVetoException
replaceObject
in interface ReplaceablePropertyChangeListener
ev
- the event that contains details about replacementReplacementVetoException
public void firePropertyChange(String propertyName, Object oldValue, Object newValue)
firePropertyChange
in interface ScienceObjectModel
propertyName
- The programmatic name of the property
that was changed.oldValue
- The old value of the property.newValue
- The new value of the property.public void firePropertyChange(String propertyName, Object oldValue, Object newValue, boolean trace)
propertyName
- The programmatic name of the property
that was changed.oldValue
- The old value of the property.newValue
- The new value of the property.public void fireVetoableChange(String propertyName, Object oldValue, Object newValue) throws ReplaceablePropertyVetoException
propertyName
- The programmatic name of the property
that was changed.oldValue
- The old value of the property.newValue
- The new value of the property.ReplaceablePropertyVetoException
public void fireVetoableChange(String propertyName, Object oldValue, Object newValue, boolean trace) throws ReplaceablePropertyVetoException
propertyName
- The programmatic name of the property
that was changed.oldValue
- The old value of the property.newValue
- The new value of the property.ReplaceablePropertyVetoException
- passed on if received from a listenerpublic void fireReplaceObject(Object oldObject, Object newObject) throws ReplacementVetoException
oldObject
- The object to be replaced by a new objectnewObject
- The new object to replace the current objectReplacementVetoException
public void fireReplaceObject(ReplaceablePropertyChangeListener newObject) throws ReplacementVetoException
newObject
- The new object to replace the current objectReplacementVetoException
public void fireReplaceObject(Object oldObject, Object newObject, boolean trace) throws ReplacementVetoException
newObject
- The new object to replace the current objectReplacementVetoException
protected void writeDebug(Object source, Object message)
protected void writeError(Object source, Object message)
public String getObjectIdString()
Copyright © 2023 Central Laboratory of the Research Councils. All Rights Reserved.