Jalog 1.3


io.github.JalogTeam.jalog
Class Jalog.Output

java.lang.Object
  extended by io.github.JalogTeam.jalog.Jalog.Output
Enclosing class:
Jalog

public static class Jalog.Output

Jalog uses Output to write whatever is specified in Prolog write calls. Output may be redirected to a nonstandard destination or captured for use by the calling program.

In order to write to a nonstandard destination, two things are needed. First, a new class is derived from Jalog.Output. The function print must be overridden so that output is directed to the intended destination. In addition, functions println and nl can (but need not) be overridden. For example, the following declaration writes to System.Out with decorations:

  public static class TestOutput extends Jalog.Output {
    public void print(String s) {
      System.out.print("|" + s);
    }
  }

Secondly, an instance of the new class is introduced to Jalog with setOut before any Jalog code is called. For example, continuing the above example, the following instructions can be used:

    Jalog myJalog = new Jalog();
    myJalog.setOut(new TestOutput());

In addition, error messages from the Jalog system can be redirected with the same or another Jalog.Output object. The procedure is as above except setErr is used instead of setOut, for example:

    myJalog.setErr(new TestOutput());

 

Method Summary
 void nl()

NOTE: For internal use of the Jalog system. Not to be called by a application program. This is provided to redirect output.

Writes a line break to desired destination.

 void print(String s)

NOTE: For internal use of the Jalog system. Not to be called by a application program. This is provided to redirect output.

Writes to desired destination.

 void println(String s)

NOTE: For internal use of the Jalog system. Not to be called by a application program. This is provided to redirect output.

Writes to desired destination, with appended line break.

 
Method Detail

nl

public void nl()
Writes a line break to desired destination.

print

public void print(String s)
Writes to desired destination.

Parameters:
s - the string to be written.

println

public void println(String s)
Writes to desired destination, with appended line break.

Parameters:
s - the string to be written.

Authors: Mikko Levanto, Ari Okkonen