com.rbnb.sapi
Class ChannelTree

java.lang.Object
  extended by com.rbnb.sapi.ChannelTree
All Implemented Interfaces:
Serializable

public final class ChannelTree
extends Object
implements Serializable

A ChannelMap accessory which provides a read-only hierarchical view of channels. This is useful mainly for clients who wish to present such a view to end users, such as RBNB Admin.

The ChannelTree is created from a ChannelMap via a factory method, createFromChannelMap(ChannelMap). The tree consists of objects of type ChannelTree.Node. Each node represents a name between slashes.

For example, a ChannelMap consisting of the channel: '/Server/source/c0' would yield a root node 'Server', with a child 'source', who has a child 'c0'. Note that for user constructed ChannelMaps, it is possible to have multiple roots. So a map with the channels 'foo' and 'bar' would yield a "tree" with two roots, 'foo' and 'bar'.

For an explanation of how name matching works, see Sink.Request.

Requires Java 1.2 or later.

Since:
V2.2
See Also:
Sink.Request(com.rbnb.sapi.ChannelMap cm, double start, double duration, String reference), Serialized Form
Author:
WHF

Nested Class Summary
static class ChannelTree.Node
          Represents a piece of a channel name.
static class ChannelTree.NodeTypeEnum
          Enumerated type for various channel node types.
 
Field Summary
static ChannelTree.NodeTypeEnum CHANNEL
          The node type which represents a data bearing channel node.
static ChannelTree.NodeTypeEnum CONTROLLER
          The node type which represents an RBNB control client.
static ChannelTree EMPTY_TREE
           
static ChannelTree.NodeTypeEnum FOLDER
          The node type which represents a organizational node without data.
static ChannelTree.NodeTypeEnum PLUGIN
          The node type which represents a PlugIn (a dynamic data source).
static ChannelTree.NodeTypeEnum SERVER
          The node type which represents an RBNB server.
static ChannelTree.NodeTypeEnum SINK
          The node type which represents a data sink.
static ChannelTree.NodeTypeEnum SOURCE
          The node type which represents a data source.
 
Method Summary
static ChannelTree createFromChannelMap(ChannelMap cmap)
          Creates a new read only view of the provided channel map.
static ChannelTree createFromChannelMap(ChannelMap cmap, String rootName)
          Creates a new read only view of the provided channel map with a single named root node.
 ChannelTree.Node findNode(String fullname)
          Returns the node which exactly matches the given full name, or null.
 Iterator iterator()
          Allows iteration over the entire tree.
 ChannelTree merge(ChannelTree toMerge)
          Produces a new tree, which is the result of merging this with the map toMerge.
 Iterator rootIterator()
          Allows iteration over the root nodes only.
 String toString()
          Uses iterator() to traverse this Tree and provide a hierarchical debug output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONTROLLER

public static final ChannelTree.NodeTypeEnum CONTROLLER
The node type which represents an RBNB control client.


SERVER

public static final ChannelTree.NodeTypeEnum SERVER
The node type which represents an RBNB server.


SOURCE

public static final ChannelTree.NodeTypeEnum SOURCE
The node type which represents a data source.


PLUGIN

public static final ChannelTree.NodeTypeEnum PLUGIN
The node type which represents a PlugIn (a dynamic data source).


SINK

public static final ChannelTree.NodeTypeEnum SINK
The node type which represents a data sink.


FOLDER

public static final ChannelTree.NodeTypeEnum FOLDER
The node type which represents a organizational node without data.


CHANNEL

public static final ChannelTree.NodeTypeEnum CHANNEL
The node type which represents a data bearing channel node.


EMPTY_TREE

public static final ChannelTree EMPTY_TREE
Method Detail

createFromChannelMap

public static ChannelTree createFromChannelMap(ChannelMap cmap)
Creates a new read only view of the provided channel map.

Throws:
NullPointerException - if map is null.

createFromChannelMap

public static ChannelTree createFromChannelMap(ChannelMap cmap,
                                               String rootName)
Creates a new read only view of the provided channel map with a single named root node. The faux root node has the name provided and is of type FOLDER. It forms the base of the hierarchy, such that all roots in the ChannelMap are children of this root, and it is the only root.

Throws:
NullPointerException - if the map of root name is null.
IllegalArgumentException - if the root name is empty.
Since:
V2.5B8

merge

public ChannelTree merge(ChannelTree toMerge)
Produces a new tree, which is the result of merging this with the map toMerge. In the case of a discrepancy in node type, the this tree will win.

In general, bigTree.merge(smallTree) is faster than smallTree.merge(bigTree).


findNode

public ChannelTree.Node findNode(String fullname)
Returns the node which exactly matches the given full name, or null.


rootIterator

public Iterator rootIterator()
Allows iteration over the root nodes only.


iterator

public Iterator iterator()
Allows iteration over the entire tree. The traversal is guaranteed to be alphabetical by fully qualified channel name. Therefore, "/Server/foo/bar/c0" will come before "/Server/kluge".


toString

public String toString()
Uses iterator() to traverse this Tree and provide a hierarchical debug output.

Overrides:
toString in class Object