com.caucho.vfs
Class JniStream

java.lang.Object
  extended by com.caucho.vfs.StreamImpl
      extended by com.caucho.vfs.JniStream

@Module
public class JniStream
extends StreamImpl

Stream using with JNI.


Field Summary
static int TIMEOUT_EXN
           
 
Fields inherited from class com.caucho.vfs.StreamImpl
_nullPath, _path
 
Constructor Summary
JniStream(JniSocketImpl socket)
          Create a new JniStream based on the java.io.* stream.
 
Method Summary
 boolean canRead()
          Returns true if this is a read stream.
 boolean canWrite()
          Returns true if this is a writable stream.
 void close()
          Closes the stream.
 void flush()
          Flushes the write output.
 int getAvailable()
          Returns the number of bytes available without blocking.
 long getTotalReadBytes()
           
 long getTotalWriteBytes()
           
 void init()
           
 boolean isClosed()
          Returns true if the stream is closed.
 boolean isEof()
           
 int read(byte[] buf, int offset, int length)
          Reads the next chunk from the stream.
 int readTimeout(byte[] buf, int offset, int length, long timeout)
          Reads the next chunk from the stream in non-blocking mode.
 java.lang.String toString()
           
 void write(byte[] buf, int offset, int length, boolean isEnd)
          Writes a buffer to the underlying stream.
 
Methods inherited from class com.caucho.vfs.StreamImpl
clearWrite, closeWrite, flushBuffer, flushToDisk, getAttribute, getAttributeNames, getFlushOnNewline, getNewline, getPath, getReadBuffer, getReadPosition, hasSkip, readNonBlock, removeAttribute, seekEnd, seekStart, setAttribute, setPath, setWriteEncoding, skip, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TIMEOUT_EXN

public static final int TIMEOUT_EXN
See Also:
Constant Field Values
Constructor Detail

JniStream

public JniStream(JniSocketImpl socket)
Create a new JniStream based on the java.io.* stream.

Method Detail

init

public void init()

canRead

public boolean canRead()
Description copied from class: StreamImpl
Returns true if this is a read stream.

Overrides:
canRead in class StreamImpl

isClosed

public boolean isClosed()
Description copied from class: StreamImpl
Returns true if the stream is closed.

Overrides:
isClosed in class StreamImpl

read

public int read(byte[] buf,
                int offset,
                int length)
         throws java.io.IOException
Description copied from class: StreamImpl
Reads the next chunk from the stream.

Overrides:
read in class StreamImpl
Parameters:
buf - byte array receiving the data.
offset - starting offset into the array.
length - number of bytes to read.
Returns:
the number of bytes read or -1 on end of file.
Throws:
java.io.IOException

readTimeout

public int readTimeout(byte[] buf,
                       int offset,
                       int length,
                       long timeout)
                throws java.io.IOException
Description copied from class: StreamImpl
Reads the next chunk from the stream in non-blocking mode.

Overrides:
readTimeout in class StreamImpl
Parameters:
buf - byte array receiving the data.
offset - starting offset into the array.
length - number of bytes to read.
Returns:
the number of bytes read, -1 on end of file, or 0 on timeout.
Throws:
java.io.IOException

getAvailable

public int getAvailable()
                 throws java.io.IOException
Description copied from class: StreamImpl
Returns the number of bytes available without blocking. Depending on the stream, this may return less than the actual bytes, but will always return a number > 0 if there is any data available.

Overrides:
getAvailable in class StreamImpl
Throws:
java.io.IOException

isEof

public boolean isEof()
              throws java.io.IOException
Overrides:
isEof in class StreamImpl
Throws:
java.io.IOException

canWrite

public boolean canWrite()
Description copied from class: StreamImpl
Returns true if this is a writable stream.

Overrides:
canWrite in class StreamImpl

write

public void write(byte[] buf,
                  int offset,
                  int length,
                  boolean isEnd)
           throws java.io.IOException
Description copied from class: StreamImpl
Writes a buffer to the underlying stream.

Overrides:
write in class StreamImpl
Parameters:
buf - the byte array to write.
offset - the offset into the byte array.
length - the number of bytes to write.
isEnd - true when the write is flushing a close.
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Description copied from class: StreamImpl
Flushes the write output.

Overrides:
flush in class StreamImpl
Throws:
java.io.IOException

getTotalReadBytes

public long getTotalReadBytes()

getTotalWriteBytes

public long getTotalWriteBytes()

close

public void close()
           throws java.io.IOException
Closes the stream.

Overrides:
close in class StreamImpl
Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object