java.lang.Object
net.i2p.data.ByteArray
org.klomp.snark.dht.MsgID
- All Implemented Interfaces:
Serializable, Comparable<ByteArray>
Used for both incoming and outgoing message IDs.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intLongest token accepted in a message.private static final intBEP 5: 2 bytes, incremented.private static final longPinned for serialized-form compatibility.Constructor Summary
ConstructorsConstructorDescriptionMsgID(byte[] data) Create an incoming message ID from received data.MsgID(I2PAppContext ctx) Create an outgoing message ID with a random value.Method Summary
Methods inherited from class ByteArray
compareTo, equals, getData, getOffset, getValid, hashCode, setData, setOffset, setValid, toBase64, toStringModifier and TypeMethodDescriptionfinal intCompares this ByteArray with another ByteArray.final booleanCompares this ByteArray with another object for equality.byte[]getData()Returns the underlying byte array.intReturns the offset into the byte array.intgetValid()Count how many of the bytes in the array are 'valid'.final inthashCode()Hash code based on the underlying byte array data.voidsetData(byte[] data) Sets the underlying byte array.voidsetOffset(int offset) Offset into the byte array.voidsetValid(int valid) Number of valid bytes.final StringtoBase64()Returns this ByteArray as a Base64 encoded string.toString()Returns a string representation of this ByteArray.
Field Details
serialVersionUID
private static final long serialVersionUIDPinned for serialized-form compatibility.- See Also:
MY_TOK_LEN
MAX_TOK_LEN
private static final int MAX_TOK_LENLongest token accepted in a message.- See Also:
Constructor Details
MsgID
Create an outgoing message ID with a random value.- Parameters:
ctx- the I2P application context for random number generation
MsgID
public MsgID(byte[] data) Create an incoming message ID from received data.- Parameters:
data- the message ID bytes- Throws:
IllegalArgumentException- if data exceeds maximum length