FileDocCategorySizeDatePackage
ContentFilter.javaAPI DocExample2312Tue Feb 04 22:40:08 GMT 1997dcj.util.Bandwidth

ContentFilter

public class ContentFilter extends Object

Fields Summary
protected ContentProducer
out
protected ContentConsumer
in
protected DataMonitor
monitor
Constructors Summary
public ContentFilter(InputStream src, OutputStream dst)


       
    in = new ContentProducer(src);
    out = new ContentConsumer(dst);
    buildFilter();
  
public ContentFilter(ContentProducer p, ContentConsumer c)

    in = c;
    out = p;
    buildFilter();
  
Methods Summary
protected voidbuildFilter()

    if (in != null && out != null) {
      in.setSource(out);
      out.setDest(in);
    }
  
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;
  
public booleanconsume(byte[] data)

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

    return success;
  
protected booleandoConsume(byte[] data)

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

    return true;
  
public ContentConsumergetInput()

 return in; 
public ContentProducergetOutput()

 return out; 
protected booleanpostConsume(byte[] data)

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

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

    return true;
  
public voidsetInput(ContentConsumer c)

    in = c;
    buildFilter();
  
public voidsetOutput(ContentProducer p)

    out = p;
    buildFilter();