|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface FinishingActionStream
Defines a common interface for streams, that are able to perform an action when the end of the stream has been reached.
Unfortunately, there has been no common interface for arbitrary streams in Java until Java 5 (when the Closeable interface has been introduced), and even worse, InputStream and OutputStream are classes, which have not been defined as or implemented against any interface, such that subclasses need to extend them directly -and there is no possibility, e.g. to inherit functionality provided in an (abstract) class. Otherwise much of the operations defined in here could have been implemented in such an abstract class, such that it could be used directly in FinishingActionOutputStream as well as FinishingActionInputStream.
Method Summary | |
---|---|
java.io.IOException |
exceptionBeforeFinishing()
Captures any error/exception/throwable or exception that occured right before executing the finishing action, in particular any IOException that occured when closing the stream. By this, the action can decide how to deal with this exception. |
void |
finish()
closes the wrapped stream and then executes the action, that has been defined to take place at the end of the stream |
long |
getCount()
Returns the number of bytes written to or read fromor skipped on the stream. |
FinishingAction |
getFinishingAction()
Retruns the assigned finishing action |
java.lang.Object |
getWrappedStream()
Returns the wrapped stream on which the stream operates |
void |
incrementCount(long valueToAdd)
Increments the value of count by the given value. |
long |
resetCount()
Resets the number of bytes written / read to zero, to start again counting. |
void |
resetExceptionBeforeFinishing()
Resets any exception that has been captured before executing the finishing action, such that it will not be thrown after finishing action was performed. |
void |
setFinishingAction(FinishingAction finishingAction)
Sets the action that should be performed for finishing processing of the stream |
void |
setWrappedStream(java.lang.Object wrappedStream)
Sets the wrapped stream on which the stream operates |
Method Detail |
---|
void finish() throws java.io.IOException
java.io.IOException
- if something goes wronglong getCount()
This is the actual number counted, if a stream supports marking - in
other words, if mark(int)
and reset
has been
used, some bytes might get be counted more than once!
long resetCount()
0
void incrementCount(long valueToAdd) throws java.io.IOException
valueToAdd
- the value to add to the counter
java.io.IOException
- if something goes wrongjava.io.IOException exceptionBeforeFinishing()
void resetExceptionBeforeFinishing()
FinishingAction getFinishingAction()
void setFinishingAction(FinishingAction finishingAction)
finishingAction
- the actionjava.lang.Object getWrappedStream()
void setWrappedStream(java.lang.Object wrappedStream)
wrappedStream
- the wrapped stream
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |