Class PrologStruct
java.lang.Object
com.igormaznitsa.prologparser.terms.PrologTerm
com.igormaznitsa.prologparser.terms.PrologCompound
com.igormaznitsa.prologparser.terms.PrologStruct
- All Implemented Interfaces:
Serializable, Comparable<PrologTerm>, Iterable<PrologTerm>
- Direct Known Subclasses:
PrologList
Representation of prolog structure.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final PrologTerm[]static final PrologAtomprotected final PrologTermprivate static final longFields inherited from class PrologTerm
quotation, text -
Constructor Summary
ConstructorsModifierConstructorDescriptionPrologStruct(PrologTerm functor) protectedPrologStruct(PrologTerm functor, int arity) PrologStruct(PrologTerm functor, int line, int pos) protectedPrologStruct(PrologTerm functor, int arity, int line, int pos) PrologStruct(PrologTerm functor, PrologTerm[] elements) PrologStruct(PrologTerm functor, PrologTerm[] elements, int line, int pos) PrologStruct(String text) PrologStruct(String text, int line, int pos) -
Method Summary
Modifier and TypeMethodDescriptionprivate static PrologTermassertFunctor(PrologTerm functor) copyWithAnotherFunctor(PrologTerm newFunctor) Make copy of the structure with replacement of functor.flatComma(List<PrologTerm> list) Flat content of the term for comma, make sense for structures.intgetArity()Arity of element.Get the functor, make sense of structure and its successors, for primitive returns the same term.intGet precedence of the term.getTermAt(int index) Get element for its positiongetType()Get term type.booleanCheck the term describes '()' or '{}' block.booleanisBlock()Check the term describes '()' block.booleanCheck the term describes '{}' block.booleanisEmpty()Check that the structure has elements.iterator()voidsetElementAt(int index, PrologTerm term) Set element for its position.stream()toString()Methods inherited from class PrologTerm
assertNonEmptyString, compareTo, findQuotation, getLine, getPos, getQuotation, getText, setLine, setPosMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
EMPTY_ATOM
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
functor
-
elements
-
-
Constructor Details
-
PrologStruct
-
PrologStruct
-
PrologStruct
-
PrologStruct
-
PrologStruct
-
PrologStruct
-
PrologStruct
-
PrologStruct
-
-
Method Details
-
assertFunctor
-
getType
Description copied from class:PrologTermGet term type.- Specified by:
getTypein classPrologTerm- Returns:
- term type, must not be null
-
getArity
public int getArity()Description copied from class:PrologTermArity of element.- Overrides:
getArityin classPrologTerm- Returns:
- arity of element, make sense for compound terms, for primitive terms is 1
-
getTermAt
Description copied from class:PrologCompoundGet element for its position- Specified by:
getTermAtin classPrologCompound- Parameters:
index- zero-based element position- Returns:
- element in position
-
setElementAt
Set element for its position.- Parameters:
index- zero based indexterm- term to set to position- Throws:
ArrayIndexOutOfBoundsException- if wrong index
-
getFunctor
Description copied from class:PrologTermGet the functor, make sense of structure and its successors, for primitive returns the same term.- Overrides:
getFunctorin classPrologTerm- Returns:
- functor for structure or the same term
-
getPrecedence
public int getPrecedence()Description copied from class:PrologTermGet precedence of the term.- Overrides:
getPrecedencein classPrologTerm- Returns:
- precedence, must not be negative
-
copyWithAnotherFunctor
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:PrologTermCheck the term describes '()' or '{}' block.- Overrides:
isAnyBlockin classPrologTerm- Returns:
- true if the term is structure describes any kind of supported block
-
isCurlyBlock
public boolean isCurlyBlock()Description copied from class:PrologTermCheck the term describes '{}' block.- Overrides:
isCurlyBlockin classPrologTerm- Returns:
- true if the term is structure with '{}' as functor
-
isBlock
public boolean isBlock()Description copied from class:PrologTermCheck the term describes '()' block.- Overrides:
isBlockin classPrologTerm- Returns:
- true if the term is structure with '()' as functor
-
flatComma
Description copied from class:PrologTermFlat content of the term for comma, make sense for structures.- Overrides:
flatCommain classPrologTerm- Parameters:
list- list to be filled by comma separated terms- Returns:
- the same list
-
toString
- Overrides:
toStringin classPrologTerm
-
isEmpty
public boolean isEmpty()Check that the structure has elements.- Returns:
- true if there is not elements, false otherwise
-
stream
- Overrides:
streamin classPrologTerm
-
iterator
- Specified by:
iteratorin interfaceIterable<PrologTerm>
-