Class UUID
- java.lang.Object
-
- totalcross.io.device.bluetooth.UUID
-
public class UUID extends java.lang.ObjectTheUUIDclass defines universally unique identifiers. These 128-bit unsigned integers are guaranteed to be unique across all time and space. Accordingly, an instance of this class is immutable. The Bluetooth specification provides an algorithm describing how a 16-bit or 32-bit UUID could be promoted to a 128-bit UUID. Accordingly, this class provides an interface that assists applications in creating 16-bit, 32-bit, and 128-bit long UUIDs. The methods supported by this class allow equality testing of two UUID objects.The Bluetooth Assigned Numbers document ( http://www.bluetooth.org/assigned-numbers/sdp.htm) defines a large number of UUIDs for protocols and service classes. The table below provides a short list of the most common UUIDs defined in the Bluetooth Assigned Numbers document.
Name Value Size Base UUID Value (Used in promoting 16-bit and 32-bit UUIDs to 128-bit UUIDs) 0x0000000000001000800000805F9B34FB 128-bit SDP 0x0001 16-bit RFCOMM 0x0003 16-bit OBEX 0x0008 16-bit HTTP 0x000C 16-bit L2CAP 0x0100 16-bit BNEP 0x000F 16-bit Serial Port 0x1101 16-bit ServiceDiscoveryServerServiceClassID 0x1000 16-bit BrowseGroupDescriptorServiceClassID 0x1001 16-bit PublicBrowseGroup 0x1002 16-bit OBEX Object Push Profile 0x1105 16-bit OBEX File Transfer Profile 0x1106 16-bit Personal Area Networking User 0x1115 16-bit Network Access Point 0x1116 16-bit Group Network 0x1117 16-bit - Since:
- TotalCross 1.2
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object value)Determines if twoUUIDs are equal.inthashCode()Computes the hash code for this object.java.lang.StringtoString()Returns the string representation of the 128-bit UUID object.
-
-
-
Constructor Detail
-
UUID
public UUID(long uuidValue)
Creates aUUIDobject fromlongvalueuuidValue. A UUID is defined as an unsigned integer whose value can range from [0 to 2128-1]. However, this constructor allows only those values that are in the range of [0 to 232 -1]. Negative values and values in the range of [232, 263 -1] are not allowed and will cause anIllegalArgumentExceptionto be thrown.- Parameters:
uuidValue- the 16-bit or 32-bit value of the UUID- Throws:
java.lang.IllegalArgumentException- ifuuidValueis not in the range [0, 232 -1]- Since:
- TotalCross 1.2
-
UUID
public UUID(java.lang.String uuidValue, boolean shortUUID)Creates aUUIDobject from the string provided. The characters in the string must be from the hexadecimal set [0-9, a-f, A-F]. It is important to note that the prefix "0x" generally used for hex representation of numbers is not allowed. If the string does not have characters from the hexadecimal set, an exception will be thrown. The string length has to be positive and less than or equal to 32. A string length that exceeds 32 is illegal and will cause an exception. Finally, anullinput is also considered illegal and causes an exception.If
shortUUIDistrue,uuidValuerepresents a 16-bit or 32-bit UUID. IfuuidValueis in the range 0x0000 to 0xFFFF then this constructor will create a 16-bit UUID. IfuuidValueis in the range 0x000010000 to 0xFFFFFFFF, then this constructor will create a 32-bit UUID. Therefore,uuidValuemay only be 8 characters long.On the other hand, if
shortUUIDisfalse, thenuuidValuerepresents a 128-bit UUID. Therefore,uuidValuemay only be 32 character long.- Parameters:
uuidValue- the string representation of a 16-bit, 32-bit or 128-bit UUIDshortUUID- indicates the size of the UUID to be constructed;trueis used to indicate short UUIDs, i.e. either 16-bit or 32-bit;falseindicates an 128-bit UUID- Throws:
java.lang.IllegalArgumentException- ifuuidValuehas characters that are not defined in the hexadecimal set [0-9, a-f, A-F]; ifuuidValuelength is zero; ifshortUUIDistrueanduuidValue's length is greater than 8; ifshortUUIDisfalseanduuidValue's length is greater than 32java.lang.NullPointerException- ifuuidValueisnull- Since:
- TotalCross 1.2
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object value)
Determines if twoUUIDs are equal. They are equal if their 128 bit values are the same. This method will returnfalseifvalueisnullor is not aUUIDobject.- Overrides:
equalsin classjava.lang.Object- Parameters:
value- the object to compare to- Returns:
trueif the 128 bit values of the two objects are equal, otherwisefalse- Since:
- TotalCross 1.2
-
hashCode
public int hashCode()
Computes the hash code for this object. This method retains the same semantic contract as defined in the classjava.lang.Objectwhile overriding the implementation.- Overrides:
hashCodein classjava.lang.Object- Returns:
- the hash code for this object
- Since:
- TotalCross 1.2
-
toString
public java.lang.String toString()
Returns the string representation of the 128-bit UUID object. The string being returned represents a UUID that contains characters from the hexadecimal set, [0-9, A-F]. It does not include the prefix "0x" that is generally used for hex representation of numbers. The return value will never benull.- Overrides:
toStringin classjava.lang.Object- Returns:
- the string representation of the UUID
- Since:
- TotalCross 1.2
-
-