java.lang.Object
com.tangosol.coherence.dsltools.termtrees.Term
com.tangosol.coherence.dsltools.termtrees.NodeTerm
All Implemented Interfaces:
Iterable<Term>

public class NodeTerm extends Term
NodeTerm is the class used to represent trees of Terms that can have children.
Author:
djl 2009.08.31
  • Constructor Details

    • NodeTerm

      public NodeTerm(String sFunctor)
      Construct a new TermNode with the given functor.
      Parameters:
      sFunctor - the functor for the Term
    • NodeTerm

      public NodeTerm(String sFunctor, Term t1)
      Construct a new TermNode with the given functor and given Terms.
      Parameters:
      sFunctor - the functor for the Term
      t1 - a child term
    • NodeTerm

      public NodeTerm(String sFunctor, Term t1, Term t2)
      Construct a new TermNode with the given functor and given Terms.
      Parameters:
      sFunctor - the functor for the Term
      t1 - a child term
      t2 - a child term
    • NodeTerm

      public NodeTerm(String sFunctor, Term t1, Term t2, Term t3)
      Construct a new TermNode with the given functor and given Terms.
      Parameters:
      sFunctor - the functor for the Term
      t1 - a child term
      t2 - a child term
      t3 - a child term
    • NodeTerm

      public NodeTerm(String sFunctor, Term t1, Term t2, Term t3, Term t4)
      Construct a new TermNode with the given functor and given Terms.
      Parameters:
      sFunctor - the functor for the Term
      t1 - a child term
      t2 - a child term
      t3 - a child term
      t4 - a child term
    • NodeTerm

      public NodeTerm(String sFunctor, Term t1, Term t2, Term t3, Term t4, Term t5)
      Construct a new TermNode with the given functor and given Terms.
      Parameters:
      sFunctor - the functor for the Term
      t1 - a child term
      t2 - a child term
      t3 - a child term
      t4 - a child term
      t5 - a child term
    • NodeTerm

      public NodeTerm(String sFunctor, Term[] aTerms)
      Construct a new TermNode with the given functor and given Terms.
      Parameters:
      sFunctor - the functor for the Term
      aTerms - children of the node
    • NodeTerm

      public NodeTerm(String sFunctor, Term term, Term[] aTerms)
      Construct a new TermNode with the given functor and given Terms.
      Parameters:
      sFunctor - the functor for the Term
      term - a term
      aTerms - children of the node
    • NodeTerm

      public NodeTerm(String sFunctor, Term[] aTerms, Term term)
      Construct a new TermNode with the given functor and given Terms.
      Parameters:
      sFunctor - the functor for the Term
      aTerms - children of the node
      term - a term
  • Method Details

    • getFunctor

      public String getFunctor()
      Obtain the functor representation of the Term.
      Specified by:
      getFunctor in class Term
      Returns:
      the functor
    • isLeaf

      public boolean isLeaf()
      Answer whether the receiver has children.
      Overrides:
      isLeaf in class Term
      Returns:
      the boolean result of the isLeaf() test
    • isAtom

      public boolean isAtom()
      Answer whether the receiver is an Atomic Term.
      Overrides:
      isAtom in class Term
      Returns:
      the boolean result of the isAtom() test
    • children

      public Term[] children()
      Obtain the childern Terms
      Specified by:
      children in class Term
      Returns:
      the children of the receiver
    • length

      public int length()
      Answer whether the length of the receivers children
      Overrides:
      length in class Term
      Returns:
      the length
    • termAt

      public Term termAt(int index)
      Obtain the child term at the given index. The index is 1 based for children and with at(0) returning the functor as an AtomicTerm. Beware, your 0 based habits can cause problems but 1 based indexing is useful since the functor is an interesting part of the information space. We are bowing here to the wisdom of Mathematica Expressions.
      Specified by:
      termAt in class Term
      Parameters:
      index - index of the child or functor to return
      Returns:
      the child Term or functor as AtomicTerm if index is 0
    • withChild

      public Term withChild(Term t)
      Join the receiver with the given child Term. AtomicTerms will construct a general list term (functor .list.) and NodeTerms may be mutated.
      Specified by:
      withChild in class Term
      Parameters:
      t - the term to join with
      Returns:
      the Term resulting from joining.
    • termEqual

      public boolean termEqual(Term t)
      Answer whether the receiver is equal to the given Term. Terms are equal if their functors are equal and their children are termEqual to the children of the given term.
      Specified by:
      termEqual in class Term
      Parameters:
      t - the Term to check for termEqual
      Returns:
      the boolean result of the comparison
    • fullFormString

      public String fullFormString()
      Answer a String representation of the Term that is allowed to show more internal details than toString() which does not compress information. Similar to Object.toString().
      Specified by:
      fullFormString in class Term
      Returns:
      a String representation of the receiver
    • accept

      public void accept(TermWalker walker)
      Description copied from class: Term
      Do a dispatch back to the given walker.
      Overrides:
      accept in class Term
      Parameters:
      walker - the TermWalker that implements the visitor for Terms
    • toString

      public String toString()
      Return a human-readable description for this Node.
      Overrides:
      toString in class Object
      Returns:
      a String description of the Node
    • setFunctor

      public void setFunctor(String sFunctor)
      Set the receiver's functor to be the given String
      Parameters:
      sFunctor - the new functor for this Term