Package uk.ac.starlink.datanode.nodes
Class DefaultDataNode
java.lang.Object
uk.ac.starlink.datanode.nodes.DefaultDataNode
- All Implemented Interfaces:
DataNode
- Direct Known Subclasses:
BranchDataNode
,CompressedDataNode
,DocumentDataNode
,EmptyDataNode
,ErrorDataNode
,FileDataNode
,FITSDataNode
,HDUDataNode
,HTMLDataNode
,PlainDataNode
,ResourceListDataNode
,ScalarDataNode
,StarTableDataNode
,TarBranchDataNode
,TarStreamDataNode
,TfitsDataNode
,TfitsHduDataNode
,VOComponentDataNode
,XMLDataNode
,ZipArchiveDataNode
,ZipBranchDataNode
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.- Version:
- $Id$
- Author:
- Mark Taylor (Starlink)
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a blankDefaultDataNode
.DefaultDataNode
(String name) Constructs aDefaultDataNode
with a given name. -
Method Summary
Modifier and TypeMethodDescriptionboolean
The DefaultDataNode implementation of this method returns false.static void
beep()
It beeps.void
No custom configuration is performed.The DefaultDataNode implementation of this method throws UnsupportedOperationException (allowsChildren()
is false).Gets the factory which should in general be used to generate descendant nodes.Retrieves information about how this node was created.getDataObject
(DataType type) The DefaultDataNode implementation returns any data object which has been registered usingregisterDataObject(uk.ac.starlink.datanode.nodes.DataType, java.lang.Object)
.Gets a concise description of this object.getIcon()
Returns a default icon, unless setIconID has been called, in which case it returns the one indicated by that call.getLabel()
Gets the label of this object.getName()
Gets the name of this object.The DefaultDataNode implementation returns the string "...".Returns a short sentence indicating what kind of node this is.Returns an object which is in some sense the parent of the one this node is based on.The DefaultDataNode implementation returns the label as a default path element.Returns a default separator string.boolean
hasDataObject
(DataType type) The DefaultDataNode implementation returns true for only those data objects which have been registered usingregisterDataObject(uk.ac.starlink.datanode.nodes.DataType, java.lang.Object)
.Uses the node's childMaker to turn objects into data nodes.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 thehasDataObject(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 bygetDescription()
.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
Sets a label for this object.protected void
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.toString()
-
Constructor Details
-
DefaultDataNode
public DefaultDataNode()Constructs a blankDefaultDataNode
. -
DefaultDataNode
Constructs aDefaultDataNode
with a given name.- Parameters:
name
- the name to use for this object.
-
-
Method Details
-
allowsChildren
public boolean allowsChildren()The DefaultDataNode implementation of this method returns false.- Specified by:
allowsChildren
in interfaceDataNode
- Returns:
true
if the node is of a type which can have child nodes,false
otherwise
-
getChildIterator
The DefaultDataNode implementation of this method throws UnsupportedOperationException (allowsChildren()
is false).- Specified by:
getChildIterator
in interfaceDataNode
- Returns:
- an
Iterator
over the children. Each object iterated over should be aDataNode
. Behaviour is undefined if this method is called on an object for whichallowsChildren
returnsfalse
.
-
getParentObject
Description copied from interface:DataNode
Returns an object which is in some sense the parent of the one this node is based on. The parent is not a DataNode, it is something which may get fed to a DataNodeFactory to create DataNode. If no such object exists, which may well be the case, null should be returned.- Specified by:
getParentObject
in interfaceDataNode
- Returns:
- an object which is the parent of this one, or null
-
setParentObject
Description copied from interface:DataNode
Sets the object which is in some sense the parent of the one this node is based on. The parent is not a DataNode, it is something which may get fed to a DataNodeFactory to create DataNode.- Specified by:
setParentObject
in interfaceDataNode
- Parameters:
parent
- an object which is the parent of this one
-
setLabel
Description copied from interface:DataNode
Sets a label for this object. This is like a name but is not intrinsic to the object, so users of implementing classes may call this method to impose a label of their own. -
getLabel
Description copied from interface:DataNode
Gets the label of this object. This ought to return the same valuegetName
unless the user of the implementing class has previously calledsetLabel
to change it. -
setName
Sets the name of this node. Since the name of a node should not change over its lifetime (though a label can), this is only intended for use during construction by subclasses.- Parameters:
name
- the node's name
-
getName
Description copied from interface:DataNode
Gets the name of this object. This is an intrinsic property of the object. -
setDescription
Sets the value which will be returned bygetDescription()
.- Parameters:
desc
- the description string
-
getDescription
Description copied from interface:DataNode
Gets a concise description of this object. The form of the description will depend on the type of node, but it might detail the shape or type of data represented, or otherwise give some information additional to the name. It should not include the return value of thegetName
method, since they may be presented together. It should be on one line, and preferably no longer than around 70 characters. Thenull
value may be returned if there is nothing to say.- Specified by:
getDescription
in interfaceDataNode
- Returns:
- a short string describing this object
-
getNodeTLA
The DefaultDataNode implementation returns the string "...".- Specified by:
getNodeTLA
in interfaceDataNode
- Returns:
- "..."
-
getNodeType
Description copied from interface:DataNode
Returns a short sentence indicating what kind of node this is. The return value should be just a few words. As a rough guideline it should indicate what the implementing class is.- Specified by:
getNodeType
in interfaceDataNode
- Returns:
- a short description of the type of this
DataNode
-
toString
-
setIconID
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.- Parameters:
id
- one of the icon identifiers defined as static final members of theIconFactory
class
-
getIcon
Returns a default icon, unless setIconID has been called, in which case it returns the one indicated by that call. -
getPathSeparator
Returns a default separator string.- Specified by:
getPathSeparator
in interfaceDataNode
- Returns:
- "."
-
getPathElement
The DefaultDataNode implementation returns the label as a default path element.- Specified by:
getPathElement
in interfaceDataNode
- Returns:
- the node's label
-
registerDataObject
Provides a straightforward method of storing typed data objects for this node, as accessed by thehasDataObject(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).- Parameters:
type
- data type of object to registerdata
- data object of type type for this node - must be non-null and of class type.getDataClass()
-
hasDataObject
The DefaultDataNode implementation returns true for only those data objects which have been registered usingregisterDataObject(uk.ac.starlink.datanode.nodes.DataType, java.lang.Object)
.- Specified by:
hasDataObject
in interfaceDataNode
- Parameters:
type
- data object type of interest- Returns:
- true iff a subsequent call of getDataObject(type) is likely to be successful
-
getDataObject
The DefaultDataNode implementation returns any data object which has been registered usingregisterDataObject(uk.ac.starlink.datanode.nodes.DataType, java.lang.Object)
.- Specified by:
getDataObject
in interfaceDataNode
- Parameters:
type
- data object type of interest- Returns:
- data object of type type
- Throws:
DataObjectException
-
configureDetail
No custom configuration is performed.- Specified by:
configureDetail
in interfaceDataNode
- Parameters:
dv
- the detail viewer which this node is given an opportunity to configure
-
setChildMaker
Description copied from interface:DataNode
Sets the factory which should in general be used to generate child nodes. This is not necessarily the factory which is used for generating children of this node, since this node may have special procedures for generating children. However it is the factory which should in general be used for creating descendants of this node.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.
- Specified by:
setChildMaker
in interfaceDataNode
- Parameters:
factory
- the factory to use for generating children
-
getChildMaker
Description copied from interface:DataNode
Gets the factory which should in general be used to generate descendant nodes.- Specified by:
getChildMaker
in interfaceDataNode
- Returns:
- the factory used for generating children
-
makeChild
Uses the node's childMaker to turn objects into data nodes. This convenience method just calls getChildMaker().makeChildNode(this,childObj). In general, nodes should use this method to construct their children.- Parameters:
childObj
- the object which forms the basis for a child data node- See Also:
-
makeErrorChild
Constructs an error data node from a throwable. This method can be used to create a error which is the child of this node. This convenience method just calls getChildMaker().makeErrorDataNode(this,th)- Parameters:
th
- the throwable on which the data node will be based- See Also:
-
setCreator
Description copied from interface:DataNode
Stores information about how this node was created.- Specified by:
setCreator
in interfaceDataNode
- Parameters:
state
- an object encapsulating the means by which this node was created
-
getCreator
Description copied from interface:DataNode
Retrieves information about how this node was created.- Specified by:
getCreator
in interfaceDataNode
- Returns:
- an object encapsulating the means by which this node was created. May be null if no information is available
-
beep
public static void beep()It beeps.
-