public abstract class I2CPMessageImpl extends DataStructureImpl implements I2CPMessage
Constructor and Description |
---|
I2CPMessageImpl() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
doReadMessage(InputStream buf,
int size)
Read in the payload part of the message (after the initial 4 byte size and 1
byte type)
|
protected abstract byte[] |
doWriteMessage()
Write out the payload part of the message (not including the 4 byte size and
1 byte type)
|
void |
readBytes(InputStream in)
Load up the current object with data from the given stream.
|
void |
readMessage(InputStream in)
Validate the type and size of the message, and then read the message into the data structures.
|
void |
readMessage(InputStream in,
int length,
int type)
Read the body into the data structures
|
SessionId |
sessionId()
Return the SessionId for this type of message.
|
void |
writeBytes(OutputStream out)
Write out the data structure to the stream, using the format defined in the
I2P data structure specification.
|
void |
writeMessage(OutputStream out)
Write out the full message to the stream, including the 4 byte size and 1
byte type header.
|
calculateHash, fromBase64, fromByteArray, read, toBase64, toByteArray
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getType
calculateHash, fromBase64, fromByteArray, toBase64, toByteArray
public void readMessage(InputStream in) throws I2CPMessageException, IOException
readMessage
in interface I2CPMessage
in
- stream to read fromIOException
I2CPMessageException
- if the stream doesn't contain a valid message
that this class can read.public void readMessage(InputStream in, int length, int type) throws I2CPMessageException, IOException
readMessage
in interface I2CPMessage
length
- number of bytes in the message payloadin
- stream to read fromtype
- type of message (should equal getType())IOException
I2CPMessageException
- if the stream doesn't contain a valid message
that this class can read.protected abstract void doReadMessage(InputStream buf, int size) throws I2CPMessageException, IOException
buf
- InputStreamsize
- payload sizeI2CPMessageException
IOException
protected abstract byte[] doWriteMessage() throws I2CPMessageException, IOException
I2CPMessageException
IOException
public void writeMessage(OutputStream out) throws I2CPMessageException, IOException
writeMessage
in interface I2CPMessage
out
- OutputStreamIOException
I2CPMessageException
- if the current object doesn't have sufficient data
to write a properly formatted message.public void readBytes(InputStream in) throws DataFormatException, IOException
DataStructure
readBytes
in interface DataStructure
in
- stream to read fromDataFormatException
- if the data is improperly formattedIOException
- if there was a problem reading the streampublic void writeBytes(OutputStream out) throws DataFormatException, IOException
DataStructure
writeBytes
in interface DataStructure
out
- stream to write toDataFormatException
- if the data was incomplete or not yet ready to be writtenIOException
- if there was a problem writing to the streampublic SessionId sessionId()
sessionId
in interface I2CPMessage