CS 1705 Library

net.sf.webcat
Class SystemIOUtilities

java.lang.Object
  extended by net.sf.webcat.SystemIOUtilities

public class SystemIOUtilities
extends Object

A utility class that provides functions for replacing System I/O streams with helpful alternative implementations to make some testing jobs easier. This class is really for use by infrastructure and support code, and students should never need to use it directly.

Since this class provides only static methods, clients should not create an instance. As a result, it provides no public constructors.

Version:
$Id: SystemIOUtilities.java,v 1.2 2007/09/15 02:04:49 stedwar2 Exp $
Author:
Stephen Edwards

Method Summary
static void assertNotOnServer()
          Checks to see if the calling program is running under the Apache Tomcat servlet container.
static PrintStreamWithHistory err()
          Get a "wrapped" version of System.err that provides history recording functions.
static boolean isOnServer()
          Checks to see if the calling program is running under the Apache Tomcat servlet container.
static PrintStreamWithHistory out()
          Get a "wrapped" version of System.out that provides history recording functions.
static void replaceSystemInContents(String contents)
          Replace System.in with the contents of the given string.
static void restoreSystemErr()
          "Unwrap" System.err by removing any history recording wrapper, and return it to its original state.
static void restoreSystemIn()
          Restore System.in to its original value.
static void restoreSystemOut()
          "Unwrap" System.out by removing any history recording wrapper, and return it to its original state.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

out

public static PrintStreamWithHistory out()
Get a "wrapped" version of System.out that provides history recording functions.

Returns:
a version of System.out that provides history features

restoreSystemOut

public static void restoreSystemOut()
"Unwrap" System.out by removing any history recording wrapper, and return it to its original state.


err

public static PrintStreamWithHistory err()
Get a "wrapped" version of System.err that provides history recording functions.

Returns:
a version of System.err that provides history features

restoreSystemErr

public static void restoreSystemErr()
"Unwrap" System.err by removing any history recording wrapper, and return it to its original state.


replaceSystemInContents

public static void replaceSystemInContents(String contents)
Replace System.in with the contents of the given string.

Parameters:
contents - The content to read from

restoreSystemIn

public static void restoreSystemIn()
Restore System.in to its original value.


isOnServer

public static boolean isOnServer()
Checks to see if the calling program is running under the Apache Tomcat servlet container.

Returns:
True if running as a servlet

assertNotOnServer

public static void assertNotOnServer()
Checks to see if the calling program is running under the Apache Tomcat servlet container. When running in such an environment, some behaviors should be avoided. For example, it is not appropriate to modify globally shared resources like those in the class System.


Last updated: Wed, Apr 1, 2009 • 12:29 AM EDT

Copyright © 2009 Virginia Tech.