com.sentilla.platform.cmote
Class RemoteRandomAccessFile

java.lang.Object
  extended by com.sentilla.platform.cmote.RemoteRandomAccessFile
All Implemented Interfaces:
DataInput, DataOutput, DataRandomAccess, Input, ObjectInput, ObjectOutput, ObjectRandomAccess, Output, RandomAccessFile

public class RemoteRandomAccessFile
extends Object
implements RandomAccessFile

Private: for Sentilla internal use only.

Abstraction for accessing a remote property.

Notes: Because the property is remote, we don't really know how big it is or what it contains. Reads and writes are propagated as atomic transactions on the remote file and may succeed or fail depending on remote conditions. There is no coherency guarantee and in fact applications should assume that it is their responsibility to guard against RAW and WAR hazards. OperationTimedOutException is thrown whenever an RPC fails to return.


Constructor Summary
RemoteRandomAccessFile(Addressable target, String key)
           
RemoteRandomAccessFile(Addressable target, String key, int maxlength)
           
 
Method Summary
 void close()
          Close the underlying media.
 void flush()
          Ensure that all previous writes have been committed.
 int getOffset()
          Get the seek position in the media.
 int length()
          Get length of the media.
 byte read()
           
 int read(byte[] b)
           
 int read(byte[] b, int boffset, int length)
           
 boolean readBoolean()
           
 byte readByte()
           
 char readChar()
           
 double readDouble()
           
 float readFloat()
           
 int readInt()
           
 long readLong()
           
 Object readObject()
          Read an Object.
 short readShort()
           
 int readUnsignedByte()
           
 String readUTF()
           
 void seek(int offset)
          Set the seek position in the media.
 void skip(int n)
           
 void write(byte[] b)
          Write an array of bytes.
 void write(byte[] b, int boffset, int length)
          Write a series of bytes.
 void write(int b)
          Write a single byte.
 void writeBoolean(boolean a)
           
 void writeByte(int a)
           
 void writeChar(int a)
           
 void writeDouble(double a)
           
 void writeFloat(float a)
           
 void writeInt(int a)
           
 void writeLong(long a)
           
 void writeObject(Object obj)
          Write an object as data.
 void writeShort(int a)
           
 void writeUTF(String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteRandomAccessFile

public RemoteRandomAccessFile(Addressable target,
                              String key,
                              int maxlength)

RemoteRandomAccessFile

public RemoteRandomAccessFile(Addressable target,
                              String key)
Method Detail

getOffset

public int getOffset()
Description copied from interface: DataRandomAccess
Get the seek position in the media.

Specified by:
getOffset in interface DataRandomAccess
Returns:
byte index.

writeObject

public void writeObject(Object obj)
Description copied from interface: ObjectOutput
Write an object as data.

Specified by:
writeObject in interface ObjectOutput
Parameters:
obj - Object to write must implement java.io.Serializable

readObject

public Object readObject()
Description copied from interface: ObjectInput
Read an Object.

Specified by:
readObject in interface ObjectInput
Returns:
an Object.

read

public int read(byte[] b,
                int boffset,
                int length)
Specified by:
read in interface Input

write

public void write(byte[] b,
                  int boffset,
                  int length)
Description copied from interface: Output
Write a series of bytes.

Specified by:
write in interface Output
boffset - within b defining start of series.
length - number of bytes to write.

skip

public void skip(int n)
Specified by:
skip in interface Input

seek

public void seek(int offset)
Description copied from interface: DataRandomAccess
Set the seek position in the media. Subsequent read/write will be performed at this position.

Specified by:
seek in interface DataRandomAccess
Parameters:
offset - byte index to seek to.

length

public int length()
Description copied from interface: DataRandomAccess
Get length of the media.

Specified by:
length in interface DataRandomAccess
Returns:
total number of bytes.

readBoolean

public boolean readBoolean()
                    throws IORuntimeException
Specified by:
readBoolean in interface DataInput
Throws:
IORuntimeException

readByte

public byte readByte()
              throws IORuntimeException
Specified by:
readByte in interface DataInput
Throws:
IORuntimeException

readUnsignedByte

public int readUnsignedByte()
                     throws IORuntimeException
Specified by:
readUnsignedByte in interface DataInput
Throws:
IORuntimeException

readShort

public short readShort()
                throws IORuntimeException
Specified by:
readShort in interface DataInput
Throws:
IORuntimeException

readChar

public char readChar()
              throws IORuntimeException
Specified by:
readChar in interface DataInput
Throws:
IORuntimeException

readInt

public int readInt()
            throws IORuntimeException
Specified by:
readInt in interface DataInput
Throws:
IORuntimeException

readLong

public long readLong()
              throws IORuntimeException
Specified by:
readLong in interface DataInput
Throws:
IORuntimeException

readFloat

public float readFloat()
                throws IORuntimeException
Specified by:
readFloat in interface DataInput
Throws:
IORuntimeException

readDouble

public double readDouble()
                  throws IORuntimeException
Specified by:
readDouble in interface DataInput
Throws:
IORuntimeException

readUTF

public String readUTF()
               throws IORuntimeException
Specified by:
readUTF in interface DataInput
Throws:
IORuntimeException

writeBoolean

public void writeBoolean(boolean a)
                  throws IORuntimeException
Specified by:
writeBoolean in interface DataOutput
Throws:
IORuntimeException

writeByte

public void writeByte(int a)
               throws IORuntimeException
Specified by:
writeByte in interface DataOutput
Throws:
IORuntimeException

writeShort

public void writeShort(int a)
                throws IORuntimeException
Specified by:
writeShort in interface DataOutput
Throws:
IORuntimeException

writeChar

public void writeChar(int a)
               throws IORuntimeException
Specified by:
writeChar in interface DataOutput
Throws:
IORuntimeException

writeInt

public void writeInt(int a)
              throws IORuntimeException
Specified by:
writeInt in interface DataOutput
Throws:
IORuntimeException

writeLong

public void writeLong(long a)
               throws IORuntimeException
Specified by:
writeLong in interface DataOutput
Throws:
IORuntimeException

writeFloat

public void writeFloat(float a)
                throws IORuntimeException
Specified by:
writeFloat in interface DataOutput
Throws:
IORuntimeException

writeDouble

public void writeDouble(double a)
                 throws IORuntimeException
Specified by:
writeDouble in interface DataOutput
Throws:
IORuntimeException

writeUTF

public void writeUTF(String s)
              throws IORuntimeException
Specified by:
writeUTF in interface DataOutput
Throws:
IORuntimeException

read

public byte read()
          throws IORuntimeException
Specified by:
read in interface Input
Throws:
IORuntimeException

read

public int read(byte[] b)
         throws IORuntimeException
Specified by:
read in interface Input
Throws:
IORuntimeException

close

public void close()
           throws IORuntimeException
Description copied from interface: Output
Close the underlying media. No more writes will be successful.

Specified by:
close in interface Input
Specified by:
close in interface Output
Throws:
IORuntimeException

write

public void write(int b)
           throws IORuntimeException
Description copied from interface: Output
Write a single byte.

Specified by:
write in interface Output
Throws:
IORuntimeException

write

public void write(byte[] b)
           throws IORuntimeException
Description copied from interface: Output
Write an array of bytes.

Specified by:
write in interface Output
Throws:
IORuntimeException

flush

public void flush()
           throws IORuntimeException
Description copied from interface: Output
Ensure that all previous writes have been committed.

Specified by:
flush in interface Output
Throws:
IORuntimeException


Copyright © 2007 Sentilla Corporation. All Rights Reserved.