|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.InputStream
org.gcube.contentmanagement.baselayer.streamutils.FinishingActionInputStream
public class FinishingActionInputStream
This class provites a generic wrapper for InputStreams, which are decorated with some action that should be performed whenever the end of the stream has been reached.
| Constructor Summary | |
|---|---|
FinishingActionInputStream(java.io.InputStream wrappedStream,
FinishingAction action)
wrapps a stream with some action, that will be executed once, when the end of the stream has been reached for the first time. |
|
| Method Summary | |
|---|---|
int |
available()
|
void |
close()
|
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 read from or 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. |
void |
mark(int readlimit)
|
boolean |
markSupported()
|
int |
read()
|
int |
read(byte[] b)
|
int |
read(byte[] b,
int off,
int len)
|
void |
reset()
|
long |
resetCount()
Resets the number of bytes written 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 |
long |
skip(long n)
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FinishingActionInputStream(java.io.InputStream wrappedStream,
FinishingAction action)
wrappedStream - the stream from which the data is takenaction - the action that should be executed| Method Detail |
|---|
public int read()
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOException
public void finish()
throws java.io.IOException
finish in interface FinishingActionStreamjava.io.IOException - if something goes wrong
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in class java.io.InputStreamjava.io.IOException
public int read(byte[] b,
int off,
int len)
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOException
public int read(byte[] b)
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOException
public long skip(long n)
throws java.io.IOException
skip in class java.io.InputStreamjava.io.IOException
public int available()
throws java.io.IOException
available in class java.io.InputStreamjava.io.IOExceptionpublic void mark(int readlimit)
mark in class java.io.InputStreampublic boolean markSupported()
markSupported in class java.io.InputStream
public void reset()
throws java.io.IOException
reset in class java.io.InputStreamjava.io.IOExceptionpublic long 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!
getCount in interface FinishingActionStreampublic long resetCount()
resetCount in interface FinishingActionStream0public java.io.IOException exceptionBeforeFinishing()
exceptionBeforeFinishing in interface FinishingActionStreampublic void resetExceptionBeforeFinishing()
resetExceptionBeforeFinishing in interface FinishingActionStream
public void incrementCount(long valueToAdd)
throws java.io.IOException
incrementCount in interface FinishingActionStreamvalueToAdd - the value to add to the counter
java.io.IOException - if something goes wrongpublic FinishingAction getFinishingAction()
getFinishingAction in interface FinishingActionStreampublic void setFinishingAction(FinishingAction finishingAction)
setFinishingAction in interface FinishingActionStreamfinishingAction - the actionpublic java.lang.Object getWrappedStream()
getWrappedStream in interface FinishingActionStreampublic void setWrappedStream(java.lang.Object wrappedStream)
setWrappedStream in interface FinishingActionStreamwrappedStream - the wrapped stream
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||