things.thinger.io
Class EchoStreamSource

java.lang.Object
  extended by things.thinger.io.EchoStreamSource
All Implemented Interfaces:
StreamSource

public class EchoStreamSource
extends java.lang.Object
implements StreamSource

An echoing stream source. Everything read will be copied to the given output stream.

Version:
1.0

Version History

EPG - Initial - 20 FEB 05
 
Author:
Erich P. Gatejen

Constructor Summary
EchoStreamSource()
           
 
Method Summary
 boolean hasMore()
          Does the source have more to get?
 int next()
          Get the next character.
 EchoStreamSource use(java.io.InputStream source, java.io.OutputStream echoStream)
          Use this object but with another stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EchoStreamSource

public EchoStreamSource()
Method Detail

use

public EchoStreamSource use(java.io.InputStream source,
                            java.io.OutputStream echoStream)
                     throws java.lang.Exception
Use this object but with another stream. I'm being particularly naughty by letting a method change the streams in-flight. This will make data processing pipelines a bit more interesting, but I probably can be convinced this is a bad idea.

Parameters:
source - The input stream source.
Returns:
itself
Throws:
java.lang.Exception

next

public int next()
         throws java.lang.Exception
Get the next character. It'll throw an EOFException if there is nothing left.

Specified by:
next in interface StreamSource
Returns:
the next integer (always fits in a byte)
Throws:
java.lang.Exception

hasMore

public boolean hasMore()
                throws java.lang.Exception
Does the source have more to get?

Specified by:
hasMore in interface StreamSource
Returns:
true if it does, otherwise false.
Throws:
java.lang.Exception


Things.