|
RuneHive-Game
|
Represents a Sector and Index cache.
More...
Public Member Functions | |
| ByteBuffer | get (final int indexId) throws IOException |
Gets a ByteBuffer of data within this cache for the specified index id. | |
Static Public Attributes | |
| static final int | INDEX_SIZE = 6 |
| Represents the size of a index file. | |
| static final int | SECTOR_HEADER_SIZE = 8 |
Represents the size of a Sectors header. | |
| static final int | SECTOR_SIZE = 520 |
Represents the size of a Sectors header. | |
Protected Member Functions | |
| Cache (SeekableByteChannel sectorChannel, SeekableByteChannel indexChannel, int id) | |
Constructs a new Cache with the specified sector and index channels and id. | |
Private Member Functions | |
| Index | readIndex (int indexId) throws IOException |
Reads an Index for the specified indexId and returns the decoded data. | |
| Sector | readSector (int sectorId, byte[] data, int offset, int length) throws IOException |
Reads a Sector for the specified sectorId and returns the decoded data. | |
Private Attributes | |
| final ByteBuffer | buffer = ByteBuffer.allocate(SECTOR_SIZE) |
A ByteBuffer allocated to SECTOR_SIZE. | |
| final int | id |
Represents the id of this Cache. | |
| final SeekableByteChannel | indexChannel |
| A byte channel that contains a series of variable-length bytes which represent a index. | |
| final SeekableByteChannel | sectorChannel |
| A byte channel that contains a series of variable-length bytes which represent a sector. | |
Represents a Sector and Index cache.
Definition at line 14 of file Cache.java.
|
protected |
Constructs a new Cache with the specified sector and index channels and id.
| sectorChannel | The cache sectors byte channel. |
| indexChannel | The cache sectors index channel. |
| id | This caches id. |
Definition at line 67 of file Cache.java.
References id, indexChannel, and sectorChannel.
| ByteBuffer com.runehive.fs.cache.Cache.get | ( | final int | indexId | ) | throws IOException |
Gets a ByteBuffer of data within this cache for the specified index id.
| indexId | The file id to get. |
null. | IOException | If some I/O exception occurs. |
Definition at line 81 of file Cache.java.
References com.runehive.fs.cache.Sector.check(), com.runehive.fs.cache.Sector.getNextIndexId(), readIndex(), readSector(), SECTOR_HEADER_SIZE, SECTOR_SIZE, and sectorChannel.
Referenced by com.runehive.fs.cache.decoder.RegionDecoder.load().
|
private |
Reads an Index for the specified indexId and returns the decoded data.
| indexId | The id of the index to read. |
| IOException | If some I/O exception occurs. |
Definition at line 115 of file Cache.java.
References buffer, com.runehive.fs.cache.Index.decode(), INDEX_SIZE, and indexChannel.
Referenced by get().
|
private |
Reads a Sector for the specified sectorId and returns the decoded data.
| sectorId | The id of the sector to read. |
| data | The sectors data. |
| offset | The sectors data offset. |
| length | The length of the sectors data. |
| IOException | If some I/O exception occurs. |
Definition at line 136 of file Cache.java.
References buffer, com.runehive.fs.cache.Sector.decode(), SECTOR_HEADER_SIZE, SECTOR_SIZE, and sectorChannel.
Referenced by get().
|
private |
A ByteBuffer allocated to SECTOR_SIZE.
This byte buffer is used to read index and sector data from their respective byte channels.
Definition at line 41 of file Cache.java.
Referenced by readIndex(), and readSector().
|
private |
|
static |
Represents the size of a index file.
Calculating the total size of a index file. the total size may be that of a long.
Definition at line 20 of file Cache.java.
Referenced by readIndex().
|
private |
A byte channel that contains a series of variable-length bytes which represent a index.
Definition at line 53 of file Cache.java.
Referenced by Cache(), and readIndex().
|
static |
Represents the size of a Sectors header.
Calculating the total size of the sector header. the total size may be that of a long.
Definition at line 26 of file Cache.java.
Referenced by get(), and readSector().
|
static |
Represents the size of a Sectors header.
Calculating the total size of the sector header. the total size may be that of a long
Definition at line 32 of file Cache.java.
Referenced by get(), and readSector().
|
private |
A byte channel that contains a series of variable-length bytes which represent a sector.
Definition at line 47 of file Cache.java.
Referenced by Cache(), get(), and readSector().