Class PrologTerm

    • Field Detail

      • quotation

        protected final Quotation quotation
      • text

        protected final java.lang.String text
      • line

        private int line
      • pos

        private int pos
    • Constructor Detail

      • PrologTerm

        public PrologTerm​(java.lang.String text,
                          Quotation quotation)
      • PrologTerm

        public PrologTerm​(java.lang.String text,
                          Quotation quotation,
                          int line,
                          int pos)
    • Method Detail

      • findQuotation

        public static Quotation findQuotation​(java.lang.String atomText)
        Find appropriate quotation for text.
        Parameters:
        atomText - text, must not be null
        Returns:
        founded quotation
      • assertNonEmptyString

        protected static java.lang.String assertNonEmptyString​(java.lang.String str)
      • flatComma

        public java.util.List<PrologTerm> flatComma​(java.util.List<PrologTerm> list)
        Flat content of the term for comma, make sense for structures.
        Parameters:
        list - list to be filled by comma separated terms
        Returns:
        the same list
      • getArity

        public int getArity()
        Arity of element.
        Returns:
        arity of element, make sense for compound terms, for primitive terms is 1
      • isAnyBlock

        public boolean isAnyBlock()
        Check the term describes '()' or '{}' block.
        Returns:
        true if the term is structure describes any kind of supported block
        Since:
        2.0.1
      • isBlock

        public boolean isBlock()
        Check the term describes '()' block.
        Returns:
        true if the term is structure with '()' as functor
      • isCurlyBlock

        public boolean isCurlyBlock()
        Check the term describes '{}' block.
        Returns:
        true if the term is structure with '{}' as functor
      • getQuotation

        public Quotation getQuotation()
        Get quotation for the term.
        Returns:
        the quotation for the term, must not be null
      • getPos

        public final int getPos()
        Position of the term in the line, first position is 1
        Returns:
        position in line or -1 if unknown
      • setPos

        public final void setPos​(int pos)
      • getLine

        public final int getLine()
        Line of the term, first line is 1
        Returns:
        line or -1 if unknown
      • setLine

        public final void setLine​(int line)
      • getText

        public java.lang.String getText()
        Get the term text.
        Returns:
        the term text, must not be null
      • getPrecedence

        public int getPrecedence()
        Get precedence of the term.
        Returns:
        precedence, must not be negative
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getType

        public abstract TermType getType()
        Get term type.
        Returns:
        term type, must not be null
      • stream

        public java.util.stream.Stream<PrologTerm> stream()
      • getFunctor

        public PrologTerm getFunctor()
        Get the functor, make sense of structure and its successors, for primitive returns the same term.
        Returns:
        functor for structure or the same term
      • compareTo

        public int compareTo​(PrologTerm that)
        Specified by:
        compareTo in interface java.lang.Comparable<PrologTerm>