net.i2p.data.i2np

## Class GarlicClove

- java.lang.Object
- - net.i2p.data.DataStructureImpl
  - - net.i2p.data.i2np.GarlicClove

- All Implemented Interfaces:
    Serializable, DataStructure

      public class GarlicClove
      extends DataStructureImpl

  Contains one deliverable message encrypted to a router along with instructions and a certificate 'paying for' the delivery. Note that certificates are always the null certificate at this time, others are unimplemented.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `GarlicClove(I2PAppContext context)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object obj)`
    `int` | `estimateSize()`
    `Certificate` | `getCertificate()`
    `long` | `getCloveId()`
    `I2NPMessage` | `getData()`
    `long` | `getExpiration()`
    `DeliveryInstructions` | `getInstructions()`
    `int` | `getSizeRatchet()`
    `int` | `hashCode()`
    `int` | `readBytes(byte[] source, int offset)`
    `void` | `readBytesRatchet(byte[] source, int offset, int len)` Short format for ECIES-Ratchet, saves 22 bytes.
    `void` | `setCertificate(Certificate cert)`
    `void` | `setCloveId(long id)`
    `void` | `setData(I2NPMessage msg)`
    `void` | `setExpiration(long exp)`
    `void` | `setInstructions(DeliveryInstructions instr)`
    `byte[]` | `toByteArray()` Convert the structure to a byte array.
    `String` | `toString()`
    `int` | `writeBytesRatchet(byte[] tgt, int offset)` Short format for ECIES-Ratchet, saves 22 bytes.

    - ### Methods inherited from class net.i2p.data.DataStructureImpl

      `calculateHash, fromBase64, fromByteArray, read, toBase64`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface net.i2p.data.DataStructure

      `readBytes, writeBytes`

- - ### Constructor Detail

    - #### GarlicClove

          public GarlicClove(I2PAppContext context)

  - ### Method Detail

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### estimateSize

          public int estimateSize()

    - #### getCertificate

          public Certificate getCertificate()

    - #### getCloveId

          public long getCloveId()

    - #### getData

          public I2NPMessage getData()

    - #### getExpiration

          public long getExpiration()

    - #### getInstructions

          public DeliveryInstructions getInstructions()

    - #### getSizeRatchet

          public int getSizeRatchet()

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### readBytes

          public int readBytes(byte[] source,
                               int offset)
                        throws DataFormatException

      Returns:
        length read
      Throws:
        `DataFormatException`

    - #### readBytesRatchet

          public void readBytesRatchet(byte[] source,
                                       int offset,
                                       int len)
                                throws DataFormatException

      Short format for ECIES-Ratchet, saves 22 bytes. NTCP2-style header, no ID, no separate expiration, no cert.
      Throws:
        `DataFormatException`

    - #### setCertificate

          public void setCertificate(Certificate cert)

    - #### setCloveId

          public void setCloveId(long id)

    - #### setData

          public void setData(I2NPMessage msg)

    - #### setExpiration

          public void setExpiration(long exp)

    - #### setInstructions

          public void setInstructions(DeliveryInstructions instr)

    - #### toByteArray

          public byte[] toByteArray()

      Description copied from interface: `DataStructure`
      Convert the structure to a byte array.
      Specified by:
        `toByteArray` in interface `DataStructure`
      Overrides:
        `toByteArray` in class `DataStructureImpl`
      Returns:
        may be null if data is not set

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### writeBytesRatchet

          public int writeBytesRatchet(byte[] tgt,
                                       int offset)

      Short format for ECIES-Ratchet, saves 22 bytes. NTCP2-style header, no ID, no separate expiration, no cert.
      Returns:
        new offset