//
// NaccioNetworkOutputStream.pfi
//
helper
import java.io.*;
import naccio.library.Check;
public class NaccioNetworkOutputStream extends java.io.FilterOutputStream {
// This stream is constructed based on the OutputStream passed back by
// a Socket object. All normal OutputStream methods get passed along
// to the original OutputStream unless overriden here. The member
// variable "out" is the original OutputStream.
RNetConnection rnc;
// Default constructor overloaded to keep anyone from calling it.
private NaccioNetworkOutputStream(OutputStream os) {
super(os);
NCheck.fatalViolation ("Network Connection resource must be specified when creatting a network input stream.");
}
// This is the constructor to use.
public NaccioNetworkOutputStream(OutputStream os, RNetConnection r) {
super (os);
rnc = r;
util.Assert.assert (r != null);
// System.err.println ("Create nnos!");
// util.Assert.showStack ();
}
//Overloaded methods:
public void write (int b) throws IOException {
// System.err.println ("NNOS write: 1");
RNetwork.preSendConnection (rnc, 1);
super.write (b);
RNetwork.postSendConnection (rnc, 1);
}
public void write (byte b[]) throws IOException {
// System.err.println ("NNOS write: " + b.length);
RNetwork.preSendConnection (rnc, b.length);
super.write (b);
RNetwork.postSendConnection (rnc, b.length);
}
public void write(byte b[], int off, int len) throws IOException {
RNetwork.preSendConnection (rnc, len);
super.write (b, off, len);
RNetwork.postSendConnection (rnc, len);
}
}
Naccio Home Page
University of Virginia, Computer Science