net.i2p.data.i2np

## Class DeliveryInstructions

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

- All Implemented Interfaces:
    Serializable, DataStructure

      public class DeliveryInstructions
      extends DataStructureImpl

  Contains the delivery instructions for garlic cloves. Generic "delivery instructions" are used both in tunnel messages and in garlic cloves, with slight differences. However, the tunnel message generator TrivialPreprocessor and reader FragmentHandler do not use this class, the reading and writing is handled inline there.
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DELIVERY_MODE_DESTINATION`
    `static int` | `DELIVERY_MODE_LOCAL`
    `static int` | `DELIVERY_MODE_ROUTER`
    `static int` | `DELIVERY_MODE_TUNNEL`
    `static DeliveryInstructions` | `LOCAL` Immutable local instructions, no options

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DeliveryInstructions()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static DeliveryInstructions` | `create(byte[] data, int offset)` Returns immutable local instructions, or new
    `boolean` | `equals(Object obj)`
    `int` | `getDeliveryMode()` default -1
    `Hash` | `getDestination()` default null
    `Hash` | `getRouter()` default null
    `int` | `getSize()`
    `TunnelId` | `getTunnelId()` default null
    `int` | `hashCode()`
    `int` | `readBytes(byte[] data, int offset)`
    `void` | `setDeliveryMode(int mode)`
    `void` | `setDestination(Hash dest)` required for DESTINATION
    `void` | `setRouter(Hash router)` required for ROUTER or TUNNEL
    `void` | `setTunnelId(TunnelId id)` required for TUNNEL
    `String` | `toString()`
    `int` | `writeBytes(byte[] target, int offset)`

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

      `calculateHash, fromBase64, fromByteArray, read, toBase64, toByteArray`

    - ### 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`

- - ### Field Detail

    - #### DELIVERY_MODE_DESTINATION

          public static final int DELIVERY_MODE_DESTINATION

      See Also:
        Constant Field Values

    - #### DELIVERY_MODE_LOCAL

          public static final int DELIVERY_MODE_LOCAL

      See Also:
        Constant Field Values

    - #### DELIVERY_MODE_ROUTER

          public static final int DELIVERY_MODE_ROUTER

      See Also:
        Constant Field Values

    - #### DELIVERY_MODE_TUNNEL

          public static final int DELIVERY_MODE_TUNNEL

      See Also:
        Constant Field Values

    - #### LOCAL

          public static final DeliveryInstructions LOCAL

      Immutable local instructions, no options

  - ### Constructor Detail

    - #### DeliveryInstructions

          public DeliveryInstructions()

  - ### Method Detail

    - #### create

          public static DeliveryInstructions create(byte[] data,
                                                    int offset)
                                             throws DataFormatException

      Returns immutable local instructions, or new
      Throws:
        `DataFormatException`

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### getDeliveryMode

          public int getDeliveryMode()

      default -1

    - #### getDestination

          public Hash getDestination()

      default null

    - #### getRouter

          public Hash getRouter()

      default null

    - #### getSize

          public int getSize()

    - #### getTunnelId

          public TunnelId getTunnelId()

      default null

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### readBytes

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

      Throws:
        `DataFormatException`

    - #### setDeliveryMode

          public void setDeliveryMode(int mode)

      Parameters:
        `mode` - 0-3

    - #### setDestination

          public void setDestination(Hash dest)

      required for DESTINATION

    - #### setRouter

          public void setRouter(Hash router)

      required for ROUTER or TUNNEL

    - #### setTunnelId

          public void setTunnelId(TunnelId id)

      required for TUNNEL

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### writeBytes

          public int writeBytes(byte[] target,
                                int offset)

      Returns:
        the number of bytes written to the target