Interface TreeQuestion.Model

Enclosing class:
TreeQuestion

public static interface TreeQuestion.Model
An interface that provides the model for the tree whose nodes are selected by a TreeQuestion.
  • Method Summary

    Modifier and Type
    Method
    Description
    getChild(Object node, int index)
    Get a child of a specified node, or null if no such child exists.
    int
    Get the number of children of a specified node.
    Get the name of a specified node.
    Get the full path from the root node of a specified node.
    Get the root node of the tree.
    boolean
    isLeaf(Object node)
    Determine if this a node is a leaf node.
  • Method Details

    • getRoot

      Object getRoot()
      Get the root node of the tree.
      Returns:
      the root node of the tree.
    • getChildCount

      int getChildCount(Object node)
      Get the number of children of a specified node.
      Parameters:
      node - the node for which to get the number of children
      Returns:
      the number of children of the specified node
    • getChild

      Object getChild(Object node, int index)
      Get a child of a specified node, or null if no such child exists.
      Parameters:
      node - the node for which to get the child
      index - the index of the child; this should be a number greater than or equal to zero and less than the number of children of the node.
      Returns:
      the specified child, or null if index does not identify a valid child.
      See Also:
    • getName

      String getName(Object node)
      Get the name of a specified node. The name will be used to construct paths. At a minimum, it should not contain '/'.
      Parameters:
      node - the node whose name is required
      Returns:
      the name of the specified node
    • getPath

      String getPath(Object node)
      Get the full path from the root node of a specified node.
      Parameters:
      node - the node whose path is required
      Returns:
      the path of the specified node from the root node, as composed from the names of this node and its ancestors, using '/' to separate the individual names.
    • isLeaf

      boolean isLeaf(Object node)
      Determine if this a node is a leaf node. This is primarily an attribute of the node's actual type, and is not necessarily the same as having zero children. (A leaf node implies zero children, but zero children does not imply a node is a leaf.)
      Parameters:
      node - the node to check for being a leaf
      Returns:
      true if the specified node is a leaf node, and false otherwise.