Class Node

java.lang.Object
VASSAL.chat.node.Node
All Implemented Interfaces:
MsgSender
Direct Known Subclasses:
PlayerNode, ServerNode

public class Node extends Object implements MsgSender
Base class for the hierarchical server model. Each node has a name, a list of children, and arbitrary extra information encoded in the getInfo() string. Each node can be identified globally by a path name. Messages sent to a node generally broadcast to all descendants of the node.
  • Constructor Details

  • Method Details

    • getId

      public String getId()
    • getInfo

      public String getInfo()
    • getInfoProperty

      public String getInfoProperty(String propName)
    • setInfo

      public void setInfo(String info)
    • setParent

      public void setParent(Node parent)
    • getParent

      public Node getParent()
    • remove

      public void remove(Node child)
    • add

      public void add(Node child)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getChild

      public Node getChild(String id)
      return the child node with the given id, or null if no match
      Parameters:
      id - id of node
      Returns:
      node with that id
    • getDescendant

      public Node getDescendant(String path)
      Return the descendant node with the given path relative to this node
      Parameters:
      path - path
      Returns:
      descendant node
    • send

      public void send(String msg)
      Specified by:
      send in interface MsgSender
    • getLeafDescendants

      public Node[] getLeafDescendants()
    • isLeaf

      public boolean isLeaf()
    • getChildren

      public Node[] getChildren()
    • build

      public static Node build(Node base, String path)
      Constructs from a path name. Instantiates parent nodes with appropriate names as necessary.
      Parameters:
      base - the top-level ancestor of the node to be built. Its name is not included in the path name
      path - path
      Returns:
      node
    • buildWithInfo

      public Node buildWithInfo(Node base, String pathAndInfo)
      Builds a Node from a pathAndInfo string
      Parameters:
      base - base
      pathAndInfo - pathAndInfo
      Returns:
      node
      See Also:
    • getPath

      public String getPath()
    • getPathAndInfo

      public String getPathAndInfo()
      Return a string in the format parentId=parentInfo/childId=childInfo/...
      Returns:
      string