com.uwyn.rife.tools
Class InputStreamUser<ResultType,DataType>

java.lang.Object
  extended by com.uwyn.rife.tools.InputStreamUser<ResultType,DataType>
All Implemented Interfaces:
Cloneable

public abstract class InputStreamUser<ResultType,DataType>
extends Object
implements Cloneable

By extending this class it's possible to provide the logic that should be executed by methods that allow interaction with an InputStream.

This class has both a default constructor and one that can take a data object. This can be handy when using it as an extending anonymous inner class when you need to use variables inside the inner class that are cumbersome to change to final in the enclosing class.

Since:
1.0
Version:
$Revision: 3634 $
Author:
Geert Bevin (gbevin[remove] at uwyn dot com)

Field Summary
protected  DataType mData
           
 
Constructor Summary
InputStreamUser()
           
InputStreamUser(DataType data)
           
 
Method Summary
 Object clone()
          Simply clones the instance with the default clone method since this class contains no member variables.
 DataType getData()
           
 void throwException(Exception exception)
          Calling this method makes it possible to throw a checked exception from within this class.
abstract  ResultType useInputStream(InputStream stream)
          Should be implemented by all extending classes.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mData

protected DataType mData
Constructor Detail

InputStreamUser

public InputStreamUser()

InputStreamUser

public InputStreamUser(DataType data)
Method Detail

getData

public DataType getData()

throwException

public void throwException(Exception exception)
                    throws InnerClassException
Calling this method makes it possible to throw a checked exception from within this class.

To catch it you should surround the using method with a try-catch block that catching InnerClassException. The original exception is then available through getCause() and can for example be rethrown.

Throws:
InnerClassException - when a checked exception needs to be thrown from within this class and caught outside the caller.
Since:
1.0

useInputStream

public abstract ResultType useInputStream(InputStream stream)
                                   throws InnerClassException
Should be implemented by all extending classes.

Throws:
InnerClassException
Since:
1.0

clone

public Object clone()
Simply clones the instance with the default clone method since this class contains no member variables.

Overrides:
clone in class Object
Since:
1.0


Copyright © 2001-2007 Uwyn sprl/bvba. All Rights Reserved.