public abstract class AbstractScienceObjectNode extends AbstractScienceObject implements ScienceObjectNodeModel
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).
AbstractScienceObject.EventMonitor
Modifier and Type | Field and Description |
---|---|
protected static String |
cloneIndent |
DATA_SOURCE_PROPERTY, MORE_DATA_PROPERTY
NAME_PROPERTY, PENDING_PROPERTY, VALID_PROPERTY
Constructor and Description |
---|
AbstractScienceObjectNode()
Creates new AbstractScienceObjectNode with blank name and holding turned off.
|
AbstractScienceObjectNode(boolean holding)
Creates new AbstractScienceObjectNode with blank name and specified holding state.
|
AbstractScienceObjectNode(String inName)
Creates new AbstractScienceObjectNode with a name and holding turned off.
|
AbstractScienceObjectNode(String inName,
boolean holding)
creates a new AbstractScienceObjectNode with specified name and specified initial
holding status.
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(ScienceObjectModel newKid)
Adds a ScienceObject as a "child" of the current object.
|
Object |
clone()
Clones this object, and does a DEEP clone on the fChildren.
|
boolean |
equals(Object obj)
Adds equals() checks on the object's DataSources and Children
|
List |
getChildren()
returns List of children of the science object
should be used only when necessary
|
ScienceObjectNodeModel |
getDataSource()
Returns an object that describes the source of the ScienceObjectModel's data.
|
int |
indexOfChild(Object child)
Looks up the index of a child in the children's list, matching on exact
equality (==) NOT on equals().
|
protected void |
initializeTransients()
Sets default values for all transient fields.
|
boolean |
isHolding()
Returns true if updates to the object would be "held".
|
boolean |
isMoreDataAvailable()
Returns true if more data is available for this science object.
|
boolean |
isPending()
Returns true when the object is in the process of performing an update.
|
boolean |
isUpToDate()
Returns true if the object is up-to-date, false otherwise.
|
boolean |
isValid()
Returns true if the object is "valid".
|
ScienceObjectModel |
namedClone()
Copies a ScienceObjectModel and assigns it a new "Copy of" name.
|
protected void |
processUpdates()
Called when updates to a ScienceObject is processed.
|
void |
removeAllChildren()
Removes all children from the ScienceObjectModel.
|
ScienceObjectModel |
removeChild(ScienceObjectModel oldKid)
Removes all occurrences of a ScienceObjectModel as a "child" of the current object.
|
static String |
repeat(String inS,
int n)
Support method for saveAsText.
|
ScienceObjectModel |
replaceChild(ScienceObjectModel oldKid,
ScienceObjectModel newKid)
Replaces all occurrence of the "old" child with the new child
in the propertychange listings.
|
void |
replaceObject(ReplacementEvent ev)
Process a request from one of a ScienceObjectModel's children to "replace"
itself with another object.
|
void |
requestMoreData()
Requests that the science object retrieve any extra data that it has
available from its data source.
|
void |
retrieveMoreData(ScienceObjectNodeModel forObject)
Attempts to retrieve more information for the specified ScienceObjectModel and
populate the ScienceObjectModel with that extra data.
|
void |
saveAsText(PrintWriter pw)
Single argument varient.
|
void |
saveAsText(PrintWriter pw,
int indent)
Prints a reasonably user-friendly description of the object to the specified
PrintWriter.
|
void |
setDataSource(ScienceObjectNodeModel s)
Sets the source of the ScienceObjectModel's data.
|
void |
setHolding(boolean inH)
Sets the "holding" property.
|
void |
setMoreDataAvailable(boolean more)
Sets whether or not more data is available for this science object from its
DataSource.
|
protected void |
setPending(boolean b)
Sets the pending state.
|
void |
setTracing(boolean onOff)
Turns on/off the tracing of propertychange handling in an object;
|
void |
setUpdatesPending(boolean inH)
Sets the flag that indicates whether or not updates to the object are needed.
|
protected void |
update()
Fires off request to update source and background counts.
|
addEventMonitor, addPropertyChangeListener, areNamesEqual, clearAllListeners, compareTo, createDefaultName, firePropertyChange, firePropertyChange, fireReplaceObject, fireReplaceObject, fireReplaceObject, fireVetoableChange, fireVetoableChange, getException, getLabel, getName, getObjectIdString, getObjectIdString, getParent, isTracing, notifyEventMonitors, propertyChange, removeEventMonitor, removePropertyChangeListener, replaceObjectNYI, setException, setName, setParent, setTraceAll, toString, writeDebug, writeError
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addPropertyChangeListener, clearAllListeners, firePropertyChange, getException, getLabel, getName, getParent, isTracing, removePropertyChangeListener, setException, setName, setParent
propertyChange
protected static String cloneIndent
public AbstractScienceObjectNode()
public AbstractScienceObjectNode(String inName, boolean holding)
Subclasses will often initialize with holding=true in order to finish populating the object before trying to update it.
public AbstractScienceObjectNode(boolean holding)
public AbstractScienceObjectNode(String inName)
public Object clone()
NOTE: for subclasses! If a subclass has a separate variable or list that points at fChildren, remember that after this clone() method is completed all fChildren will have also been cloned.
So subclasses may need to "repoint" variables or elemenets of lists that reference child objects, but should NOT re-clone those children.
See ExposureGroup.clone() and Exposure.clone() as examples of classes that need to re-proint existing pointers to correctly point at the correct elements.
clone
in interface ScienceObjectModel
clone
in class AbstractScienceObject
public int indexOfChild(Object child)
child
- Child object to be located in the the children listpublic ScienceObjectModel namedClone()
public boolean equals(Object obj)
equals
in class AbstractScienceObject
public void replaceObject(ReplacementEvent ev) throws ReplacementVetoException
replaceObject
in interface ReplaceablePropertyChangeListener
replaceObject
in class AbstractScienceObject
ev
- the event that contains details about replacementReplacementVetoException
public void saveAsText(PrintWriter pw, int indent)
pw
- The PrintWriter to which to send the outputindent
- A preliminary string (likely all blanks) to pre-pend to
each line of output. Allows recursive calls to an object's children
to indent their output.public static String repeat(String inS, int n)
ntimes.
public void saveAsText(PrintWriter pw)
public boolean isMoreDataAvailable()
isMoreDataAvailable
in interface ScienceObjectNodeModel
public void setMoreDataAvailable(boolean more)
setMoreDataAvailable
in interface ScienceObjectNodeModel
public void retrieveMoreData(ScienceObjectNodeModel forObject)
retrieveMoreData
in interface ScienceObjectNodeModel
forObject
- retrieve more data for this science objectpublic void requestMoreData()
requestMoreData
in interface ScienceObjectNodeModel
public ScienceObjectNodeModel getDataSource()
getDataSource
in interface ScienceObjectNodeModel
public void setDataSource(ScienceObjectNodeModel s)
setDataSource
in interface ScienceObjectNodeModel
public boolean isHolding()
isHolding
in interface ScienceObjectModel
isHolding
in class AbstractScienceObject
processUpdates()
public void setHolding(boolean inH)
setHolding
in interface ScienceObjectModel
setHolding
in class AbstractScienceObject
inH
- processUpdates()
public void setUpdatesPending(boolean inH)
inH
- processUpdates()
protected void update()
processUpdates()
protected void processUpdates()
In the default implementation, this method is empty, and should be overridden by classes that want to be able to hold updates.
To use this feature in a subclass of ScienceObject:
- Use setHolding() to turn delaying of updates on/off.
- Override processUpdates() to contain the actual code that performs
the updating of an object. Remember that processUpdates() or the subclass is
responsible for setting Pending back to false.
- Call update() to request that updates be made to an object. Subclasses
should NOT override this method, it will call processUpdates() if holding is
off. If holding is on, update() will set a flag so that processUpdates() will
be called as soon as a setHolding(false) is received.
- use setUpdatesPending() to manually override the setting of the pending flag. This
is rarely used in subclasses as update() and setHolding() normally manage the pending flag.
Subclasses should not call processUpdates() directly.
public boolean isUpToDate()
public boolean isValid()
isValid
in interface ScienceObjectModel
isValid
in class AbstractScienceObject
public boolean isPending()
isPending
in interface ScienceObjectNodeModel
isPending
in class AbstractScienceObject
protected void setPending(boolean b)
public void setTracing(boolean onOff)
setTracing
in interface ScienceObjectModel
setTracing
in class AbstractScienceObject
ScienceObjectModel.isTracing()
protected void initializeTransients()
public void addChild(ScienceObjectModel newKid)
addChild
in interface ScienceObjectNodeModel
newKid
- ScienceObjectModel to be addedpublic ScienceObjectModel removeChild(ScienceObjectModel oldKid)
removeChild
in interface ScienceObjectNodeModel
oldKid
- ScienceObjectModel to be addedpublic void removeAllChildren()
removeAllChildren
in interface ScienceObjectNodeModel
public ScienceObjectModel replaceChild(ScienceObjectModel oldKid, ScienceObjectModel newKid)
replaceChild
in interface ScienceObjectNodeModel
oldKid
- ScienceObjectModel to be replacednewKid
- new ScienceObjectModel to be "added"public List getChildren()
getChildren
in interface ScienceObjectNodeModel
Copyright © 2023 Central Laboratory of the Research Councils. All Rights Reserved.