Class Struct

  • All Implemented Interfaces:
    java.io.Serializable

    public class Struct
    extends Term
    Struct class represents both compound prolog term and atom term (considered as 0-arity compound).
    See Also:
    Serialized Form
    • Constructor Detail

      • Struct

        @Deprecated
        public Struct​(java.lang.String f,
                      Term... argList)
        Deprecated.
        Builds a compound, with an array of arguments
      • Struct

        @Deprecated
        public Struct()
        Deprecated.
        Builds a structure representing an emptyWithStandardOperators list
      • Struct

        @Deprecated
        public Struct​(java.util.Collection<? extends Term> terms)
        Deprecated.
      • Struct

        @Deprecated
        public Struct​(Term h,
                      Term t)
        Deprecated.
        Builds a list providing head and tail
      • Struct

        @Deprecated
        public Struct​(Term... argList)
        Deprecated.
        Builds a list specifying the elements
      • Struct

        @Deprecated
        public Struct​(java.util.stream.Stream<? extends Term> stream)
        Deprecated.
      • Struct

        @Deprecated
        public Struct​(java.util.Iterator<? extends Term> i)
        Deprecated.
    • Method Detail

      • emptySet

        public static Struct emptySet()
      • set

        public static Struct set​(java.util.Collection<? extends Term> terms)
      • set

        public static Struct set​(java.util.stream.Stream<? extends Term> terms)
      • set

        public static Struct set​(java.lang.Iterable<? extends Term> terms)
      • set

        public static Struct set​(java.util.Iterator<? extends Term> terms)
      • cut

        public static Struct cut()
      • truth

        public static Struct truth​(boolean value)
      • directive

        public static Struct directive​(Term body)
      • atom

        public static Struct atom​(java.lang.String atom)
      • of

        public static Struct of​(java.lang.String functor,
                                Term term1,
                                Term... terms)
      • of

        public static Struct of​(java.lang.String functor,
                                Term[] terms)
      • emptyList

        public static Struct emptyList()
      • list

        public static Struct list​(Term... terms)
      • list

        public static Struct list​(java.util.stream.Stream<? extends Term> terms)
      • list

        public static Struct list​(java.util.Iterator<? extends Term> terms)
      • list

        public static Struct list​(java.lang.Iterable<? extends Term> terms)
      • list

        public static Struct list​(java.util.stream.Stream<? extends Term> items,
                                  Term last)
      • list

        public static Struct list​(java.lang.Iterable<? extends Term> items,
                                  Term last)
      • list

        public static Struct list​(java.util.Iterator<? extends Term> items,
                                  Term last)
      • tuple

        public static Struct tuple​(java.util.Collection<? extends Term> terms)
      • tuple

        public static Struct tuple​(java.lang.Iterable<? extends Term> terms)
      • tuple

        public static Struct tuple​(java.util.Iterator<? extends Term> terms)
      • tuple

        public static Struct tuple​(java.util.stream.Stream<? extends Term> terms)
      • tuple

        public static Struct tuple​(java.util.List<? extends Term> terms)
      • getArity

        public int getArity()
        Gets the number of elements of this structure
      • getName

        public java.lang.String getName()
        Gets the functor name of this structure
      • getArg

        public Term getArg​(int index)
        Gets the i-th element of this structure

        No bound check is done

      • setArg

        public void setArg​(int index,
                           Term argument)
        Sets the i-th element of this structure

        (Only for internal service)

      • getTerm

        public Term getTerm​(int index)
        Gets the i-th element of this structure

        No bound check is done. It is equivalent to getArg(index).getTerm()

      • isNumber

        @Deprecated
        public boolean isNumber()
        Deprecated.
        is this term a prolog numeric term?
        Overrides:
        isNumber in class Term
      • isStruct

        @Deprecated
        public boolean isStruct()
        Deprecated.
        is this term a struct
        Overrides:
        isStruct in class Term
      • isVar

        @Deprecated
        public boolean isVar()
        Deprecated.
        is this term a variable
        Overrides:
        isVar in class Term
      • isAtomic

        public boolean isAtomic()
        Description copied from class: Term
        is this term a constant prolog term?
        Overrides:
        isAtomic in class Term
      • isCompound

        public boolean isCompound()
        Description copied from class: Term
        is this term a prolog compound term?
        Overrides:
        isCompound in class Term
      • isAtom

        public boolean isAtom()
        Description copied from class: Term
        is this term a prolog (alphanumeric) atom?
        Overrides:
        isAtom in class Term
      • isGround

        public boolean isGround()
        Description copied from class: Term
        is this term a ground term?
        Overrides:
        isGround in class Term
      • equals

        public boolean equals​(java.lang.Object t)
        Description copied from class: Term
        Tests for the equality of two object terms
        Overrides:
        equals in class Term
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • isClause

        public boolean isClause()
        Check is this struct is clause or directive
      • getTerm

        public Term getTerm()
        Description copied from class: Term
        Gets the actual term referred by this Term. if the Term is a bound variable, the method gets the Term linked to the variable
        Specified by:
        getTerm in class Term
      • getArg

        public Struct getArg​(java.lang.String name)
        Gets an argument inside this structure, given its name
        Parameters:
        name - name of the structure
        Returns:
        the argument or null if not found
      • isGreater

        public boolean isGreater​(Term t)
        Test if a term is greater than other
        Specified by:
        isGreater in class Term
      • isCons

        public boolean isCons()
        Overrides:
        isCons in class Term
      • isList

        public boolean isList()
        Description copied from class: Term
        is this term a prolog list?
        Overrides:
        isList in class Term
      • isEmptyList

        public boolean isEmptyList()
        Description copied from class: Term
        is this term a null term?
        Overrides:
        isEmptyList in class Term
      • isEmptySet

        public boolean isEmptySet()
        Overrides:
        isEmptySet in class Term
      • isSet

        public boolean isSet()
        Overrides:
        isSet in class Term
      • isTuple

        public boolean isTuple()
        Overrides:
        isTuple in class Term
      • listHead

        public Term listHead()
        Gets the head of this structure, which is supposed to be a list.

        Gets the head of this structure, which is supposed to be a list. If the callee structure is not a list, throws an UnsupportedOperationException

      • listTail

        public Struct listTail()
        Gets the tail of this structure, which is supposed to be a list.

        Gets the tail of this structure, which is supposed to be a list. If the callee structure is not a list, throws an UnsupportedOperationException

      • listSize

        public int listSize()
        Gets the number of elements of this structure, which is supposed to be a list.

        Gets the number of elements of this structure, which is supposed to be a list. If the callee structure is not a list, throws an UnsupportedOperationException

      • listIterator

        public java.util.Iterator<? extends Term> listIterator()
        Gets an iterator on the elements of this structure, which is supposed to be a list.

        Gets an iterator on the elements of this structure, which is supposed to be a list. If the callee structure is not a list, throws an UnsupportedOperationException

      • unfoldedListIterator

        public java.util.Iterator<? extends Term> unfoldedListIterator()
      • unfoldedTupleIterator

        public java.util.Iterator<? extends Term> unfoldedTupleIterator()
      • unfoldedSetIterator

        public java.util.Iterator<? extends Term> unfoldedSetIterator()
      • listStream

        public java.util.stream.Stream<? extends Term> listStream()
      • unfoldedListStream

        public java.util.stream.Stream<? extends Term> unfoldedListStream()
      • unfoldedTupleStream

        public java.util.stream.Stream<? extends Term> unfoldedTupleStream()
      • unfoldedSetStream

        public java.util.stream.Stream<? extends Term> unfoldedSetStream()
      • append

        public void append​(Term t)
        Appends an element to this structure supposed to be a list
      • free

        public void free()
        dummy method
        Specified by:
        free in class Term
      • getPrimitive

        public PrimitiveInfo getPrimitive()
        Get primitive behaviour associated at structure
      • isPrimitive

        public boolean isPrimitive()
        Check if this term is a primitive struct
      • isFunctorAtomic

        public boolean isFunctorAtomic()
      • toString

        public java.lang.String toString()
        Gets the string representation of this structure

        Specific representations are provided for lists and atoms. Names starting with upper case letter are enclosed in apices.

        Overrides:
        toString in class java.lang.Object
      • iteratedGoalTerm

        public Term iteratedGoalTerm()
        Description copied from class: Term
        The iterated-goal term G of a term T is a term defined recursively as follows:
        • if T unifies with ^(_, Goal) then G is the iterated-goal term of Goal
        • else G is T
        Overrides:
        iteratedGoalTerm in class Term
      • accept

        public <T> T accept​(TermVisitor<T> tv)
        Description copied from class: Term
        Visitor pattern
        Specified by:
        accept in class Term
        Parameters:
        tv - - Visitor
      • getArgs

        public Term[] getArgs()