org.sonatype.gshell.io
Class StreamJack

java.lang.Object
  extended by org.sonatype.gshell.io.StreamJack

public class StreamJack
extends java.lang.Object

Hijacks the systems standard input, output and error streams on a per-thread basis and redirects to given streams.

Since:
2.0
Author:
Jason Dillon

Constructor Summary
StreamJack()
           
 
Method Summary
static StreamSet current()
          Returns the currently registered streams.
static void deregister()
          Re-register streams for the current thread, and restore the previous if any.
static void install()
          Install the hijacker.
static void install(java.io.InputStream in, java.io.PrintStream out)
          Install the hijacker and register combined streams for the current thread.
static void install(java.io.InputStream in, java.io.PrintStream out, java.io.PrintStream err)
          Install the hijacker and register streams for the current thread.
static void install(StreamSet set)
          Install the hijacker and register streams for the current thread.
static boolean isInstalled()
          Check if the hijacker has been installed.
static boolean isRegistered()
          Check if there are streams registered for the current thread.
static void maybeInstall()
           
static void maybeInstall(StreamSet set)
           
static void register(java.io.InputStream in, java.io.PrintStream out)
          Register combined streams for the current thread.
static void register(java.io.InputStream in, java.io.PrintStream out, java.io.PrintStream err)
          Register streams for the current thread.
static void register(StreamSet set)
          Register streams for the current thread.
static void restore()
          Restores the original System streams from StreamSet.SYSTEM and resets the hijacker state to un-installed.
static void restore(StreamSet streams)
          Restores the System streams to the given pair and resets the hijacker state to un-installed.
static void uninstall()
          Uninstall the hijacker.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamJack

public StreamJack()
Method Detail

isInstalled

public static boolean isInstalled()
Check if the hijacker has been installed.


install

public static void install()
Install the hijacker.


install

public static void install(java.io.InputStream in,
                           java.io.PrintStream out,
                           java.io.PrintStream err)
Install the hijacker and register streams for the current thread.


install

public static void install(java.io.InputStream in,
                           java.io.PrintStream out)
Install the hijacker and register combined streams for the current thread.


install

public static void install(StreamSet set)
Install the hijacker and register streams for the current thread.


maybeInstall

public static void maybeInstall()

maybeInstall

public static void maybeInstall(StreamSet set)

uninstall

public static void uninstall()
Uninstall the hijacker.


isRegistered

public static boolean isRegistered()
Check if there are streams registered for the current thread.


register

public static void register(java.io.InputStream in,
                            java.io.PrintStream out,
                            java.io.PrintStream err)
Register streams for the current thread.


register

public static void register(java.io.InputStream in,
                            java.io.PrintStream out)
Register combined streams for the current thread.


register

public static void register(StreamSet set)
Register streams for the current thread.


deregister

public static void deregister()
Re-register streams for the current thread, and restore the previous if any.


current

public static StreamSet current()
Returns the currently registered streams.


restore

public static void restore(StreamSet streams)
Restores the System streams to the given pair and resets the hijacker state to un-installed.


restore

public static void restore()
Restores the original System streams from StreamSet.SYSTEM and resets the hijacker state to un-installed.



Copyright © 2008-2009. All Rights Reserved.