Class Writef
- java.lang.Object
-
- org.projog.core.predicate.AbstractSingleResultPredicate
-
- org.projog.core.predicate.builtin.io.Writef
-
- All Implemented Interfaces:
KnowledgeBaseConsumer,PredicateFactory
public final class Writef extends AbstractSingleResultPredicate
writef(X,Y)- writes formatted text to the output stream.The first argument is an atom representing the text to be output. The text can contain special character sequences which specify formatting and substitution rules.
Supported special character sequences are:
Sequence Action \n Output a 'new line' character (ASCII code 10). \l Same as \n.\r Output a 'carriage return' character (ASCII code 13). \t Output a tab character (ASCII code 9). \\ Output the \character.\% Output the %character.\\uNNNN Output the unicode character represented by the hex digits NNNN. %t Output the next term - in same format as write/1.%w Same as \t.%q Same as \t.%p Same as \t.%d Output the next term - in same format as write_canonical/1.%f Ignored (only included to support compatibility with other Prologs). %s Output the elements contained in the list represented by the next term. %n Output the character code of the next term. %r Write the next term N times, where N is the value of the second term. %Nc Write the next term centered in N columns. %Nl Write the next term left-aligned in N columns. %Nr Write the next term right-aligned in N columns. writef(X)produces the same results aswritef(X, []).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classWritef.Formatter
-
Constructor Summary
Constructors Constructor Description Writef()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.Stringalign(Writef.Formatter f, Term t)private java.lang.Stringconcat(Writef.Formatter f, Term t)protected booleanevaluate(Term atom)protected booleanevaluate(Term atom, Term list)private java.lang.StringBuilderformat(java.lang.String text, java.util.List<Term> args)private java.lang.StringgetWhitespace(int diff)private booleanisNumber(int c)private intparseNumber(Writef.Formatter f)private voidparsePercentEscapeSequence(Writef.Formatter f)private voidparseSlashEscapeSequence(Writef.Formatter f)private intparseUnicode(Writef.Formatter f)private voidprint(java.lang.StringBuilder sb)private java.lang.Stringrepeat(java.lang.String text, long timesToRepeat)-
Methods inherited from class org.projog.core.predicate.AbstractSingleResultPredicate
evaluate, evaluate, evaluate, evaluate, getArithmeticOperators, getFileHandles, getKnowledgeBase, getOperands, getPredicate, getPredicates, getProjogListeners, getSpyPoints, getTermFormatter, init, isRetryable, setKnowledgeBase
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.projog.core.predicate.PredicateFactory
isAlwaysCutOnBacktrack
-
-
-
-
Method Detail
-
evaluate
protected boolean evaluate(Term atom)
- Overrides:
evaluatein classAbstractSingleResultPredicate
-
evaluate
protected boolean evaluate(Term atom, Term list)
- Overrides:
evaluatein classAbstractSingleResultPredicate
-
format
private java.lang.StringBuilder format(java.lang.String text, java.util.List<Term> args)
-
parsePercentEscapeSequence
private void parsePercentEscapeSequence(Writef.Formatter f)
-
repeat
private java.lang.String repeat(java.lang.String text, long timesToRepeat)
-
concat
private java.lang.String concat(Writef.Formatter f, Term t)
-
align
private java.lang.String align(Writef.Formatter f, Term t)
-
getWhitespace
private java.lang.String getWhitespace(int diff)
-
parseNumber
private int parseNumber(Writef.Formatter f)
-
parseSlashEscapeSequence
private void parseSlashEscapeSequence(Writef.Formatter f)
-
parseUnicode
private int parseUnicode(Writef.Formatter f)
-
isNumber
private boolean isNumber(int c)
-
print
private void print(java.lang.StringBuilder sb)
-
-