|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.starlink.datanode.nodes.DefaultDataNode
public class DefaultDataNode
A basic implementation of the DataNode
interface.
It may be used directly for simple nodes, or it may be subclassed
for convenience in writing more specific DataNode
implementors.
Constructor Summary | |
---|---|
DefaultDataNode()
Constructs a blank DefaultDataNode . |
|
DefaultDataNode(String name)
Constructs a DefaultDataNode with a given name. |
Method Summary | |
---|---|
boolean |
allowsChildren()
The DefaultDataNode implementation of this method returns false. |
static void |
beep()
It beeps. |
void |
configureDetail(DetailViewer dv)
No custom configuration is performed. |
Iterator |
getChildIterator()
The DefaultDataNode implementation of this method throws UnsupportedOperationException ( allowsChildren() is false). |
DataNodeFactory |
getChildMaker()
Gets the factory which should in general be used to generate descendant nodes. |
CreationState |
getCreator()
Retrieves information about how this node was created. |
Object |
getDataObject(DataType type)
The DefaultDataNode implementation returns any data object which has been registered using registerDataObject(uk.ac.starlink.datanode.nodes.DataType, java.lang.Object) . |
String |
getDescription()
Gets a concise description of this object. |
Icon |
getIcon()
Returns a default icon, unless setIconID has been called, in which case it returns the one indicated by that call. |
String |
getLabel()
Gets the label of this object. |
String |
getName()
Gets the name of this object. |
String |
getNodeTLA()
The DefaultDataNode implementation returns the string "...". |
String |
getNodeType()
Returns a short sentence indicating what kind of node this is. |
Object |
getParentObject()
Returns an object which is in some sense the parent of the one this node is based on. |
String |
getPathElement()
The DefaultDataNode implementation returns the label as a default path element. |
String |
getPathSeparator()
Returns a default separator string. |
boolean |
hasDataObject(DataType type)
The DefaultDataNode implementation returns true for only those data objects which have been registered using registerDataObject(uk.ac.starlink.datanode.nodes.DataType, java.lang.Object) . |
DataNode |
makeChild(Object childObj)
Uses the node's childMaker to turn objects into data nodes. |
DataNode |
makeErrorChild(Throwable th)
Constructs an error data node from a throwable. |
void |
registerDataObject(DataType type,
Object data)
Provides a straightforward method of storing typed data objects for this node, as accessed by the hasDataObject(uk.ac.starlink.datanode.nodes.DataType) /getDataObject(uk.ac.starlink.datanode.nodes.DataType)
methods. |
void |
setChildMaker(DataNodeFactory factory)
Sets the factory which should in general be used to generate child nodes. |
void |
setCreator(CreationState state)
Stores information about how this node was created. |
void |
setDescription(String desc)
Sets the value which will be returned by getDescription() . |
protected void |
setIconID(short id)
This may be called by subclasses to set the icon returned by this node to one of the ones defined in the IconFactory class. |
void |
setLabel(String label)
Sets a label for this object. |
protected void |
setName(String name)
Sets the name of this node. |
void |
setParentObject(Object parent)
Sets the object which is in some sense the parent of the one this node is based on. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DefaultDataNode()
DefaultDataNode
.
public DefaultDataNode(String name)
DefaultDataNode
with a given name.
name
- the name to use for this object.Method Detail |
---|
public boolean allowsChildren()
allowsChildren
in interface DataNode
true
if the node is of a type which can have
child nodes, false
otherwisepublic Iterator getChildIterator()
allowsChildren()
is false).
getChildIterator
in interface DataNode
Iterator
over the children. Each object
iterated over should be a DataNode
.
Behaviour is undefined if this method is called on an
object for which allowsChildren
returns
false
.public Object getParentObject()
DataNode
getParentObject
in interface DataNode
public void setParentObject(Object parent)
DataNode
setParentObject
in interface DataNode
parent
- an object which is the parent of this onepublic void setLabel(String label)
DataNode
setLabel
in interface DataNode
label
- the label to be given to this objectpublic String getLabel()
DataNode
getName
unless the user of the implementing class
has previously called setLabel
to change it.
getLabel
in interface DataNode
protected void setName(String name)
name
- the node's namepublic String getName()
DataNode
getName
in interface DataNode
public void setDescription(String desc)
getDescription()
.
desc
- the description stringpublic String getDescription()
DataNode
getName
method, since they may be presented together.
It should be on one line, and preferably no longer than around
70 characters. The null
value may be returned if
there is nothing to say.
getDescription
in interface DataNode
public String getNodeTLA()
getNodeTLA
in interface DataNode
public String getNodeType()
DataNode
getNodeType
in interface DataNode
DataNode
public String toString()
toString
in class Object
protected void setIconID(short id)
id
- one of the icon identifiers defined as static
final members of the IconFactory
classpublic Icon getIcon()
getIcon
in interface DataNode
public String getPathSeparator()
getPathSeparator
in interface DataNode
public String getPathElement()
getPathElement
in interface DataNode
public void registerDataObject(DataType type, Object data)
hasDataObject(uk.ac.starlink.datanode.nodes.DataType)
/getDataObject(uk.ac.starlink.datanode.nodes.DataType)
methods. You can invoke this method to register a data object
for a particular data type. Note that this is only suitable if
the data object is free or cheap to come by - in the case
that its construction is expensive then the data object ought to
be constructed on demand by getDataObject rather than being
registered as a matter of course (since it may never be needed).
type
- data type of object to registerdata
- data object of type type for this node -
must be non-null and of class type.getDataClass()public boolean hasDataObject(DataType type)
registerDataObject(uk.ac.starlink.datanode.nodes.DataType, java.lang.Object)
.
hasDataObject
in interface DataNode
type
- data object type of interest
public Object getDataObject(DataType type) throws DataObjectException
registerDataObject(uk.ac.starlink.datanode.nodes.DataType, java.lang.Object)
.
getDataObject
in interface DataNode
type
- data object type of interest
DataObjectException
public void configureDetail(DetailViewer dv)
configureDetail
in interface DataNode
dv
- the detail viewer which this node is given an opportunity
to configurepublic void setChildMaker(DataNodeFactory factory)
DataNode
This method should only be used by applications which wish to restrict the type of node which can appear in a whole subtree of the node hierarchy. The childMaker is normally inherited from parent to child, so for instance customising the childMaker of the tree root by removing certain builders will prevent such nodes from appearing anywhere in the tree.
setChildMaker
in interface DataNode
factory
- the factory to use for generating childrenpublic DataNodeFactory getChildMaker()
DataNode
getChildMaker
in interface DataNode
public DataNode makeChild(Object childObj)
childObj
- the object which forms the basis for a child
data nodeDataNodeFactory.makeDataNode(uk.ac.starlink.datanode.nodes.DataNode, java.lang.Object)
public DataNode makeErrorChild(Throwable th)
th
- the throwable on which the data node will be basedDataNodeFactory.makeErrorDataNode(uk.ac.starlink.datanode.nodes.DataNode, java.lang.Throwable)
public void setCreator(CreationState state)
DataNode
setCreator
in interface DataNode
state
- an object encapsulating the means by which this node
was createdpublic CreationState getCreator()
DataNode
getCreator
in interface DataNode
public static void beep()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |