RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
Sector.java
1package com.osroyale.fs.cache;
2
3import com.google.common.base.Preconditions;
4import com.osroyale.fs.util.ByteBufferUtil;
5
6import java.nio.ByteBuffer;
7
45
46public final class Sector {
47
49 private final int indexId;
50
52 private final int chunk;
53
55 private final int nextIndexId;
56
58 private final int cacheId;
59
71 private Sector(int indexId, int chunk, int nextIndexId, int cacheId) {
72 this.indexId = indexId;
73 this.chunk = chunk;
74 this.nextIndexId = nextIndexId;
75 this.cacheId = cacheId;
76 }
77
87 public static Sector decode(ByteBuffer buffer, byte[] data, int offset, int length) {
88 int indexId = buffer.getShort() & 0xFFFF;
89 int chunk = buffer.getShort() & 0xFFFF;
90 int nextIndexId = ByteBufferUtil.getMedium(buffer);
91 int cacheId = buffer.get() & 0xFF;
92 buffer.get(data, offset, length);
93 return new Sector(indexId, chunk, nextIndexId, cacheId);
94 }
95
103 public void check(int cacheId, int indexId, int chunk) {
104 Preconditions.checkArgument(this.cacheId == cacheId);
105 Preconditions.checkArgument(this.indexId == indexId);
106 Preconditions.checkArgument(this.chunk == chunk);
107 }
108
110 public int getIndexId() {
111 return indexId;
112 }
113
115 public int getChunk() {
116 return chunk;
117 }
118
120 public int getNextIndexId() {
121 return nextIndexId;
122 }
123
125 public int getCacheId() {
126 return cacheId;
127 }
128
129}
void check(int cacheId, int indexId, int chunk)
Definition Sector.java:103
static Sector decode(ByteBuffer buffer, byte[] data, int offset, int length)
Definition Sector.java:87