public interface DataStructure
Do not reuse objects. Many of modifying methods contain checks to prevent altering a DataStructure after it is initialized. This protects the netdb, messages that contain DataStructures, caches, and the object itself from simple causes of corruption, by throwing IllegalStateExceptions. These checks are not necessarily thread-safe, and are not guaranteed to catch all possible means of corruption. Beware of other avenues of corruption, such as directly modifying data stored in byte[] objects.
Modifier and Type | Method and Description |
---|---|
Hash |
calculateHash()
Calculate the SHA256 value of this object (useful for a few scenarios)
|
void |
fromBase64(String data)
Load the structure from the base 64 encoded data provided
Warning - many classes will throw IllegalStateException if data is already set.
|
void |
fromByteArray(byte[] data)
Load the structure from the data provided
Warning - many classes will throw IllegalStateException if data is already set.
|
void |
readBytes(InputStream in)
Load up the current object with data from the given stream.
|
String |
toBase64()
render the structure into modified base 64 notation
|
byte[] |
toByteArray() |
void |
writeBytes(OutputStream out)
Write out the data structure to the stream, using the format defined in the
I2P data structure specification.
|
void readBytes(InputStream in) throws DataFormatException, IOException
in
- stream to read fromDataFormatException
- if the data is improperly formattedIOException
- if there was a problem reading the streamvoid writeBytes(OutputStream out) throws DataFormatException, IOException
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 streamString toBase64()
void fromBase64(String data) throws DataFormatException
DataFormatException
byte[] toByteArray()
void fromByteArray(byte[] data) throws DataFormatException
DataFormatException
Hash calculateHash()