- java.lang.Object
-
- org.logicng.formulas.printer.FormulaStringRepresentation
-
- Direct Known Subclasses:
DefaultStringRepresentation,LatexStringRepresentation,UTF8StringRepresentation
public abstract class FormulaStringRepresentation extends Object
Super class for a formula string representation.- Since:
- 1.0
- Version:
- 2.0.0
-
-
Constructor Summary
Constructors Constructor Description FormulaStringRepresentation()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Stringand()Returns the string representation of and.protected StringbinaryOperator(BinaryOperator operator, String opString)Returns the string representation of a binary operator.protected Stringbracket(Formula formula)Returns a bracketed string version of a given formula.protected abstract Stringequivalence()Returns the string representation of an equivalence.protected abstract Stringfalsum()Returns the string representation of false.protected abstract Stringimplication()Returns the string representation of an implication.protected abstract Stringlbr()Returns the string representation of a left bracket.protected StringnaryOperator(NAryOperator operator, String opString)Returns the string representation of an n-ary operator.protected abstract Stringnegation()Returns the string representation of not.protected abstract Stringor()Returns the string representation of or.protected abstract StringpbAdd()Returns the string representation of a pseudo-Boolean addition.protected abstract StringpbComparator(CType comparator)Returns the string representation of a pseudo-Boolean comparator.protected StringpbLhs(Literal[] operands, int[] coefficients)Returns the string representation of the left-hand side of a pseudo-Boolean constraint.protected abstract StringpbMul()Returns the string representation of a pseudo-Boolean multiplication.protected abstract Stringrbr()Returns the string representation of right bracket.protected StringtoInnerString(Formula formula)Returns the string representation of the given formula.StringtoString(Formula formula)Returns the string representation of the given formula.protected abstract Stringverum()Returns the string representation of true.
-
-
-
Method Detail
-
toString
public String toString(Formula formula)
Returns the string representation of the given formula.In order to add a prefix/suffix or do one-time calculations on the formula it is recommended to overwrite this method in subclasses.
- Parameters:
formula- the formula- Returns:
- the string representation of the formula
-
toInnerString
protected String toInnerString(Formula formula)
Returns the string representation of the given formula.This method is used for recursive calls in order to format the sub-formulas.
- Parameters:
formula- the formula- Returns:
- the string representation of the formula
-
bracket
protected String bracket(Formula formula)
Returns a bracketed string version of a given formula.- Parameters:
formula- the formula- Returns:
"(" + formula.toString() + ")"
-
binaryOperator
protected String binaryOperator(BinaryOperator operator, String opString)
Returns the string representation of a binary operator.- Parameters:
operator- the binary operatoropString- the operator string- Returns:
- the string representation
-
naryOperator
protected String naryOperator(NAryOperator operator, String opString)
Returns the string representation of an n-ary operator.- Parameters:
operator- the n-ary operatoropString- the operator string- Returns:
- the string representation
-
pbLhs
protected String pbLhs(Literal[] operands, int[] coefficients)
Returns the string representation of the left-hand side of a pseudo-Boolean constraint.- Parameters:
operands- the literals of the constraintcoefficients- the coefficients of the constraint- Returns:
- the string representation
-
falsum
protected abstract String falsum()
Returns the string representation of false.- Returns:
- the string representation of false
-
verum
protected abstract String verum()
Returns the string representation of true.- Returns:
- the string representation of true
-
negation
protected abstract String negation()
Returns the string representation of not.- Returns:
- the string representation of not
-
implication
protected abstract String implication()
Returns the string representation of an implication.- Returns:
- the string representation of an implication
-
equivalence
protected abstract String equivalence()
Returns the string representation of an equivalence.- Returns:
- the string representation of an equivalence
-
and
protected abstract String and()
Returns the string representation of and.- Returns:
- the string representation of and
-
or
protected abstract String or()
Returns the string representation of or.- Returns:
- the string representation of or
-
pbComparator
protected abstract String pbComparator(CType comparator)
Returns the string representation of a pseudo-Boolean comparator.- Parameters:
comparator- the pseudo-Boolean comparator- Returns:
- the string representation of a pseudo-Boolean comparator
-
pbMul
protected abstract String pbMul()
Returns the string representation of a pseudo-Boolean multiplication.- Returns:
- the string representation of a pseudo-Boolean multiplication
-
pbAdd
protected abstract String pbAdd()
Returns the string representation of a pseudo-Boolean addition.- Returns:
- the string representation of a pseudo-Boolean addition
-
lbr
protected abstract String lbr()
Returns the string representation of a left bracket.- Returns:
- the string representation of a left bracket
-
rbr
protected abstract String rbr()
Returns the string representation of right bracket.- Returns:
- the string representation of right bracket
-
-