Class DefaultDataNode

    • Constructor Detail

      • DefaultDataNode

        public DefaultDataNode()
        Constructs a blank DefaultDataNode.
      • DefaultDataNode

        public DefaultDataNode​(java.lang.String name)
        Constructs a DefaultDataNode with a given name.
        Parameters:
        name - the name to use for this object.
    • Method Detail

      • allowsChildren

        public boolean allowsChildren()
        The DefaultDataNode implementation of this method returns false.
        Specified by:
        allowsChildren in interface DataNode
        Returns:
        true if the node is of a type which can have child nodes, false otherwise
      • getChildIterator

        public java.util.Iterator getChildIterator()
        The DefaultDataNode implementation of this method throws UnsupportedOperationException (allowsChildren() is false).
        Specified by:
        getChildIterator in interface DataNode
        Returns:
        an 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.
      • getParentObject

        public java.lang.Object 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 interface DataNode
        Returns:
        an object which is the parent of this one, or null
      • setParentObject

        public void setParentObject​(java.lang.Object parent)
        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 interface DataNode
        Parameters:
        parent - an object which is the parent of this one
      • setLabel

        public void setLabel​(java.lang.String label)
        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.
        Specified by:
        setLabel in interface DataNode
        Parameters:
        label - the label to be given to this object
      • getLabel

        public java.lang.String getLabel()
        Description copied from interface: DataNode
        Gets the label of this object. This ought to return the same value getName unless the user of the implementing class has previously called setLabel to change it.
        Specified by:
        getLabel in interface DataNode
        Returns:
        the label of the object
      • setName

        protected void setName​(java.lang.String name)
        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

        public java.lang.String getName()
        Description copied from interface: DataNode
        Gets the name of this object. This is an intrinsic property of the object.
        Specified by:
        getName in interface DataNode
        Returns:
        the name of the object
      • setDescription

        public void setDescription​(java.lang.String desc)
        Sets the value which will be returned by getDescription().
        Parameters:
        desc - the description string
      • getDescription

        public java.lang.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 the 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.
        Specified by:
        getDescription in interface DataNode
        Returns:
        a short string describing this object
      • getNodeTLA

        public java.lang.String getNodeTLA()
        The DefaultDataNode implementation returns the string "...".
        Specified by:
        getNodeTLA in interface DataNode
        Returns:
        "..."
      • getNodeType

        public java.lang.String 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 interface DataNode
        Returns:
        a short description of the type of this DataNode
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • 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 the IconFactory class
      • getIcon

        public javax.swing.Icon getIcon()
        Returns a default icon, unless setIconID has been called, in which case it returns the one indicated by that call.
        Specified by:
        getIcon in interface DataNode
        Returns:
        an icon representing this node
      • getPathSeparator

        public java.lang.String getPathSeparator()
        Returns a default separator string.
        Specified by:
        getPathSeparator in interface DataNode
        Returns:
        "."
      • getPathElement

        public java.lang.String getPathElement()
        The DefaultDataNode implementation returns the label as a default path element.
        Specified by:
        getPathElement in interface DataNode
        Returns:
        the node's label
      • registerDataObject

        public void registerDataObject​(DataType type,
                                       java.lang.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. 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 register
        data - data object of type type for this node - must be non-null and of class type.getDataClass()
      • configureDetail

        public void configureDetail​(DetailViewer dv)
        No custom configuration is performed.
        Specified by:
        configureDetail in interface DataNode
        Parameters:
        dv - the detail viewer which this node is given an opportunity to configure
      • setChildMaker

        public void setChildMaker​(DataNodeFactory factory)
        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 interface DataNode
        Parameters:
        factory - the factory to use for generating children
      • getChildMaker

        public DataNodeFactory getChildMaker()
        Description copied from interface: DataNode
        Gets the factory which should in general be used to generate descendant nodes.
        Specified by:
        getChildMaker in interface DataNode
        Returns:
        the factory used for generating children
      • setCreator

        public void setCreator​(CreationState state)
        Description copied from interface: DataNode
        Stores information about how this node was created.
        Specified by:
        setCreator in interface DataNode
        Parameters:
        state - an object encapsulating the means by which this node was created
      • getCreator

        public CreationState getCreator()
        Description copied from interface: DataNode
        Retrieves information about how this node was created.
        Specified by:
        getCreator in interface DataNode
        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.