## net.i2p.data
Interface DataStructure

All Known Subinterfaces:
  I2CPMessage, I2NPMessage

All Known Implementing Classes:
  AbuseReason, AbuseSeverity, Address, Certificate, CreateLeaseSetMessage, CreateSessionMessage, DatabaseLookupMessage, DatabaseSearchReplyMessage, DatabaseStoreMessage, DataMessage, DataStructureImpl, DateMessage, DeliveryInstructions, DeliveryStatusMessage, Destination, DestroySessionMessage, DisconnectMessage, EndPointPrivateKey, EndPointPublicKey, GarlicClove, GarlicMessage, GetDateMessage, Hash, I2CPMessageImpl, I2NPMessageImpl, Lease, LeaseSet, LeaseSetKeys, MessageId, MessagePayloadMessage, MessageStatusMessage, Payload, PrivateKey, PublicKey, ReceiveMessageBeginMessage, ReceiveMessageEndMessage, ReportAbuseMessage, RequestLeaseSetMessage, RouterAddress, RouterIdentity, RouterInfo, SendMessageMessage, SessionConfig, SessionId, SessionKey, SessionStatusMessage, SetDateMessage, Signature, SigningPrivateKey, SigningPublicKey, SSUDemo.FooMessage, TunnelBuildMessage, TunnelBuildReplyMessage, TunnelCreateMessage, TunnelCreateStatusMessage, TunnelDataMessage, TunnelGatewayMessage, TunnelId, TunnelSessionKey, TunnelSettings, TunnelSigningPrivateKey, TunnelSigningPublicKey, TunnelVerificationStructure

    public interface DataStructure

Defines the class as a standard object with particular bit representation, exposing methods to read and write that representation.

Author:
  jrandom

Method Summary
`Hash` `calculateHash()` Calculate the SHA256 value of this object (useful for a few scenarios)
`void` `fromBase64(java.lang.String data)` Load the structure from the base 64 encoded data provided
`void` `fromByteArray(byte[] data)`
`void` `readBytes(java.io.InputStream in)` Load up the current object with data from the given stream.
`java.lang.String` `toBase64()` render the structure into modified base 64 notation
`byte[]` `toByteArray()`
`void` `writeBytes(java.io.OutputStream out)` Write out the data structure to the stream, using the format defined in the I2P data structure specification.

Method Detail

### readBytes

    void readBytes(java.io.InputStream in)
                   throws DataFormatException,
                          java.io.IOException

  Load up the current object with data from the given stream. Data loaded this way must match the I2P data structure specification.

  Parameters:
    `in` - stream to read from
  Throws:
    `DataFormatException` - if the data is improperly formatted
    `java.io.IOException` - if there was a problem reading the stream

### writeBytes

    void writeBytes(java.io.OutputStream out)
                    throws DataFormatException,
                           java.io.IOException

  Write out the data structure to the stream, using the format defined in the I2P data structure specification.

  Parameters:
    `out` - stream to write to
  Throws:
    `DataFormatException` - if the data was incomplete or not yet ready to be written
    `java.io.IOException` - if there was a problem writing to the stream

### toBase64

    java.lang.String toBase64()

  render the structure into modified base 64 notation

  Returns:
    null on error

### fromBase64

    void fromBase64(java.lang.String data)
                    throws DataFormatException

  Load the structure from the base 64 encoded data provided

  Throws:
    `DataFormatException`

### toByteArray

    byte[] toByteArray()

### fromByteArray

    void fromByteArray(byte[] data)
                       throws DataFormatException

  Throws:
    `DataFormatException`

### calculateHash

    Hash calculateHash()

  Calculate the SHA256 value of this object (useful for a few scenarios)

  Returns:
    SHA256 hash, or null if there were problems (data format or io errors)