Class PrologStruct

All Implemented Interfaces:
Serializable, Comparable<PrologTerm>, Iterable<PrologTerm>
Direct Known Subclasses:
PrologList

public class PrologStruct extends PrologCompound implements Iterable<PrologTerm>
Representation of prolog structure.
See Also:
  • Field Details

  • Constructor Details

    • PrologStruct

      public PrologStruct(PrologTerm functor, PrologTerm[] elements)
    • PrologStruct

      public PrologStruct(PrologTerm functor, PrologTerm[] elements, int line, int pos)
    • PrologStruct

      public PrologStruct(String text)
    • PrologStruct

      public PrologStruct(String text, int line, int pos)
    • PrologStruct

      public PrologStruct(PrologTerm functor)
    • PrologStruct

      public PrologStruct(PrologTerm functor, int line, int pos)
    • PrologStruct

      protected PrologStruct(PrologTerm functor, int arity)
    • PrologStruct

      protected PrologStruct(PrologTerm functor, int arity, int line, int pos)
  • Method Details

    • assertFunctor

      private static PrologTerm assertFunctor(PrologTerm functor)
    • getType

      public TermType getType()
      Description copied from class: PrologTerm
      Get term type.
      Specified by:
      getType in class PrologTerm
      Returns:
      term type, must not be null
    • getArity

      public int getArity()
      Description copied from class: PrologTerm
      Arity of element.
      Overrides:
      getArity in class PrologTerm
      Returns:
      arity of element, make sense for compound terms, for primitive terms is 1
    • getTermAt

      public PrologTerm getTermAt(int index)
      Description copied from class: PrologCompound
      Get element for its position
      Specified by:
      getTermAt in class PrologCompound
      Parameters:
      index - zero-based element position
      Returns:
      element in position
    • setElementAt

      public void setElementAt(int index, PrologTerm term)
      Set element for its position.
      Parameters:
      index - zero based index
      term - term to set to position
      Throws:
      ArrayIndexOutOfBoundsException - if wrong index
    • getFunctor

      public PrologTerm getFunctor()
      Description copied from class: PrologTerm
      Get the functor, make sense of structure and its successors, for primitive returns the same term.
      Overrides:
      getFunctor in class PrologTerm
      Returns:
      functor for structure or the same term
    • getPrecedence

      public int getPrecedence()
      Description copied from class: PrologTerm
      Get precedence of the term.
      Overrides:
      getPrecedence in class PrologTerm
      Returns:
      precedence, must not be negative
    • copyWithAnotherFunctor

      public PrologStruct copyWithAnotherFunctor(PrologTerm newFunctor)
      Make copy of the structure with replacement of functor.
      Parameters:
      newFunctor - the new functor, must not be null
      Returns:
      the new instance with replaced functor.
    • isAnyBlock

      public boolean isAnyBlock()
      Description copied from class: PrologTerm
      Check the term describes '()' or '{}' block.
      Overrides:
      isAnyBlock in class PrologTerm
      Returns:
      true if the term is structure describes any kind of supported block
    • isCurlyBlock

      public boolean isCurlyBlock()
      Description copied from class: PrologTerm
      Check the term describes '{}' block.
      Overrides:
      isCurlyBlock in class PrologTerm
      Returns:
      true if the term is structure with '{}' as functor
    • isBlock

      public boolean isBlock()
      Description copied from class: PrologTerm
      Check the term describes '()' block.
      Overrides:
      isBlock in class PrologTerm
      Returns:
      true if the term is structure with '()' as functor
    • flatComma

      public List<PrologTerm> flatComma(List<PrologTerm> list)
      Description copied from class: PrologTerm
      Flat content of the term for comma, make sense for structures.
      Overrides:
      flatComma in class PrologTerm
      Parameters:
      list - list to be filled by comma separated terms
      Returns:
      the same list
    • toString

      public String toString()
      Overrides:
      toString in class PrologTerm
    • isEmpty

      public boolean isEmpty()
      Check that the structure has elements.
      Returns:
      true if there is not elements, false otherwise
    • stream

      public Stream<PrologTerm> stream()
      Overrides:
      stream in class PrologTerm
    • iterator

      public Iterator<PrologTerm> iterator()
      Specified by:
      iterator in interface Iterable<PrologTerm>