- java.lang.Object
-
- com.igormaznitsa.prologparser.terms.PrologTerm
-
- All Implemented Interfaces:
Serializable,Comparable<PrologTerm>
- Direct Known Subclasses:
Op,PrologAtom,PrologCompound,PrologNumeric,PrologVar
public abstract class PrologTerm extends Object implements Serializable, Comparable<PrologTerm>
Base class describes a Prolog term- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description PrologTerm(String text, Quotation quotation)PrologTerm(String text, Quotation quotation, int line, int pos)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static StringassertNonEmptyString(String str)intcompareTo(PrologTerm that)static QuotationfindQuotation(String atomText)Find appropriate quotation for text.List<PrologTerm>flatComma(List<PrologTerm> list)Flat content of the term for comma, make sense for structures.intgetArity()Arity of element.PrologTermgetFunctor()Get the functor, make sense of structure and its successors, for primitive returns the same term.intgetLine()Line of the term, first line is 1intgetPos()Position of the term in the line, first position is 1intgetPrecedence()Get precedence of the term.QuotationgetQuotation()Get quotation for the term.StringgetText()Get the term text.abstract TermTypegetType()Get term type.booleanisAnyBlock()Check the term describes '()' or '{}' block.booleanisBlock()Check the term describes '()' block.booleanisCurlyBlock()Check the term describes '{}' block.voidsetLine(int line)voidsetPos(int pos)Stream<PrologTerm>stream()StringtoString()
-
-
-
Method Detail
-
findQuotation
public static Quotation findQuotation(String atomText)
Find appropriate quotation for text.- Parameters:
atomText- text, must not be null- Returns:
- founded quotation
-
flatComma
public List<PrologTerm> flatComma(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 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
-
getType
public abstract TermType getType()
Get term type.- Returns:
- term type, must not be null
-
stream
public 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:
compareToin interfaceComparable<PrologTerm>
-
-