|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.deckfour.xes.nikefs2.NikeFS2RandomAccessStorageImpl
public class NikeFS2RandomAccessStorageImpl
Implements the Random Access Storage interface for using the NikeFS2 virtual file system transparently to the application and user. Effectively, this class implements a file abstraction, backed not by a real OS-level file, but a set of virtual blocks in the VFS.
Nested Class Summary | |
---|---|
protected class |
NikeFS2RandomAccessStorageImpl.FS2BlockInputStream
Internal support class implementing an input stream over a list of blocks, as implemented by the enclosing class |
protected class |
NikeFS2RandomAccessStorageImpl.FS2BlockOutputStream
Internal support class implementing an output stream over a list of blocks, as implemented by the enclosing class |
protected class |
NikeFS2RandomAccessStorageImpl.FS2DataInputStream
Internal support class implementing a data input stream with NikeFS2-block-safe UTF-8 string serialization. |
protected class |
NikeFS2RandomAccessStorageImpl.FS2DataOutputStream
Internal support class implementing a data output stream with NikeFS2-block-safe UTF-8 string serialization. |
Field Summary | |
---|---|
protected List<NikeFS2Block> |
blocks
List of blocks used to store data. |
protected NikeFS2RandomAccessStorageImpl.FS2DataInputStream |
dataInputStream
Data input stream, used to simplify reading of higher-level data types. |
protected NikeFS2RandomAccessStorageImpl.FS2DataOutputStream |
dataOutputStream
Data output stream, used to simplify writing of higher-level data types. |
protected long |
pointer
Current file pointer (in bytes from the start) within this virtual file. |
protected long |
size
Current size, in bytes, of this virtual file. |
protected NikeFS2VirtualFileSystem |
vfs
References the virtual file system for block provision. |
Constructor Summary | |
---|---|
NikeFS2RandomAccessStorageImpl(NikeFS2VirtualFileSystem virtualFileSystem)
Creates a new instance of this class. |
Method Summary | |
---|---|
protected void |
adjustSize()
Calling this method will adjust the size of this file, if it is no longer accurate. |
void |
close()
Closes the data storage container. |
NikeFS2RandomAccessStorage |
copy()
Creates a clone, or copy, of this storage, having the exact same contents and the file pointer reset to zero. |
long |
getFilePointer()
Returns the current file pointer of the storage container. |
long |
length()
Returns the length, or size, in number of bytes currently used by this instance. |
boolean |
readBoolean()
|
byte |
readByte()
|
char |
readChar()
|
double |
readDouble()
|
float |
readFloat()
|
void |
readFully(byte[] b)
|
void |
readFully(byte[] b,
int off,
int len)
|
int |
readInt()
|
String |
readLine()
Deprecated. |
long |
readLong()
|
short |
readShort()
|
int |
readUnsignedByte()
|
int |
readUnsignedShort()
|
String |
readUTF()
|
void |
seek(long pos)
Repositions the offset, or file pointer, at which the next read or write operation will occur. |
int |
skipBytes(int n)
Moves the offset, or file pointer, a specified number of bytes towards the end of the storage container. |
protected int |
translateToBlockNumber(long offset)
Translates a virtual file pointer address in this instance to the block number, where the data is actually stored. |
protected int |
translateToBlockOffset(long offset)
Translates a virtual file pointer address in this instance to the offset within the block, where the data is actually stored. |
void |
write(byte[] b)
|
void |
write(byte[] b,
int off,
int len)
|
void |
write(int b)
|
void |
writeBoolean(boolean v)
|
void |
writeByte(int b)
|
void |
writeBytes(String str)
|
void |
writeChar(int c)
|
void |
writeChars(String str)
|
void |
writeDouble(double d)
|
void |
writeFloat(float f)
|
void |
writeInt(int i)
|
void |
writeLong(long l)
|
void |
writeShort(int s)
|
void |
writeUTF(String str)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected NikeFS2VirtualFileSystem vfs
protected List<NikeFS2Block> blocks
protected long size
protected long pointer
protected NikeFS2RandomAccessStorageImpl.FS2DataOutputStream dataOutputStream
protected NikeFS2RandomAccessStorageImpl.FS2DataInputStream dataInputStream
Constructor Detail |
---|
public NikeFS2RandomAccessStorageImpl(NikeFS2VirtualFileSystem virtualFileSystem)
virtualFileSystem
- The virtual file system instance
this virtual file can allocate storage blocks from.Method Detail |
---|
protected void adjustSize()
protected int translateToBlockNumber(long offset)
offset
- The virtual file pointer address,
in bytes from the beginning.
protected int translateToBlockOffset(long offset)
offset
- The virtual file pointer address,
in bytes from the beginning.
public void close() throws IOException
NikeFS2RandomAccessStorage
close
in interface NikeFS2RandomAccessStorage
IOException
public NikeFS2RandomAccessStorage copy() throws IOException
NikeFS2RandomAccessStorage
copy
in interface NikeFS2RandomAccessStorage
IOException
public long getFilePointer() throws IOException
NikeFS2RandomAccessStorage
getFilePointer
in interface NikeFS2RandomAccessStorage
IOException
public long length() throws IOException
NikeFS2RandomAccessStorage
length
in interface NikeFS2RandomAccessStorage
IOException
public void seek(long pos) throws IOException
NikeFS2RandomAccessStorage
seek
in interface NikeFS2RandomAccessStorage
pos
- The offset in bytes, at which the next operation
will occur.
IOException
public int skipBytes(int n) throws IOException
NikeFS2RandomAccessStorage
skipBytes
in interface DataInput
skipBytes
in interface NikeFS2RandomAccessStorage
IOException
public void write(int b) throws IOException
write
in interface DataOutput
IOException
public void write(byte[] b) throws IOException
write
in interface DataOutput
IOException
public void write(byte[] b, int off, int len) throws IOException
write
in interface DataOutput
IOException
public void writeBoolean(boolean v) throws IOException
writeBoolean
in interface DataOutput
IOException
public void writeByte(int b) throws IOException
writeByte
in interface DataOutput
IOException
public void writeBytes(String str) throws IOException
writeBytes
in interface DataOutput
IOException
public void writeChar(int c) throws IOException
writeChar
in interface DataOutput
IOException
public void writeChars(String str) throws IOException
writeChars
in interface DataOutput
IOException
public void writeDouble(double d) throws IOException
writeDouble
in interface DataOutput
IOException
public void writeFloat(float f) throws IOException
writeFloat
in interface DataOutput
IOException
public void writeInt(int i) throws IOException
writeInt
in interface DataOutput
IOException
public void writeLong(long l) throws IOException
writeLong
in interface DataOutput
IOException
public void writeShort(int s) throws IOException
writeShort
in interface DataOutput
IOException
public void writeUTF(String str) throws IOException
writeUTF
in interface DataOutput
IOException
public boolean readBoolean() throws IOException
readBoolean
in interface DataInput
IOException
public byte readByte() throws IOException
readByte
in interface DataInput
IOException
public char readChar() throws IOException
readChar
in interface DataInput
IOException
public double readDouble() throws IOException
readDouble
in interface DataInput
IOException
public float readFloat() throws IOException
readFloat
in interface DataInput
IOException
public void readFully(byte[] b) throws IOException
readFully
in interface DataInput
IOException
public void readFully(byte[] b, int off, int len) throws IOException
readFully
in interface DataInput
IOException
public int readInt() throws IOException
readInt
in interface DataInput
IOException
@Deprecated public String readLine() throws IOException
readLine
in interface DataInput
IOException
public long readLong() throws IOException
readLong
in interface DataInput
IOException
public short readShort() throws IOException
readShort
in interface DataInput
IOException
public String readUTF() throws IOException
readUTF
in interface DataInput
IOException
public int readUnsignedByte() throws IOException
readUnsignedByte
in interface DataInput
IOException
public int readUnsignedShort() throws IOException
readUnsignedShort
in interface DataInput
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |