FileDocCategorySizeDatePackage
P4HandlerAdapter.javaAPI DocApache Ant 1.704120Wed Dec 13 06:16:22 GMT 2006org.apache.tools.ant.taskdefs.optional.perforce

P4HandlerAdapter

public abstract class P4HandlerAdapter extends Object implements P4Handler
base class to manage streams around the execution of the Perforce command line client

Fields Summary
String
p4input
private org.apache.tools.ant.taskdefs.PumpStreamHandler
myHandler
OutputStream
os
InputStream
is
InputStream
es
Constructors Summary
Methods Summary
public abstract voidprocess(java.lang.String line)
subclasses of P4HandlerAdapter must implement this routine processing of one line of stdout or of stderr

param
line line of stdout or stderr to process

public voidsetOutput(java.lang.String p4Input)
set any data to be written to P4's stdin

param
p4Input the text to write to P4's stdin

    // CheckStyle:VisibilityModifier ON
                             
        
        this.p4input = p4Input;
    
public voidsetProcessErrorStream(java.io.InputStream is)
connects the handler to the stderr of the Perforce process

param
is stderr coming from Perforce
throws
IOException under unknown circumstances

        this.es = is;
    
public voidsetProcessInputStream(java.io.OutputStream os)
connects the handler to the input stream into Perforce used indirectly by tasks requiring to send specific standard input such as p4label, p4change

param
os the stream bringing input to the p4 executable
throws
IOException under unknown circumstances

        this.os = os;
    
public voidsetProcessOutputStream(java.io.InputStream is)
connects the handler to the stdout of the Perforce process

param
is stdout coming from Perforce
throws
IOException under unknown circumstances

        this.is = is;
    
public voidstart()
this routine gets called by the execute routine of the Execute class it connects the PumpStreamHandler to the input/output/error streams of the process.

throws
BuildException if there is a error.
see
org.apache.tools.ant.taskdefs.Execute#execute

        if (p4input != null && p4input.length() > 0) {
            myHandler = new PumpStreamHandler(new P4OutputStream(this), new P4OutputStream(this),
                new ByteArrayInputStream(p4input.getBytes()));
        } else {
            myHandler = new PumpStreamHandler(new P4OutputStream(this), new P4OutputStream(this));
        }
        myHandler.setProcessInputStream(os);
        myHandler.setProcessErrorStream(es);
        myHandler.setProcessOutputStream(is);
        myHandler.start();
    
public voidstop()
stops the processing of streams called from P4Base#execP4Command(String command, P4Handler handler)

see
P4Base#execP4Command(String, P4Handler)

        myHandler.stop();