net.i2p.data
Class TunnelId

java.lang.Object
  extended by net.i2p.data.DataStructureImpl
      extended by net.i2p.data.TunnelId
All Implemented Interfaces:
DataStructure

public class TunnelId
extends DataStructureImpl

Defines the tunnel ID that messages are passed through on a set of routers. This is not globally unique, but must be unique on each router making up the tunnel (otherwise they would get confused and send messages down the wrong one).

Author:
jrandom

Field Summary
static TunnelId INVALID
           
static long MAX_ID_VALUE
           
static int TYPE_INBOUND
           
static int TYPE_OUTBOUND
           
static int TYPE_PARTICIPANT
           
static int TYPE_UNSPECIFIED
           
 
Constructor Summary
TunnelId()
           
TunnelId(long id)
           
TunnelId(long id, int type)
           
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 long getTunnelId()
           
 int getType()
          is this tunnel inbound, outbound, or a participant (kept in memory only and used only for the router).s
 int hashCode()
           
 void readBytes(java.io.InputStream in)
          Load up the current object with data from the given stream.
 void setTunnelId(long id)
           
 void setType(int type)
           
 java.lang.String toString()
           
 int writeBytes(byte[] target, int offset)
           
 void writeBytes(java.io.OutputStream out)
          Write out the data structure to the stream, using the format defined in the I2P data structure specification.
 
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
 

Field Detail

MAX_ID_VALUE

public static final long MAX_ID_VALUE
See Also:
Constant Field Values

TYPE_UNSPECIFIED

public static final int TYPE_UNSPECIFIED
See Also:
Constant Field Values

TYPE_INBOUND

public static final int TYPE_INBOUND
See Also:
Constant Field Values

TYPE_OUTBOUND

public static final int TYPE_OUTBOUND
See Also:
Constant Field Values

TYPE_PARTICIPANT

public static final int TYPE_PARTICIPANT
See Also:
Constant Field Values

INVALID

public static final TunnelId INVALID
Constructor Detail

TunnelId

public TunnelId()

TunnelId

public TunnelId(long id)

TunnelId

public TunnelId(long id,
                int type)
Method Detail

getTunnelId

public long getTunnelId()

setTunnelId

public void setTunnelId(long id)

getType

public int getType()
is this tunnel inbound, outbound, or a participant (kept in memory only and used only for the router).s

Returns:
type of tunnel (per constants TYPE_UNSPECIFIED, TYPE_INBOUND, TYPE_OUTBOUND, TYPE_PARTICIPANT)

setType

public void setType(int type)

readBytes

public void readBytes(java.io.InputStream in)
               throws DataFormatException,
                      java.io.IOException
Description copied from interface: DataStructure
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

public void writeBytes(java.io.OutputStream out)
                throws DataFormatException,
                       java.io.IOException
Description copied from interface: DataStructure
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

writeBytes

public int writeBytes(byte[] target,
                      int offset)
               throws DataFormatException
Throws:
DataFormatException

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object