Interface StreamBundle
-
- All Known Implementing Classes:
BufferedStreamBundle
,com.levigo.jadice.server.shared.types.internal.DefaultStreamBundle
public interface StreamBundle extends Iterable<Stream>, Iterator<Stream>
Bundles severalStream
s. The streams may be added asynchronously, therefore access to the streams is purely iterative.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
abort()
Close all bundled streams and shut everything down.void
addStream(Stream s)
Add a Stream to this bundle.OutputStream
addStream(StreamDescriptor type)
Convenience method: add aDynamicPipe
for the givenStreamDescriptor
, and return as theOutputStream
the write end of the pipe.void
addStream(InputStream stream, StreamDescriptor type)
Convenience method: add the givenInputStream
along with itsStreamDescriptor
by wrapping it in aBundledStream
.void
complete()
Signal the completeness of the stream bundle.boolean
hasNext()
Check whether there are more streams to be retrieved.boolean
isComplete()
Return whether this bundle is complete, i.e.Iterator<Stream>
iterator()
Stream
next()
Retrieve the next stream This method may block until either a new stream is available, or the completeness of the bundle has been signaled.void
remove()
Not supported! Throws aUnsupportedOperationException
.-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Method Detail
-
addStream
void addStream(InputStream stream, StreamDescriptor type) throws IOException
Convenience method: add the givenInputStream
along with itsStreamDescriptor
by wrapping it in aBundledStream
.- Parameters:
stream
- TheInputStream
to addtype
- the associatedStreamDescriptor
- Throws:
IOException
- might be thrown if an error occurs when the givenInputStream
is wrapped to aSeekableInputStream
-
addStream
OutputStream addStream(StreamDescriptor type) throws IOException
Convenience method: add aDynamicPipe
for the givenStreamDescriptor
, and return as theOutputStream
the write end of the pipe.- Parameters:
type
- the associatedStreamDescriptor
- Returns:
- output stream
- Throws:
IOException
- if an I/O Error occurs
-
addStream
void addStream(Stream s)
Add a Stream to this bundle.- Parameters:
s
- theStream
to be added
-
hasNext
boolean hasNext()
Check whether there are more streams to be retrieved. This method may block until either a new stream is available, or the completeness of the bundle has been signaled.- Specified by:
hasNext
in interfaceIterator<Stream>
- See Also:
Iterator.hasNext()
-
next
Stream next()
Retrieve the next stream This method may block until either a new stream is available, or the completeness of the bundle has been signaled.- Specified by:
next
in interfaceIterator<Stream>
- Throws:
NoSuchElementException
- if there are no more streams.- See Also:
Iterator.next()
-
remove
void remove()
Not supported! Throws aUnsupportedOperationException
.- Specified by:
remove
in interfaceIterator<Stream>
- See Also:
Iterator.remove()
-
isComplete
boolean isComplete()
Return whether this bundle is complete, i.e. all streams have been received. This method differs fromhasNext()
by never blocking.- Returns:
- true iff this bundle is complete
-
complete
void complete()
Signal the completeness of the stream bundle.
-
abort
void abort()
Close all bundled streams and shut everything down. Beware: closing a bundle is rather disrupting. For a normal termination with no more data available usecomplete()
.
-
-