|
LimeWire Consolidated API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.limewire.io.GUID
public class GUID
A 16-byte globally unique ID. Immutable.
Let the bytes of a GUID G be labelled G[0]..G[15]. All bytes are unsigned. Let a "short" be a 2 byte little-endian** unsigned number. Let AB be the short formed by concatenating bytes A and B, with B being the most significant byte. LimeWire GUID's have the following properties:
As of 9/2004, LimeWire GUIDs used to be marked as such:
| Nested Class Summary | |
|---|---|
static class |
GUID.GUIDByteComparator
Compares 16-byte arrays (raw GUIDs) lexically. |
static class |
GUID.GUIDComparator
Compares GUID's lexically. |
static class |
GUID.TimedGUID
Simply couples a GUID with a timestamp. |
| Field Summary | |
|---|---|
static Comparator<byte[]> |
GUID_BYTE_COMPARATOR
|
static Comparator<GUID> |
GUID_COMPARATOR
|
| Constructor Summary | |
|---|---|
GUID()
Creates a new Globally Unique Identifier (GUID). |
|
GUID(byte[] bytes)
Creates a new GUID instance with the specified array of unique bytes. |
|
GUID(String hexString)
Creates a GUID from a hex string. |
|
| Method Summary | |
|---|---|
static byte[] |
addressEncodeGuid(byte[] ret,
byte[] ip,
int port)
Modifies the input guid by address encoding it with the ip and port. |
static boolean |
addressesMatch(byte[] guidBytes,
byte[] ip,
int port)
|
boolean |
addressesMatch(byte[] ip,
int port)
Same as addressesMatch(this.bytes, ....) |
byte[] |
bytes()
Warning: this exposes the rep! Do not modify returned value. |
int |
compareTo(GUID o)
Compares this GUID to o, lexically. |
boolean |
equals(Object o)
|
static byte[] |
fromHexString(String sguid)
Create a GUID bytes from a hex string version. |
String |
getIP()
Same as getIP(this.bytes) |
static String |
getIP(byte[] guidBytes)
Gets bytes 0-4 as a dotted ip address. |
int |
getPort()
Same as getPort(this.bytes) |
static int |
getPort(byte[] guidBytes)
Gets bytes 13-14 as a port. |
int |
hashCode()
|
boolean |
isLimeGUID()
Same as isLimeGUID(this.bytes) |
static boolean |
isLimeGUID(byte[] bytes)
Returns true if this is a specially marked LimeWire GUID. |
boolean |
isLimeRequeryGUID()
Same is isLimeRequeryGUID(this.bytes) |
static boolean |
isLimeRequeryGUID(byte[] bytes)
Returns true if this is a specially marked Requery GUID from any version of LimeWire. |
static boolean |
isLimeRequeryGUID(byte[] bytes,
int version)
Returns true if this is a specially marked LimeWire Requery GUID. |
boolean |
isLimeRequeryGUID(int version)
Same as isLimeRequeryGUID(this.bytes, version) |
static byte[] |
makeAddressEncodedGuid(byte[] ip,
int port)
Create a guid with an ip and port encoded within. |
static byte[] |
makeGuid()
Returns the bytes for a new GUID. |
static byte[] |
makeGuidRequery()
|
boolean |
matchesIP(byte[] bytes)
Same as matchesIP(this.bytes) |
static boolean |
matchesIP(byte[] ipBytes,
byte[] guidBytes)
Gets bytes 0-4 as a dotted ip address. |
static long |
readTimeStamp(byte[] guid)
|
static void |
timeStampGuid(byte[] guid)
encodes the current time in seconds in the guid. |
String |
toHexString()
Create a hex version of a GUID for compact display and storage Note that the client guid should be read in with the Integer.parseByte(String s, int radix) call like this in reverse |
static String |
toHexString(byte[] guid)
Returns a hex string of the guid bytes. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Comparator<GUID> GUID_COMPARATOR
public static final Comparator<byte[]> GUID_BYTE_COMPARATOR
| Constructor Detail |
|---|
public GUID()
public GUID(byte[] bytes)
bytes - the array of unique bytespublic GUID(String hexString)
IllegalArgumentException - if the string is invalid, see fromHexString(String).| Method Detail |
|---|
public static byte[] makeGuid()
public static byte[] makeGuidRequery()
public static void timeStampGuid(byte[] guid)
public static long readTimeStamp(byte[] guid)
public static byte[] makeAddressEncodedGuid(byte[] ip,
int port)
throws IllegalArgumentException
IllegalArgumentException - thrown if ip.length != 4 or if the
port is not a valid value.
public static byte[] addressEncodeGuid(byte[] ret,
byte[] ip,
int port)
throws IllegalArgumentException
IllegalArgumentException - thrown if ip.length != 4 or if the
port is not a valid value or if the size of the input guid is not 16.public boolean isLimeGUID()
public boolean isLimeRequeryGUID(int version)
public boolean isLimeRequeryGUID()
public boolean addressesMatch(byte[] ip,
int port)
throws IllegalArgumentException
IllegalArgumentExceptionpublic String getIP()
public boolean matchesIP(byte[] bytes)
public int getPort()
public static boolean isLimeGUID(byte[] bytes)
public static boolean isLimeRequeryGUID(byte[] bytes)
public static boolean isLimeRequeryGUID(byte[] bytes,
int version)
version - The version of RequeryGUID you want to test for. 0 for
requeries up to 2.2.4, 1 for requeries between 2.2.4 and all 2.3s, and 2
for current requeries....
public static boolean addressesMatch(byte[] guidBytes,
byte[] ip,
int port)
throws IllegalArgumentException
IllegalArgumentException - thrown if ip.length != 4 or if the
port is not a valid value.public static String getIP(byte[] guidBytes)
public static boolean matchesIP(byte[] ipBytes,
byte[] guidBytes)
public static int getPort(byte[] guidBytes)
public int compareTo(GUID o)
compareTo in interface Comparable<GUID>public boolean equals(Object o)
public int hashCode()
public byte[] bytes()
public String toString()
public String toHexString()
public static String toHexString(byte[] guid)
public static byte[] fromHexString(String sguid) throws IllegalArgumentException
IllegalArgumentException - if sguid is
not of the proper format.
|
LimeWire Consolidated API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||