Class OpContainer
java.lang.Object
com.igormaznitsa.prologparser.terms.PrologTerm
com.igormaznitsa.prologparser.terms.PrologCompound
com.igormaznitsa.prologparser.terms.InternalSpecialCompoundTerm
com.igormaznitsa.prologparser.terms.OpContainer
- All Implemented Interfaces:
Serializable, Comparable<PrologTerm>
Container of operators which have same name but differently associative.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate Opprivate Opprivate Opprivate static final longFields inherited from class PrologTerm
quotation, text -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateOpContainer(Op operator) privateOpContainer(String text, Op fz, Op zf, Op zfz) -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdd operator into the container.voidclear()Remove all saved operators.findForArity(int arity) Find operator with arity in the containerfindForType(OpAssoc type) Find operator for its typefindSimilar(boolean hasLeftArg, boolean hasRightArg) Find operator for presented arguments.findSimilar(OpAssoc type) Find operator with similar type.intgetArity()Arity of element.Get operator if it is only one in the containerintGet precedence of the term.getTermAt(int position) Get element for its positiongetType()Get term type.static OpContainerCreate new container based on operator name.static OpContainerbooleanRemove operator from the containerbooleanremoveForType(OpAssoc type) Remove operator for typeintsize()Get current size of the container.toString()Methods inherited from class InternalSpecialCompoundTerm
compareTo, streamMethods inherited from class PrologTerm
assertNonEmptyString, findQuotation, flatComma, getFunctor, getLine, getPos, getQuotation, getText, isAnyBlock, isBlock, isCurlyBlock, setLine, setPos
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
opFZ
-
opZF
-
opZFZ
-
numberAtContainer
private int numberAtContainer
-
-
Constructor Details
-
OpContainer
-
OpContainer
-
-
Method Details
-
make
Create new container based on operator name.- Parameters:
operator- operator which name will be used and which will be added to the new container- Returns:
- generated container with the operator
-
make
-
add
Add operator into the container.- Parameters:
operator- the operator to be added- Returns:
- true if the operator has been added, false if it was impossible because similar operator already presented
- Throws:
IllegalArgumentException- if operator has different name
-
clear
public void clear()Remove all saved operators. -
findForArity
Find operator with arity in the container- Parameters:
arity- arity to be used (1..2)- Returns:
- found operator or null
-
remove
Remove operator from the container- Parameters:
op- operator to be removed- Returns:
- true if operator was removed, false otherwise
- Throws:
IllegalArgumentException- if operator name is not compatible with the container
-
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- Overrides:
getTermAtin classInternalSpecialCompoundTerm- Parameters:
position- zero-based element position- Returns:
- element in position
-
size
public int size()Get current size of the container.- Returns:
- size of the container
-
getIfSingle
Get operator if it is only one in the container- Returns:
- the found only operator, null if there are severe operators
-
findSimilar
Find operator for presented arguments.- Parameters:
hasLeftArg- should have left argumenthasRightArg- should have right argument- Returns:
- operator for needed condition, null if not found
-
findForType
-
findSimilar
-
removeForType
Remove operator for type- Parameters:
type- type of removing operator- Returns:
- true if removed, false if not found
-
getPrecedence
public int getPrecedence()Description copied from class:PrologTermGet precedence of the term.- Overrides:
getPrecedencein classPrologTerm- Returns:
- precedence, must not be negative
-
toString
- Overrides:
toStringin classPrologTerm
-