|
||||||||||
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 executedMethod Detail |
---|
public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public void finish() throws java.io.IOException
finish
in interface FinishingActionStream
java.io.IOException
- if something goes wrongpublic void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.InputStream
java.io.IOException
public int read(byte[] b, int off, int len) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int read(byte[] b) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public long skip(long n) throws java.io.IOException
skip
in class java.io.InputStream
java.io.IOException
public int available() throws java.io.IOException
available
in class java.io.InputStream
java.io.IOException
public void mark(int readlimit)
mark
in class java.io.InputStream
public boolean markSupported()
markSupported
in class java.io.InputStream
public void reset() throws java.io.IOException
reset
in class java.io.InputStream
java.io.IOException
public 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 FinishingActionStream
public long resetCount()
resetCount
in interface FinishingActionStream
0
public java.io.IOException exceptionBeforeFinishing()
exceptionBeforeFinishing
in interface FinishingActionStream
public void resetExceptionBeforeFinishing()
resetExceptionBeforeFinishing
in interface FinishingActionStream
public void incrementCount(long valueToAdd) throws java.io.IOException
incrementCount
in interface FinishingActionStream
valueToAdd
- the value to add to the counter
java.io.IOException
- if something goes wrongpublic FinishingAction getFinishingAction()
getFinishingAction
in interface FinishingActionStream
public void setFinishingAction(FinishingAction finishingAction)
setFinishingAction
in interface FinishingActionStream
finishingAction
- the actionpublic java.lang.Object getWrappedStream()
getWrappedStream
in interface FinishingActionStream
public void setWrappedStream(java.lang.Object wrappedStream)
setWrappedStream
in interface FinishingActionStream
wrappedStream
- the wrapped stream
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |