Package 

Class TransactionID

  • All Implemented Interfaces:

    
    public class TransactionID
    
                        

    This class encapsulates a STUN transaction ID. It is useful for storing transaction IDs in collection objects as it implements the equals method. It also provides a utility for creating unique transaction IDs.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      Object getApplicationData() Returns whatever applicationData was previously stored in this ID.
      void setApplicationData(Object applicationData) Stores applicationData in this ID so that we can refer back to it if we ever need to at a later stage (e.g.
      static TransactionID createNewTransactionID() Creates a transaction id object.
      static TransactionID createNewRFC3489TransactionID() Creates a RFC3489 transaction id object.
      static TransactionID createTransactionID(StunStack stunStack, Array<byte> transactionID) Returns a TransactionID instance for the specified id.
      Array<byte> getBytes() Returns the transaction id byte array (length 12 or 16 if RFC3489 compatible).
      boolean isRFC3489Compatible() If the transaction is compatible with RFC3489 (16 bytes).
      boolean equals(Object obj) Compares two TransactionID objects.
      boolean equals(Array<byte> targetID) Compares the specified byte array with this transaction id.
      int hashCode() Returns the first four bytes of the transactionID to ensure proper retrieval from hashtables.
      String toString() Returns a string representation of the ID
      static String toString(Array<byte> transactionID) Returns a string representation of the ID
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • setApplicationData

         void setApplicationData(Object applicationData)

        Stores applicationData in this ID so that we can refer back to it if we ever need to at a later stage (e.g. when receiving a response to a StunClientTransaction).

        Parameters:
        applicationData - a reference to the Object that the application would like to correlate to the transaction represented by this ID.
      • createNewTransactionID

         static TransactionID createNewTransactionID()

        Creates a transaction id object.The transaction id itself is generated using the following algorithm: The first 6 bytes of the id are given the value of System.currentTimeMillis(). Putting the right most bits first so that we get a more optimized equals() method.

      • createNewRFC3489TransactionID

         static TransactionID createNewRFC3489TransactionID()

        Creates a RFC3489 transaction id object.The transaction id itself is generated using the following algorithm: The first 8 bytes of the id are given the value of System.currentTimeMillis(). Putting the right most bits first so that we get a more optimized equals() method.

      • createTransactionID

         static TransactionID createTransactionID(StunStack stunStack, Array<byte> transactionID)

        Returns a TransactionID instance for the specified id. If transactionID is the ID of a client or a server transaction already known to the stack, then this method would return a reference to that transaction's instance so that we could use it to for storing application data.

        Parameters:
        stunStack - the StunStack in the context of which the request to create a TransactionID is being made
        transactionID - the value of the ID.
      • getBytes

         Array<byte> getBytes()

        Returns the transaction id byte array (length 12 or 16 if RFC3489 compatible).

      • isRFC3489Compatible

         boolean isRFC3489Compatible()

        If the transaction is compatible with RFC3489 (16 bytes).

      • equals

         boolean equals(Object obj)

        Compares two TransactionID objects.

        Parameters:
        obj - the object to compare with.
      • equals

         boolean equals(Array<byte> targetID)

        Compares the specified byte array with this transaction id.

        Parameters:
        targetID - the id to compare with ours.
      • hashCode

         int hashCode()

        Returns the first four bytes of the transactionID to ensure proper retrieval from hashtables.

      • toString

         String toString()

        Returns a string representation of the ID

      • toString

         static String toString(Array<byte> transactionID)

        Returns a string representation of the ID

        Parameters:
        transactionID - the transaction ID to convert into String.