|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.data.DataStructureImpl
net.i2p.data.i2np.I2NPMessageImpl
Defines the base message implementation.
Field Summary | |
protected I2PAppContext |
_context
|
static int |
CHECKSUM_LENGTH
|
static long |
DEFAULT_EXPIRATION_MS
|
Fields inherited from interface net.i2p.data.i2np.I2NPMessage |
MAX_ID_VALUE |
Constructor Summary | |
I2NPMessageImpl(I2PAppContext context)
|
Method Summary | |
protected abstract int |
calculateWrittenLength()
calculate the message body's length (not including the header and footer |
long |
getMessageExpiration()
Date after which the message should be dropped (and the associated uniqueId forgotten) |
int |
getMessageSize()
How large the message is, including any checksums |
long |
getUniqueId()
Replay resistent message Id |
int |
readBytes(byte[] data,
int type,
int offset)
|
void |
readBytes(java.io.InputStream in)
Load up the current object with data from the given stream. |
int |
readBytes(java.io.InputStream in,
int type,
byte[] buffer)
Read the body into the data structures, after the initial type byte, using the current class's format as defined by the I2NP specification |
void |
setMessageExpiration(long exp)
|
void |
setUniqueId(long id)
|
byte[] |
toByteArray()
|
int |
toByteArray(byte[] buffer)
write the message to the buffer, returning the number of bytes written |
void |
writeBytes(java.io.OutputStream out)
Write out the data structure to the stream, using the format defined in the I2P data structure specification. |
protected abstract int |
writeMessageBody(byte[] out,
int curIndex)
write the message body to the output array, starting at the given index. |
Methods inherited from class net.i2p.data.DataStructureImpl |
calculateHash, fromBase64, fromByteArray, read, toBase64 |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.i2p.data.i2np.I2NPMessage |
getType, readMessage |
Methods inherited from interface net.i2p.data.DataStructure |
calculateHash, fromBase64, fromByteArray, toBase64 |
Field Detail |
protected I2PAppContext _context
public static final long DEFAULT_EXPIRATION_MS
public static final int CHECKSUM_LENGTH
Constructor Detail |
public I2NPMessageImpl(I2PAppContext context)
Method Detail |
public void readBytes(java.io.InputStream in) throws DataFormatException, java.io.IOException
DataStructure
readBytes
in interface DataStructure
in
- stream to read from
java.io.IOException
- if there was a problem reading the stream
DataFormatException
- if the data is improperly formattedpublic int readBytes(java.io.InputStream in, int type, byte[] buffer) throws I2NPMessageException, java.io.IOException
I2NPMessage
readBytes
in interface I2NPMessage
in
- stream to read fromtype
- I2NP message typebuffer
- scratch buffer to be used when reading and parsing
I2NPMessageException
- if the stream doesn't contain a valid message
that this class can read.
java.io.IOException
- if there is a problem reading from the streampublic int readBytes(byte[] data, int type, int offset) throws I2NPMessageException, java.io.IOException
readBytes
in interface I2NPMessage
I2NPMessageException
java.io.IOException
public void writeBytes(java.io.OutputStream out) throws DataFormatException, java.io.IOException
DataStructure
writeBytes
in interface DataStructure
out
- stream to write to
DataFormatException
- if the data was incomplete or not yet ready to be written
java.io.IOException
- if there was a problem writing to the streampublic long getUniqueId()
getUniqueId
in interface I2NPMessage
public void setUniqueId(long id)
public long getMessageExpiration()
getMessageExpiration
in interface I2NPMessage
public void setMessageExpiration(long exp)
public int getMessageSize()
I2NPMessage
getMessageSize
in interface I2NPMessage
public byte[] toByteArray()
toByteArray
in interface DataStructure
toByteArray
in class DataStructureImpl
public int toByteArray(byte[] buffer)
I2NPMessage
toByteArray
in interface I2NPMessage
protected abstract int calculateWrittenLength()
protected abstract int writeMessageBody(byte[] out, int curIndex) throws I2NPMessageException
I2NPMessageException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |