Class HelpTree

java.lang.Object
com.sun.javatest.util.HelpTree

public class HelpTree extends Object
A class that provides a tree of information nodes that can be selectively printed, suitable for simple command line help.
  • Constructor Details

    • HelpTree

      public HelpTree()
      Create an empty HelpTree object.
    • HelpTree

      public HelpTree(HelpTree.Node... nodes)
      Create a HelpTree object containing a given set of nodes.
      Parameters:
      nodes - the contents of the HelpTree
  • Method Details

    • addNode

      public void addNode(HelpTree.Node node)
      Add a node to a help tree.
      Parameters:
      node - the node to be added to the tree
    • getNodeIndent

      public int getNodeIndent()
      Get the indentation used to adjust the left margin when writing the child nodes for a node.
      Returns:
      the indentation used to adjust the left margin when writing the child nodes for a node
      See Also:
    • setNodeIndent

      public void setNodeIndent(int n)
      Set the indentation used to adjust the left margin when writing the child nodes for a node.
      Parameters:
      n - the indentation used to adjust the left margin when writing the child nodes for a node
      See Also:
    • getDescriptionIndent

      public int getDescriptionIndent()
      Get the indentation used to adjust the left margin when writing the description of a node.
      Returns:
      the indentation used to adjust the left margin when writing the description of a node
      See Also:
    • setDescriptionIndent

      public void setDescriptionIndent(int n)
      Set the indentation used to adjust the left margin when writing the description of a node.
      Parameters:
      n - the indentation used to adjust the left margin when writing the description of a node
      See Also:
    • find

      public HelpTree.Selection find(String... words)
      Get a selection representing the nodes that match the given words. If there are nodes whose name or description contain all of the given words, then those nodes will be returned. Otherwise, all nodes whose name or description contain at least one of the given words will be returned.
      Parameters:
      words - the words to be searched for
      Returns:
      a Selection containing the matching nodes
    • findAll

      public HelpTree.Selection findAll(String... words)
      Get a selection representing the nodes that match all of the given words.
      Parameters:
      words - the words to be searched for
      Returns:
      a Selection containing the matching nodes
    • findAny

      public HelpTree.Selection findAny(String... words)
      Get a selection representing the nodes that each match at least one of the given words.
      Parameters:
      words - the words to be searched for
      Returns:
      a Selection containing the matching nodes
    • write

      public void write(Writer out) throws IOException
      Write out all the nodes in this HelpTree.
      Parameters:
      out - the writer to which to write the nodes. If out is a com.sun.javatest.util.WrapWriter, it will be used directly, otherwise a WrapWriter will be created that will write to the given writer.
      Throws:
      IOException - if the is a problem writing the nodes.
      See Also:
    • write

      public void write(Writer out, HelpTree.Selection s) throws IOException
      Write out selected nodes in this HelpTree.
      Parameters:
      out - the writer to which to write the nodes. If out is a com.sun.javatest.util.WrapWriter, it will be used directly, otherwise a WrapWriter will be created that will write to the given writer.
      s - a Selection object containing the nodes to be written
      Throws:
      IOException - if the is a problem writing the nodes.
      See Also:
    • writeSummary

      public void writeSummary(Writer out) throws IOException
      Write out a summary of all the nodes in this HelpTree. The summary will contain the name and description of the top level nodes, but not any of their children.
      Parameters:
      out - the writer to which to write the nodes. If out is a com.sun.javatest.util.WrapWriter, it will be used directly, otherwise a WrapWriter will be created that will write to the given writer.
      Throws:
      IOException - if the is a problem writing the nodes.
      See Also:
    • getNodeComparator

      public Comparator<HelpTree.Node> getNodeComparator()
      Returns current comparator used in find methods method
      Returns:
      current node comparator
    • setNodeComparator

      public void setNodeComparator(Comparator<HelpTree.Node> comparator)
      Sets the comparator which will be used in find methods method
      Parameters:
      comparator - Comparator to set