FileDocCategorySizeDatePackage
InputsAndOutputs.javaAPI DocGlassfish v2 API7279Fri May 04 22:25:20 BST 2007com.sun.enterprise.cli.framework

InputsAndOutputs

public class InputsAndOutputs extends Object
A class which stores the inputs and outputs for the asadmin-specific information.

Fields Summary
private static InputsAndOutputs
sIO
private IUserInput
userInput
private IUserOutput
userOutputImpl
private IErrorOutput
errorOutputImpl
Constructors Summary
private InputsAndOutputs()
Default constructor.


                 
     
    
    
Methods Summary
public IErrorOutputgetErrorOutput()
Returns the errorOutputImpl class object.

        return this.errorOutputImpl;
    
public static synchronized com.sun.enterprise.cli.framework.InputsAndOutputsgetInstance()
Singleton method that returns an instance of InputsAndOutputs

	if (sIO == null)
	{
	    sIO = new InputsAndOutputs();
	}
	return sIO;
    
public IUserInputgetUserInput()
Returns the userInput object that is set in InputsAndOutputs.

        return this.userInput;
    
public IUserOutputgetUserOutput()
Returns the userOutputImpl class object.

	return this.userOutputImpl;
    
public voidsetErrorOutput(java.io.OutputStream os)
Creates and sets the errorOutputImpl class with the given OutputStream object.

param
os is the OutputStream object to be set.

        this.errorOutputImpl.close();
        this.errorOutputImpl = new ErrorOutputImpl( os, false );
    
public voidsetErrorOutputFile(java.lang.String fileName)
Set the output file name and force new output to this file immediately. Any existing output will be flushed and closed.

param
fileName is file in the file system to be set.
throws
IOException

        FileOutputStream errorOutputFile = new FileOutputStream( fileName );
        this.errorOutputImpl.close();
        this.errorOutputImpl = new ErrorOutputImpl( errorOutputFile, true );
    
public static voidsetInstance(com.sun.enterprise.cli.framework.InputsAndOutputs iao)
Singleton method that sets the instance of InputsAndOutputs

        if (iao == null) {
            if (sIO!=null) {
                try {
                    sIO.userOutputImpl.close();
                    sIO.userInput.close();
                }
                catch (Exception e){
                    e.printStackTrace();
                }
            }
            sIO = new InputsAndOutputs();
            return;
        }
        if (iao != null && sIO != iao)
            sIO = iao;
    
public voidsetUserInput(IUserInput userInput)
Sets the userInput object in the InputsAndOutputs.

param
userInput is the UserInput object to be set.
throws
IOException

        this.userInput.close();
        this.userInput = userInput;
    
public voidsetUserInput(java.io.InputStream is)
Sets the InputStream object in the InputsAndOutputs.

param
userInput is the UserInput object to be set.
throws
IOException

        userInput.close();
        this.userInput = new UserInput(is);
    
public voidsetUserInput(java.io.InputStream is, java.lang.String sEncoding)
Sets the InputStream object in the InputsAndOutputs with specified character set.

param
userInput is the UserInput object to be set.
throws
IOException

        userInput.close();
        this.userInput = new UserInput(is);
        this.userInput.setEncoding(sEncoding);
    
public voidsetUserInputFile(java.lang.String fileName)
Set the input to a file name

param
fileName is file in the file system to be set.
throws
IOException

        final FileInputStream userInputFile = new FileInputStream( fileName );
        setUserInput(userInputFile);
    
public voidsetUserInputFile(java.lang.String fileName, java.lang.String sEncoding)
Set the input to a file name with specified encoding

param
fileName is file in the file system to be set.
throws
IOException

        final FileInputStream userInputFile = new FileInputStream( fileName );
        setUserInput(userInputFile, sEncoding);
    
public voidsetUserOutput(java.io.OutputStream os)
Creates and sets the userOutputImpl class with the given OutputStream object.

param
os is the OutputStream object to be set.

	this.userOutputImpl.close();
	this.userOutputImpl = new UserOutputImpl( os, false );
    
public voidsetUserOutputFile(java.lang.String fileName)
Set the output file name and force new output to this file immediately. Any existing output will be flushed and closed.

param
fileName is file in the file system to be set.
throws
IOException

        FileOutputStream userOutputFile = new FileOutputStream( fileName );
        this.userOutputImpl.close();
        this.userOutputImpl = new UserOutputImpl( userOutputFile, true );