|
||||||||||
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 java.util.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()
|
java.lang.String |
readLine()
Deprecated. |
long |
readLong()
|
short |
readShort()
|
int |
readUnsignedByte()
|
int |
readUnsignedShort()
|
java.lang.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(java.lang.String str)
|
void |
writeChar(int c)
|
void |
writeChars(java.lang.String str)
|
void |
writeDouble(double d)
|
void |
writeFloat(float f)
|
void |
writeInt(int i)
|
void |
writeLong(long l)
|
void |
writeShort(int s)
|
void |
writeUTF(java.lang.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 java.util.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 java.io.IOException
NikeFS2RandomAccessStorage
close
in interface NikeFS2RandomAccessStorage
java.io.IOException
public NikeFS2RandomAccessStorage copy() throws java.io.IOException
NikeFS2RandomAccessStorage
copy
in interface NikeFS2RandomAccessStorage
java.io.IOException
public long getFilePointer() throws java.io.IOException
NikeFS2RandomAccessStorage
getFilePointer
in interface NikeFS2RandomAccessStorage
java.io.IOException
public long length() throws java.io.IOException
NikeFS2RandomAccessStorage
length
in interface NikeFS2RandomAccessStorage
java.io.IOException
public void seek(long pos) throws java.io.IOException
NikeFS2RandomAccessStorage
seek
in interface NikeFS2RandomAccessStorage
pos
- The offset in bytes, at which the next operation
will occur.
java.io.IOException
public int skipBytes(int n) throws java.io.IOException
NikeFS2RandomAccessStorage
skipBytes
in interface java.io.DataInput
skipBytes
in interface NikeFS2RandomAccessStorage
java.io.IOException
public void write(int b) throws java.io.IOException
write
in interface java.io.DataOutput
java.io.IOException
public void write(byte[] b) throws java.io.IOException
write
in interface java.io.DataOutput
java.io.IOException
public void write(byte[] b, int off, int len) throws java.io.IOException
write
in interface java.io.DataOutput
java.io.IOException
public void writeBoolean(boolean v) throws java.io.IOException
writeBoolean
in interface java.io.DataOutput
java.io.IOException
public void writeByte(int b) throws java.io.IOException
writeByte
in interface java.io.DataOutput
java.io.IOException
public void writeBytes(java.lang.String str) throws java.io.IOException
writeBytes
in interface java.io.DataOutput
java.io.IOException
public void writeChar(int c) throws java.io.IOException
writeChar
in interface java.io.DataOutput
java.io.IOException
public void writeChars(java.lang.String str) throws java.io.IOException
writeChars
in interface java.io.DataOutput
java.io.IOException
public void writeDouble(double d) throws java.io.IOException
writeDouble
in interface java.io.DataOutput
java.io.IOException
public void writeFloat(float f) throws java.io.IOException
writeFloat
in interface java.io.DataOutput
java.io.IOException
public void writeInt(int i) throws java.io.IOException
writeInt
in interface java.io.DataOutput
java.io.IOException
public void writeLong(long l) throws java.io.IOException
writeLong
in interface java.io.DataOutput
java.io.IOException
public void writeShort(int s) throws java.io.IOException
writeShort
in interface java.io.DataOutput
java.io.IOException
public void writeUTF(java.lang.String str) throws java.io.IOException
writeUTF
in interface java.io.DataOutput
java.io.IOException
public boolean readBoolean() throws java.io.IOException
readBoolean
in interface java.io.DataInput
java.io.IOException
public byte readByte() throws java.io.IOException
readByte
in interface java.io.DataInput
java.io.IOException
public char readChar() throws java.io.IOException
readChar
in interface java.io.DataInput
java.io.IOException
public double readDouble() throws java.io.IOException
readDouble
in interface java.io.DataInput
java.io.IOException
public float readFloat() throws java.io.IOException
readFloat
in interface java.io.DataInput
java.io.IOException
public void readFully(byte[] b) throws java.io.IOException
readFully
in interface java.io.DataInput
java.io.IOException
public void readFully(byte[] b, int off, int len) throws java.io.IOException
readFully
in interface java.io.DataInput
java.io.IOException
public int readInt() throws java.io.IOException
readInt
in interface java.io.DataInput
java.io.IOException
@Deprecated public java.lang.String readLine() throws java.io.IOException
readLine
in interface java.io.DataInput
java.io.IOException
public long readLong() throws java.io.IOException
readLong
in interface java.io.DataInput
java.io.IOException
public short readShort() throws java.io.IOException
readShort
in interface java.io.DataInput
java.io.IOException
public java.lang.String readUTF() throws java.io.IOException
readUTF
in interface java.io.DataInput
java.io.IOException
public int readUnsignedByte() throws java.io.IOException
readUnsignedByte
in interface java.io.DataInput
java.io.IOException
public int readUnsignedShort() throws java.io.IOException
readUnsignedShort
in interface java.io.DataInput
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |