Class TermFormatter
java.lang.Object
org.projog.core.term.TermFormatter
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanformatTerm(Term t) Returns a string representation of the specifiedTerm.private static Termprivate intgetPriority(Term next) private booleanprivate booleanprivate booleanprivate booleanshouldLeftArgumentBeBracketed(Term next, Term parentInfixTerm, int parentInfixPriority) private booleanshouldRightArgumentBeBracketed(Term next, Term parentInfixTerm, int parentInfixPriority) private voidwrite(Term t, StringBuilder sb) private voidwriteInfixOperator(Term p, StringBuilder sb) private voidwriteList(Term p, StringBuilder sb) private voidprivate voidprivate voidwritePredicate(Term p, StringBuilder sb) private voidwritePrefixOperator(Term p, StringBuilder sb)
-
Field Details
-
operands
-
-
Constructor Details
-
TermFormatter
-
-
Method Details
-
formatTerm
Returns a string representation of the specifiedTerm.This method does take account of current operator declarations - thus an infix operator will be printed out between its arguments. This method represents lists as a comma separated sequence of elements enclosed in square brackets.
For example:
Term structure = Structure.createStructure("+", new IntegerNumber(1), new IntegerNumber(2)); Term list = ListFactory.create(new Term[]{new Atom("a"), Atom("b"), Atom("c")}); System.out.println("Structure.toString(): "+structure.toString()); System.out.println("Write.toString(structure): "+write.toString(structure)); System.out.println("List.toString(): "+list.toString()); System.out.println("Write.toString(list): "+write.toString(list));would print out:Structure.toString(): +(1, 2) Write.toString(structure): 1 + 2 List.toString(): .(a, .(b, .(c, []))) Write.toString(list): [a,b,c]
- Parameters:
t- theTermto represent as a string- Returns:
- a string representation of the specified
Term
-
write
-
writeList
-
getList
-
writePredicate
-
isInfixOperator
-
writeInfixOperator
-
shouldLeftArgumentBeBracketed
-
shouldRightArgumentBeBracketed
-
isPrefixOperator
-
writePrefixOperator
-
isPostfixOperator
-
writePostfixOperator
-
canBePreceededByEqualPriority
-
getPriority
-
writeNonOperatorPredicate
-