public abstract class FastI2NPMessageImpl extends I2NPMessageImpl
I2NPMessageImpl.Builder
Modifier and Type | Field and Description |
---|---|
protected byte |
_checksum |
protected boolean |
_hasChecksum |
_context, _expiration, _log, _uniqueId, CHECKSUM_LENGTH, DEFAULT_EXPIRATION_MS, HEADER_LENGTH
MAX_ID_VALUE, MAX_SIZE
Constructor and Description |
---|
FastI2NPMessageImpl(I2PAppContext context) |
Modifier and Type | Method and Description |
---|---|
int |
readBytes(byte[] data,
int type,
int offset,
int maxLen)
Ignore, but save, the checksum, to be used later if necessary.
|
void |
readBytes(InputStream in)
Deprecated.
unused
|
int |
readBytes(InputStream in,
int type,
byte[] buffer)
Deprecated.
unused
|
int |
toByteArray(byte[] buffer)
If available, use the previously-computed or previously-read checksum for speed
|
protected int |
toByteArrayWithSavedChecksum(byte[] buffer)
Use a previously-computed checksum for speed
|
void |
writeBytes(OutputStream out)
Deprecated.
unused
|
calculateWrittenLength, createMessage, fromRawByteArray, getMessageExpiration, getMessageSize, getRawMessageSize, getUniqueId, readBytes, readMessage, registerBuilder, setMessageExpiration, setUniqueId, toByteArray, toRawByteArray, writeMessageBody
calculateHash, fromBase64, fromByteArray, read, toBase64
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getType, readMessage
calculateHash, fromBase64, fromByteArray, toBase64
public FastI2NPMessageImpl(I2PAppContext context)
public void readBytes(InputStream in) throws DataFormatException, IOException
I2NPMessageImpl
readBytes
in interface DataStructure
readBytes
in class I2NPMessageImpl
in
- stream to read fromUnsupportedOperationException
DataFormatException
- if the data is improperly formattedIOException
- if there was a problem reading the streampublic int readBytes(InputStream in, int type, byte[] buffer) throws I2NPMessageException, IOException
I2NPMessageImpl
Specifically: 1 byte type (if caller didn't read already, as specified by the type param 4 byte ID 8 byte expiration 2 byte size 1 byte checksum size bytes of payload (read by readMessage() in implementation)Unused - All transports provide encapsulation and so we have byte arrays available.
readBytes
in interface I2NPMessage
readBytes
in class I2NPMessageImpl
in
- stream to read from
starting at type if type is < 0 (16 byte header)
starting at ID if type is >= 0 (15 byte header)type
- the message type or -1 if we should read it herebuffer
- temp buffer to useUnsupportedOperationException
I2NPMessageException
- if the stream doesn't contain a valid message
that this class can read.IOException
- if there is a problem reading from the streampublic int readBytes(byte[] data, int type, int offset, int maxLen) throws I2NPMessageException
readBytes
in interface I2NPMessage
readBytes
in class I2NPMessageImpl
maxLen
- read no more than this many bytes from data starting at offset, even if it is longer
This includes the type byte only if type < 0data
- the data, may or may not include the typetype
- I2NP message type. If less than zero, read the type from dataoffset
- where to start
starting at type if type is < 0 (16 byte header)
starting at ID if type is >= 0 (15 byte header)IllegalStateException
- if called twice, to protect saved checksumI2NPMessageException
- if there is no valid messagepublic void writeBytes(OutputStream out) throws DataFormatException, IOException
I2NPMessageImpl
writeBytes
in interface DataStructure
writeBytes
in class I2NPMessageImpl
out
- stream to write toUnsupportedOperationException
DataFormatException
- if the data was incomplete or not yet ready to be writtenIOException
- if there was a problem writing to the streampublic int toByteArray(byte[] buffer)
toByteArray
in interface I2NPMessage
toByteArray
in class I2NPMessageImpl
protected int toByteArrayWithSavedChecksum(byte[] buffer)