Package com.alachisoft.ncache.client
Interface CacheStream
-
- All Superinterfaces:
java.lang.AutoCloseable
public interface CacheStream extends java.lang.AutoCloseable
CacheStream is derived from java.io.BufferedInputStream and java.io.BufferedOutputStream.It is designed to put/fetch BLOB using standard CacheStream interface.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
canRead()
Gets a value indicating whether the current stream supports reading.boolean
canSeek()
Gets a value indicating whether the current stream supports seeking.boolean
canWrite()
Gets a value indicating whether the current stream supports writing.boolean
closed()
Gets a value indicating whether stream is closed or not.void
flush()
When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.java.io.BufferedInputStream
getBufferedInputStream()
Gets theBufferedInputStream
instance.java.io.BufferedInputStream
getBufferedInputStream(int bufferSize)
Gets theBufferedInputStream
of given buffer size.java.io.BufferedOutputStream
getBufferedOutputStream()
Gets theBufferedOutputStream
of given buffer size.java.io.BufferedOutputStream
getBufferedOutputStream(int bufferSize)
Gets theBufferedOutputStream
of given buffer size.long
length()
Gets the length of the stream.long
position()
Gets the position within current stream.int
read(byte[] buffer, int offset, int count)
Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.long
seek(long offset)
Sets the position within the current stream.void
setLength(long value)
Sets the length of the stream.void
write(byte[] buffer, int offset, int count)
Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
-
-
-
Method Detail
-
length
long length() throws java.lang.Exception
Gets the length of the stream.- Returns:
- The length of the stream.
- Throws:
java.lang.Exception
-
canRead
boolean canRead()
Gets a value indicating whether the current stream supports reading.- Returns:
- True if stream supports reading otherwise false.
-
canSeek
boolean canSeek()
Gets a value indicating whether the current stream supports seeking.- Returns:
- True if stream supports seeking otherwise false.
-
canWrite
boolean canWrite()
Gets a value indicating whether the current stream supports writing.- Returns:
- True if stream supports writing otherwise false.
-
closed
boolean closed()
Gets a value indicating whether stream is closed or not.- Returns:
- True if stream is closed otherwise false.
-
flush
void flush()
When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.
-
position
long position() throws java.lang.Exception
Gets the position within current stream.- Returns:
- The position within the current stream.
- Throws:
java.lang.Exception
-
seek
long seek(long offset) throws NotSupportedException
Sets the position within the current stream.- Parameters:
offset
- A byte offset relative to the origin parameter.- Returns:
- The current position within the stream.
- Throws:
NotSupportedException
- If stream does not support seeking.
-
setLength
void setLength(long value) throws NotSupportedException
Sets the length of the stream.- Parameters:
value
- The desired length of the current stream in bytes.- Throws:
NotSupportedException
- If stream does not support both writing and seeking.
-
getBufferedInputStream
java.io.BufferedInputStream getBufferedInputStream(int bufferSize) throws java.lang.Exception
Gets theBufferedInputStream
of given buffer size.- Parameters:
bufferSize
- Buffer size in bytes.- Returns:
- An instance of java.io.BufferedInputStream.
- Throws:
java.lang.Exception
-
getBufferedInputStream
java.io.BufferedInputStream getBufferedInputStream() throws java.lang.Exception
Gets theBufferedInputStream
instance.- Returns:
- An instance of java.io.BufferedInputStream.
- Throws:
java.lang.Exception
-
getBufferedOutputStream
java.io.BufferedOutputStream getBufferedOutputStream(int bufferSize) throws java.lang.Exception
Gets theBufferedOutputStream
of given buffer size.- Parameters:
bufferSize
- Buffer size in bytes.- Returns:
- An instance of java.io.BufferedOutputStream.
- Throws:
java.lang.Exception
-
getBufferedOutputStream
java.io.BufferedOutputStream getBufferedOutputStream() throws java.lang.Exception
Gets theBufferedOutputStream
of given buffer size.- Returns:
- An instance of java.io.BufferedOutputStream.
- Throws:
java.lang.Exception
-
read
int read(byte[] buffer, int offset, int count) throws java.lang.Exception
Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.- Parameters:
buffer
- An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.offset
- The zero-based byte offset in buffer at which to begin storing the data read from the current stream.count
- The maximum number of bytes to be read from the current stream.- Returns:
- The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.
- Throws:
java.lang.Exception
-
write
void write(byte[] buffer, int offset, int count) throws java.lang.Exception
Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.- Parameters:
buffer
- An array of bytes. This method copies count bytes from buffer to the current stream.offset
- The zero-based byte offset in buffer at which to begin copying bytes to the current stream.count
- The number of bytes to be written to the current stream.- Throws:
java.lang.Exception
-
-