-
Notifications
You must be signed in to change notification settings - Fork 1
/
ReadingByteBuffer.java
119 lines (102 loc) · 2.63 KB
/
ReadingByteBuffer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
*
* * Copyright (c) 2021. Zyonic Software - Niklas Griese
* * This File, its contents and by extention the corresponding project is property of Zyonic Software and may not be used without explicit permission to do so.
* *
* * contact(at)zyonicsoftware.com
*
*/
package com.zyonicsoftware.minereaper.signal.buffer;
import org.boon.primitive.InputByteArray;
import java.util.UUID;
/**
* @author Niklas Griese
* @see InputByteArray
* @see java.nio.Buffer
* @see java.io.Serializable
*/
public class ReadingByteBuffer {
/**
* @implNote init an final InputByteArray
*/
private final InputByteArray inputByteArray;
public ReadingByteBuffer(final byte... bytes) {
this.inputByteArray = new InputByteArray(bytes);
}
/**
* @return a boolean value from InputByteArray
*/
public boolean readBoolean() {
// read boolean
return this.inputByteArray.readBoolean();
}
/**
* @return a byte value from InputByteArray
*/
public byte readByte() {
// read byte
return this.inputByteArray.readByte();
}
/**
* @return a byte array value from InputByteArray
*/
public byte[] readBytes() {
return this.inputByteArray.readLargeByteArray();
}
/**
* @return a short value from InputByteArray
*/
public short readShort() {
// read short
return this.inputByteArray.readShort();
}
/**
* @return an int value from InputByteArray
*/
public int readInt() {
// read int
return this.inputByteArray.readInt();
}
/**
* @return a long value from InputByteArray
*/
public long readLong() {
// read long
return this.inputByteArray.readLong();
}
/**
* @return a float value from InputByteArray
*/
public float readFloat() {
// read float
return this.inputByteArray.readFloat();
}
/**
* @return a double value from InputByteArray
*/
public double readDouble() {
// read double
return this.inputByteArray.readDouble();
}
/**
* @return a char value from InputByteArray
*/
public char readChar() {
// read chars
return this.inputByteArray.readChar();
}
/**
* @return a big string value from InputByteArray
*/
public String readLargeString() {
// read string
return this.inputByteArray.readLargeString();
}
/**
* @return a uuid value above the readLargeString method
*/
public UUID readUUID() {
// read uuid
return UUID.fromString(this.readLargeString());
}
}