com.caucho.vfs
Class JniMemoryMappedFile

java.lang.Object
  extended by com.caucho.vfs.RandomAccessStream
      extended by com.caucho.vfs.JniMemoryMappedFile
All Implemented Interfaces:
LockableStream

public class JniMemoryMappedFile
extends RandomAccessStream

Stream using with JNI.


Method Summary
 void closeImpl()
          Closes the stream.
protected  void finalize()
           
 void flushToDisk()
           
 long getFilePointer()
          Returns the current position of the file pointer.
 java.io.InputStream getInputStream()
          Returns an InputStream for this stream.
 long getLength()
          Returns the length.
 java.io.OutputStream getOutputStream()
          Returns an OutputStream for this stream.
static boolean isEnabled()
           
static JniMemoryMappedFile open(Path path, byte[] name, int length, long fileLength)
           
 int read()
          Read a byte from the file, advancing the pointer.
 int read(byte[] buf, int offset, int length)
          Reads data from the file.
 int read(char[] buf, int offset, int length)
          Reads data from the file.
 int read(long pos, byte[] buf, int offset, int length)
          Reads data from the file.
 boolean seek(long position)
          Seeks to the given position in the file.
 java.lang.String toString()
          Returns the debug name for the stream.
 void write(byte[] buf, int offset, int length)
          Writes data to the file.
 void write(int b)
          Write a byte to the file, advancing the pointer.
 void write(long pos, byte[] buf, int offset, int length)
          Writes data to the file.
 
Methods inherited from class com.caucho.vfs.RandomAccessStream
allocate, close, free, getUseCount, isOpen, lock, unlock
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

isEnabled

public static boolean isEnabled()

open

public static JniMemoryMappedFile open(Path path,
                                       byte[] name,
                                       int length,
                                       long fileLength)

getLength

public long getLength()
               throws java.io.IOException
Returns the length.

Specified by:
getLength in class RandomAccessStream
Throws:
java.io.IOException

read

public int read(long pos,
                byte[] buf,
                int offset,
                int length)
         throws java.io.IOException
Reads data from the file.

Specified by:
read in class RandomAccessStream
Throws:
java.io.IOException

write

public void write(long pos,
                  byte[] buf,
                  int offset,
                  int length)
           throws java.io.IOException
Writes data to the file.

Specified by:
write in class RandomAccessStream
Throws:
java.io.IOException

flushToDisk

public void flushToDisk()
                 throws java.io.IOException
Throws:
java.io.IOException

read

public int read(byte[] buf,
                int offset,
                int length)
         throws java.io.IOException
Reads data from the file.

Specified by:
read in class RandomAccessStream
Throws:
java.io.IOException

read

public int read(char[] buf,
                int offset,
                int length)
         throws java.io.IOException
Reads data from the file.

Specified by:
read in class RandomAccessStream
Throws:
java.io.IOException

write

public void write(byte[] buf,
                  int offset,
                  int length)
           throws java.io.IOException
Writes data to the file.

Specified by:
write in class RandomAccessStream
Throws:
java.io.IOException

seek

public boolean seek(long position)
Seeks to the given position in the file.

Specified by:
seek in class RandomAccessStream

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Returns an OutputStream for this stream.

Specified by:
getOutputStream in class RandomAccessStream
Throws:
java.io.IOException

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Returns an InputStream for this stream.

Specified by:
getInputStream in class RandomAccessStream
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Read a byte from the file, advancing the pointer.

Specified by:
read in class RandomAccessStream
Throws:
java.io.IOException

write

public void write(int b)
           throws java.io.IOException
Write a byte to the file, advancing the pointer.

Specified by:
write in class RandomAccessStream
Throws:
java.io.IOException

getFilePointer

public long getFilePointer()
                    throws java.io.IOException
Returns the current position of the file pointer.

Specified by:
getFilePointer in class RandomAccessStream
Throws:
java.io.IOException

closeImpl

public void closeImpl()
               throws java.io.IOException
Description copied from class: RandomAccessStream
Closes the stream.

Overrides:
closeImpl in class RandomAccessStream
Throws:
java.io.IOException

finalize

protected void finalize()
                 throws java.io.IOException
Overrides:
finalize in class java.lang.Object
Throws:
java.io.IOException

toString

public java.lang.String toString()
Returns the debug name for the stream.

Overrides:
toString in class java.lang.Object