RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.fs.cache.Sector Class Reference

Represents a sector within some Cache. More...

Public Member Functions

void check (int cacheId, int indexId, int chunk)
 Tests whether or not this sector is valid.
int getCacheId ()
 Returns the id of the cache this sector is in.
int getChunk ()
 Returns this sectors chunk.
int getIndexId ()
 Returns the id of the index this sector is within.
int getNextIndexId ()
 Returns the next index within this sector.

Static Public Member Functions

static Sector decode (ByteBuffer buffer, byte[] data, int offset, int length)
 Decodes a Sector from the specified ByteBuffer.

Private Member Functions

 Sector (int indexId, int chunk, int nextIndexId, int cacheId)
 Constructs a new Sector with the expected index id, chunk, next index id and cache id.

Private Attributes

final int cacheId
 The id of the cache this sector is in.
final int chunk
 This sectors chunk.
final int indexId
 The id of the index this sector is within.
final int nextIndexId
 The next index within this sector.

Detailed Description

Represents a sector within some Cache.

Author
Ryley Kimmel ryley.nosp@m..kim.nosp@m.mel@l.nosp@m.ive..nosp@m.com

Definition at line 13 of file Sector.java.

Constructor & Destructor Documentation

◆ Sector()

com.runehive.fs.cache.Sector.Sector ( int indexId,
int chunk,
int nextIndexId,
int cacheId )
private

Constructs a new Sector with the expected index id, chunk, next index id and cache id.

This constructor is marked private and should not be modified to be invoked directly, use Sector#decode(ByteBuffer, byte[], int, int) instead.

Parameters
indexIdThe id of the index this sector is within.
chunkThis sectors chunk.
nextIndexIdThe next index within this sector.
cacheIdThe id of the cache this sector is in.

Definition at line 38 of file Sector.java.

38 {
39 this.indexId = indexId;
40 this.chunk = chunk;
41 this.nextIndexId = nextIndexId;
42 this.cacheId = cacheId;
43 }

References cacheId, chunk, indexId, and nextIndexId.

Referenced by decode().

Here is the caller graph for this function:

Member Function Documentation

◆ check()

void com.runehive.fs.cache.Sector.check ( int cacheId,
int indexId,
int chunk )

Tests whether or not this sector is valid.

Parameters
cacheIdThe cache id to test.
indexIdThe index id to test.
chunkThe chunk id to test.

Definition at line 70 of file Sector.java.

70 {
71 Preconditions.checkArgument(this.cacheId == cacheId);
72 Preconditions.checkArgument(this.indexId == indexId);
73 Preconditions.checkArgument(this.chunk == chunk);
74 }

References cacheId, chunk, and indexId.

Referenced by com.runehive.fs.cache.Cache.get().

Here is the caller graph for this function:

◆ decode()

Sector com.runehive.fs.cache.Sector.decode ( ByteBuffer buffer,
byte[] data,
int offset,
int length )
static

Decodes a Sector from the specified ByteBuffer.

Parameters
bufferThe ByteBuffer to get the sector from.
dataThe expected data within the sector.
offsetThe expected offset of the sector.
lengthThe expected length of the sector.
Returns
The decoded sector.

Definition at line 54 of file Sector.java.

54 {
55 int indexId = buffer.getShort() & 0xFFFF;
56 int chunk = buffer.getShort() & 0xFFFF;
57 int nextIndexId = ByteBufferUtil.getMedium(buffer);
58 int cacheId = buffer.get() & 0xFF;
59 buffer.get(data, offset, length);
60 return new Sector(indexId, chunk, nextIndexId, cacheId);
61 }

References cacheId, chunk, com.runehive.fs.util.ByteBufferUtil.getMedium(), indexId, nextIndexId, and Sector().

Referenced by com.runehive.fs.cache.Cache.readSector().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCacheId()

int com.runehive.fs.cache.Sector.getCacheId ( )

Returns the id of the cache this sector is in.

Definition at line 92 of file Sector.java.

92 {
93 return cacheId;
94 }

References cacheId.

◆ getChunk()

int com.runehive.fs.cache.Sector.getChunk ( )

Returns this sectors chunk.

Definition at line 82 of file Sector.java.

82 {
83 return chunk;
84 }

References chunk.

◆ getIndexId()

int com.runehive.fs.cache.Sector.getIndexId ( )

Returns the id of the index this sector is within.

Definition at line 77 of file Sector.java.

77 {
78 return indexId;
79 }

References indexId.

◆ getNextIndexId()

int com.runehive.fs.cache.Sector.getNextIndexId ( )

Returns the next index within this sector.

Definition at line 87 of file Sector.java.

87 {
88 return nextIndexId;
89 }

References nextIndexId.

Referenced by com.runehive.fs.cache.Cache.get().

Here is the caller graph for this function:

Member Data Documentation

◆ cacheId

final int com.runehive.fs.cache.Sector.cacheId
private

The id of the cache this sector is in.

Definition at line 25 of file Sector.java.

Referenced by check(), decode(), getCacheId(), and Sector().

◆ chunk

final int com.runehive.fs.cache.Sector.chunk
private

This sectors chunk.

Definition at line 19 of file Sector.java.

Referenced by check(), decode(), getChunk(), and Sector().

◆ indexId

final int com.runehive.fs.cache.Sector.indexId
private

The id of the index this sector is within.

Definition at line 16 of file Sector.java.

Referenced by check(), decode(), getIndexId(), and Sector().

◆ nextIndexId

final int com.runehive.fs.cache.Sector.nextIndexId
private

The next index within this sector.

Definition at line 22 of file Sector.java.

Referenced by decode(), getNextIndexId(), and Sector().


The documentation for this class was generated from the following file: