public interface DataStructure
DataStructure provides the foundation for all I2P protocol data:
Core Operations:
readBytes(InputStream) - Deserialize from binary streamwriteBytes(OutputStream) - Serialize to binary streamIntegrity Protection:
Usage Throughout I2P:
Implementation Guidelines:
Security Considerations:
Performance Aspects:
Common Implementations:
DataStructureImpl - Base class with common functionalitySimpleDataStructure - Fixed-size byte array structuresDatabaseEntry - NetDb-storable objects with signatures| 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 provided base64 string.
|
void |
fromByteArray(byte[] data)
Load's 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()
Convert the structure to a byte array.
|
void |
writeBytes(OutputStream out)
Write out the data structure to the stream, using the format defined in the
I2P data structure specification.
|
Hash calculateHash()
void fromBase64(String data) throws DataFormatException
data - base64 encoded string to load fromDataFormatException - if the data format is invalidvoid fromByteArray(byte[] data)
throws DataFormatException
data - byte array to load fromDataFormatException - if the data format is invalidvoid readBytes(InputStream in) throws DataFormatException, IOException
in - stream to read fromDataFormatException - if the data is improperly formattedIOException - if there was a problem reading the streamString toBase64()
byte[] toByteArray()
void 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 stream