Buju 0.4

biz.bbeans.util
Class BInputStreamLoader

java.lang.Object
  extended bybiz.bbeans.util.BInputStreamLoader

public abstract class BInputStreamLoader
extends Object

Utility to load an InputStream into a String. An instance of BInputStreamLoader is re-usable; in other words, one BInputStreamLoader can load more than one InputStream.


Constructor Summary
BInputStreamLoader()
          Create a new BInputStreamLoader.
 
Method Summary
static BInputStreamLoader getDefaultInstance()
          Get an instance of BInputStreamLoader which implements processLine by simply returning the line untouched.
 String load(InputStreamReader in)
          Load the data from the given InputStreamReader into a String.
abstract  String processLine(String line)
          Process the line of data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BInputStreamLoader

public BInputStreamLoader()
Create a new BInputStreamLoader. You must provide an implementation of processLine if you use this constructor. Use getDefaultInstance for a default implementation which does no processing of the loaded data.

Method Detail

load

public String load(InputStreamReader in)
            throws IOException
Load the data from the given InputStreamReader into a String. Calls implemented processLine method.

Parameters:
in - InputStreamReader to load from.
Returns:
Loaded data.
Throws:
IOException - If I/O exception occurs.

processLine

public abstract String processLine(String line)
Process the line of data. Implementations should make whatever changes they need to the line and return it.

Parameters:
line - Line to process.
Returns:
Processed line.

getDefaultInstance

public static BInputStreamLoader getDefaultInstance()
Get an instance of BInputStreamLoader which implements processLine by simply returning the line untouched.

Returns:
No-op instance.

Buju 0.4