public class TransactionID extends Object
Modifier and Type | Field and Description |
---|---|
private Object |
applicationData
Any object that the application would like to correlate to a transaction.
|
private int |
hashCode
A hashcode for hashtable storage.
|
private static Random |
random
The object to use to generate the rightmost 8 bytes of the id.
|
static int |
RFC3489_TRANSACTION_ID_LENGTH
RFC3489 Transaction ID length.
|
static int |
RFC5389_TRANSACTION_ID_LENGTH
RFC5289 Transaction ID length.
|
private byte[] |
transactionID
The id itself
|
Modifier | Constructor and Description |
---|---|
private |
TransactionID()
Limits access to TransactionID instantiation.
|
private |
TransactionID(boolean rfc3489Compatibility)
Limits access to TransactionID instantiation.
|
Modifier and Type | Method and Description |
---|---|
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().
|
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().
|
static TransactionID |
createTransactionID(StunStack stunStack,
byte[] transactionID)
Returns a TransactionID instance for the specified id.
|
boolean |
equals(byte[] targetID)
Compares the specified byte array with this transaction id.
|
boolean |
equals(Object obj)
Compares two TransactionID objects.
|
private static void |
generateTransactionID(TransactionID tid,
int nb)
Generates a random transaction ID
|
Object |
getApplicationData()
Returns whatever applicationData was previously stored in this
ID.
|
byte[] |
getBytes()
Returns the transaction id byte array (length 12 or 16 if RFC3489
compatible).
|
int |
hashCode()
Returns the first four bytes of the transactionID to ensure proper
retrieval from hashtables.
|
boolean |
isRFC3489Compatible()
If the transaction is compatible with RFC3489 (16 bytes).
|
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.
|
String |
toString()
Returns a string representation of the ID
|
static String |
toString(byte[] transactionID)
Returns a string representation of the ID
|
public static final int RFC5389_TRANSACTION_ID_LENGTH
public static final int RFC3489_TRANSACTION_ID_LENGTH
private final byte[] transactionID
private Object applicationData
private static final Random random
private int hashCode
private TransactionID()
private TransactionID(boolean rfc3489Compatibility)
rfc3489Compatibility
- true to create a RFC3489 transaction IDpublic static TransactionID createNewTransactionID()
public static TransactionID createNewRFC3489TransactionID()
private static void generateTransactionID(TransactionID tid, int nb)
tid
- transaction IDnb
- number of bytes to generatepublic static TransactionID createTransactionID(StunStack stunStack, byte[] transactionID)
stunStack
- the StunStack in the context of which the
request to create a TransactionID is being madetransactionID
- the value of the ID.public byte[] getBytes()
public boolean isRFC3489Compatible()
public boolean equals(Object obj)
public boolean equals(byte[] targetID)
targetID
- the id to compare with ours.public int hashCode()
public String toString()
public static String toString(byte[] transactionID)
transactionID
- the transaction ID to convert into String.public void setApplicationData(Object applicationData)
StunClientTransaction
).applicationData
- a reference to the Object
that the
application would like to correlate to the transaction represented by
this ID.Copyright © 2018. All rights reserved.