FileDocCategorySizeDatePackage
NullConsumer.javaAPI DocExample2264Tue Feb 04 21:46:42 GMT 1997dcj.util.Bandwidth

ContentConsumer

public class ContentConsumer extends Object

Fields Summary
protected ContentProducer
source
protected ContentConsumer
dest
protected DataMonitor
monitor
Constructors Summary
public ContentConsumer(InputStream src)


     
    source = new ContentProducer(src);
  
public ContentConsumer(ContentProducer src)

    source = src;
  
public ContentConsumer(OutputStream dst)

    dest = new ContentConsumer(dst);
  
public ContentConsumer(ContentConsumer dst)

    dest = dst;
  
Methods Summary
public booleanconsume(byte[] data)

    boolean success;
    success = preConsume(data);
    if (success)
      success = doConsume(data);
    if (success)
      success = postConsume(data);

    return success;
  
public booleanconsume()

    boolean success = false;
    if (source != null) {
      byte[] data = source.produce();
//      byte[] data = null;
      while (data != null) {
        success = consume(data);
        data = source.produce();
      }
    }

    return success;
  
protected booleandoConsume(byte[] data)

    boolean success = false;
    if (dest != null) {
      success = dest.consume(data);
    }

    return true;
  
protected booleanpostConsume(byte[] data)

    monitor.addSample(data.length);
    return true;
  
protected booleanpreConsume(byte[] data)

    if (monitor.getStart() == null)
      monitor.start();

    return true;
  
public voidsetDest(dcj.util.Bandwidth.ContentConsumer c)

    dest = c;
  
public voidsetDest(java.io.OutputStream s)

    dest = new ContentConsumer(s);
  
public voidsetSource(ContentProducer p)

    source = p;
  
public voidsetSource(java.io.InputStream s)

    source = new ContentProducer(s);