org.fraid.io
Class FraidIO

java.lang.Object
  extended by org.fraid.io.FraidIO

public class FraidIO
extends java.lang.Object

This is the FrAid IO system. You can redirect them usng setOutputStream, log or unlog them (even at run time).


Field Summary
static FraidPrintStream err
          Describe variable err here.
static FraidPrintStream info
          Info stream.
static FraidPrintStream log
          The log stream.
static java.io.OutputStream nullOutput
          Just like the null stream in Unix.
static FraidPrintStream out
          Standard output.
static FraidPrintStream prompt
          The prompt is handled by a separate stream to allow seamless logging and consoleless execution.
 
Constructor Summary
FraidIO()
           
 
Method Summary
static void closeAllOutputStreams()
          Closes all output streams.
static java.io.Reader logReader(java.io.Reader aReader)
          Log whatever goes through a Reader.
static void logStream(FraidPrintStream aStream)
          "Tees" a stream and sends a copy of it the log.
static void logTeeReader(TeeReader aTee)
          After a Reader is being "teed" for logging and stopped this starts the logging again.
static void printPrompt(java.io.PrintStream aOutput)
          Prints the next prompt.
static void restoreOutputStreams()
          Restores all output streams.
static void setLogFileStream(java.lang.String aFileName)
          Sets the logFileName.
static java.io.OutputStream setOutputStream(FraidPrintStream aFraidStream, java.io.OutputStream aNewOutput)
          Redirects a FrAid output stream.
static void unlogStream(FraidPrintStream aStream)
          If a stream was logged, closses its tee to the log.
static void unlogTeeReader(TeeReader aTee)
          After a Reader is being "teed" for logging, this stops the logging.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nullOutput

public static java.io.OutputStream nullOutput
Just like the null stream in Unix. Redirect to this stream if you want to discard some stream.


out

public static FraidPrintStream out
Standard output. Use for FrAid output, for the other stuff use the info stream. Default is System.out.

See Also:
info

err

public static FraidPrintStream err
Describe variable err here. Default is System.out.


info

public static FraidPrintStream info
Info stream. Use when not printing output of a function or error info. Default is System.out.


prompt

public static FraidPrintStream prompt
The prompt is handled by a separate stream to allow seamless logging and consoleless execution. Default is System.out.


log

public static FraidPrintStream log
The log stream. You can write explicitly to it if you do not want something to appear in the other streams. Otherwise just run logStream on the particular stream you want loged. Default is the fraid.log file.

Constructor Detail

FraidIO

public FraidIO()
Method Detail

printPrompt

public static void printPrompt(java.io.PrintStream aOutput)
Prints the next prompt.


setLogFileStream

public static void setLogFileStream(java.lang.String aFileName)
Sets the logFileName.

Parameters:
aFileName - a String value

setOutputStream

public static java.io.OutputStream setOutputStream(FraidPrintStream aFraidStream,
                                                   java.io.OutputStream aNewOutput)
Redirects a FrAid output stream. If the stream was logged it will keep doing it.

Parameters:
aFraidStream - which FrAid stream,
aNewOutput - to go where.
Returns:
the old stream.

logStream

public static void logStream(FraidPrintStream aStream)
"Tees" a stream and sends a copy of it the log.

Parameters:
aStream - the Fraid stream to log.

unlogStream

public static void unlogStream(FraidPrintStream aStream)
If a stream was logged, closses its tee to the log.

Parameters:
aStream - the Fraid stream to disconect from logging.

logReader

public static java.io.Reader logReader(java.io.Reader aReader)
Log whatever goes through a Reader. Do it before using the Reader and if you need to unlog it later use unlogTeeReader. If you plan on logging a Reader eventhough not from the begining call this method and immediately after call unlogTeeReader. When you actually need to log call logTeeReader and so on.

Parameters:
aReader - the Reader to log.
Returns:
use this instead of the original Reader you passed.

unlogTeeReader

public static void unlogTeeReader(TeeReader aTee)
After a Reader is being "teed" for logging, this stops the logging.

Parameters:
aTee - a TeeReader value

logTeeReader

public static void logTeeReader(TeeReader aTee)
After a Reader is being "teed" for logging and stopped this starts the logging again.

Parameters:
aTee - a TeeReader value

closeAllOutputStreams

public static void closeAllOutputStreams()
Closes all output streams.


restoreOutputStreams

public static void restoreOutputStreams()
Restores all output streams.



Fraid (system and language). (C) 2003-2007 Ivaylo Iliev
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.