1 /**
2 * Java docs licensed under the Apache License, Version 2.0
3 * http://www.apache.org/licenses/LICENSE-2.0
4 * (c) Copyright 2001, 2002 Motorola, Inc. ALL RIGHTS RESERVED.
5 *
6 *
7 * @version $Id: UUID.java 1379 2007-10-13 02:00:43Z vlads $
8 */
9
10 package javax.bluetooth;
11
12 /**
13 * The <code>UUID</code> class defines universally
14 * unique identifiers. These 128-bit unsigned integers are guaranteed
15 * to be unique across all time and space. Accordingly, an instance of
16 * this class is immutable.
17 *
18 * The Bluetooth specification provides an algorithm describing how a
19 * 16-bit or 32-bit UUID could be promoted to a 128-bit UUID.
20 * Accordingly, this class provides an interface that assists
21 * applications in creating 16-bit, 32-bit, and 128-bit long UUIDs. The
22 * methods supported by this class allow equality testing of two UUID
23 * objects.
24 *
25 * <p>
26 *
27 * The Bluetooth Assigned Numbers document (<A
28 * HREF="http://www.bluetooth.org/assigned-numbers/sdp.htm">
29 * http://www.bluetooth.org/assigned-numbers/sdp.htm</A>)
30 * defines a large number of UUIDs for protocols and service classes.
31 * The table below provides a short list of the most common UUIDs
32 * defined in the Bluetooth Assigned Numbers document.
33 * <TABLE>
34 * <TR><TH>Name</TH><TH>Value</TH><TH>Size</TH></TR>
35 * <TR><TD>Base UUID Value (Used in promoting 16-bit and 32-bit UUIDs to
36 * 128-bit UUIDs)</TD><TD>0x0000000000001000800000805F9B34FB</TD>
37 * <TD>128-bit</TD></TR>
38 * <TR><TD>SDP</TD><TD>0x0001</TD><TD>16-bit</TD></TR>
39 * <TR><TD>RFCOMM</TD><TD>0x0003</TD><TD>16-bit</TD></TR>
40 * <TR><TD>OBEX</TD><TD>0x0008</TD><TD>16-bit</TD></TR>
41 * <TR><TD>HTTP</TD><TD>0x000C</TD><TD>16-bit</TD></TR>
42 * <TR><TD>L2CAP</TD><TD>0x0100</TD><TD>16-bit</TD></TR>
43 * <TR><TD>BNEP</TD><TD>0x000F</TD><TD>16-bit</TD></TR>
44 * <TR><TD>Serial Port</TD><TD>0x1101</TD><TD>16-bit</TD></TR>
45 * <TR><TD>ServiceDiscoveryServerServiceClassID</TD><TD>0x1000</TD>
46 * <TD>16-bit</TD></TR>
47 * <TR><TD>BrowseGroupDescriptorServiceClassID</TD><TD>0x1001</TD>
48 * <TD>16-bit</TD></TR>
49 * <TR><TD>PublicBrowseGroup</TD><TD>0x1002</TD><TD>16-bit</TD></TR>
50 * <TR><TD>OBEX Object Push
51 * Profile</TD><TD>0x1105</TD><TD>16-bit</TD></TR>
52 * <TR><TD>OBEX File Transfer
53 * Profile</TD><TD>0x1106</TD><TD>16-bit</TD></TR>
54 * <TR><TD>Personal Area Networking User</TD><TD>0x1115</TD>
55 * <TD>16-bit</TD></TR>
56 * <TR><TD>Network Access Point</TD><TD>0x1116</TD><TD>16-bit</TD></TR>
57 * <TR><TD>Group Network</TD><TD>0x1117</TD><TD>16-bit</TD></TR>
58 * </TABLE>
59 *
60 * @version 1.0 February 11, 2002
61 *
62 */
63 public class UUID {
64 /**
65 * Creates a <code>UUID</code> object from <code>long</code> value
66 * <code>uuidValue</code>. A UUID
67 * is defined as an unsigned integer whose value can range from
68 * [0 to 2<sup>128</sup>-1]. However, this constructor allows only
69 * those values that are in the range of [0 to 2<sup>32</sup> -1].
70 * Negative values and values in the range of [2<sup>32</sup>,
71 * 2<sup>63</sup> -1] are not
72 * allowed and will cause an <code>IllegalArgumentException</code> to
73 * be thrown.
74 *
75 * @param uuidValue the 16-bit or 32-bit value of the UUID
76 *
77 * @exception IllegalArgumentException if <code>uuidValue</code>
78 * is not in the range [0, 2<sup>32</sup> -1]
79 *
80 */
81 public UUID(long uuidValue) {
82 if (uuidValue < 0 || uuidValue > 0xffffffffl) {
83 throw new IllegalArgumentException("uuidValue is not in the range [0, 2^32 -1]");
84 }
85 }
86
87 /**
88 * Creates a <code>UUID</code> object from the string provided. The
89 * characters in the string must be from the hexadecimal set [0-9,
90 * a-f, A-F]. It is important to note that the prefix "0x" generally
91 * used for hex representation of numbers is not allowed. If the
92 * string does not have characters from the hexadecimal set, an
93 * exception will be thrown. The string length has to be positive
94 * and less than or equal to 32. A string length that exceeds 32 is
95 * illegal and will cause an exception. Finally, a <code>null</code> input
96 * is also considered illegal and causes an exception.
97 * <P>
98 * If <code>shortUUID</code> is <code>true</code>, <code>uuidValue</code>
99 * represents a 16-bit or 32-bit UUID. If <code>uuidValue</code> is in
100 * the range 0x0000 to 0xFFFF then this constructor will create a
101 * 16-bit UUID. If <code>uuidValue</code> is in the range
102 * 0x000010000 to 0xFFFFFFFF, then this constructor will create
103 * a 32-bit UUID. Therefore, <code>uuidValue</code> may only be 8 characters
104 * long.
105 * <P>
106 * On the other hand, if <code>shortUUID</code> is <code>false</code>, then
107 * <code>uuidValue</code> represents a 128-bit UUID. Therefore,
108 * <code>uuidValue</code> may only be 32 character long
109 *
110 * @param uuidValue the string representation of a 16-bit,
111 * 32-bit or 128-bit UUID
112 *
113 * @param shortUUID indicates the size of the UUID to be constructed;
114 * <code>true</code> is used to indicate short UUIDs,
115 * i.e. either 16-bit or 32-bit; <code>false</code> indicates an 128-bit
116 * UUID
117 *
118 * @exception NumberFormatException if <code>uuidValue</code>
119 * has characters that are not defined in the hexadecimal set [0-9,
120 * a-f, A-F]
121 *
122 * @exception IllegalArgumentException if <code>uuidValue</code>
123 * length is zero; if <code>shortUUID</code> is <code>true</code>
124 * and <code>uuidValue</code>'s length is greater than 8; if
125 * <code>shortUUID</code> is <code>false</code> and
126 * <code>uuidValue</code>'s length is greater than 32
127 *
128 * @exception NullPointerException if <code>uuidValue</code> is
129 * <code>null</code>
130 *
131 */
132 public UUID(String uuidValue, boolean shortUUID) {
133 if (uuidValue == null) {
134 throw new NullPointerException("uuidValue is null");
135 }
136 }
137
138 /**
139 * Returns the string representation of the 128-bit UUID object.
140 * The string being returned represents a UUID
141 * that contains characters from the hexadecimal set, [0-9,
142 * A-F]. It does not include the prefix "0x" that is generally
143 * used for hex representation of numbers. The return value will
144 * never be <code>null</code>.
145 *
146 * @return the string representation of the UUID
147 *
148 */
149 public String toString() {
150 return null;
151 }
152
153 /**
154 * Determines if two <code>UUID</code>s are equal. They are equal
155 * if their 128 bit values are the same. This method will return
156 * <code>false</code> if <code>value</code> is
157 * <code>null</code> or is not a <code>UUID</code> object.
158 *
159 * @param value the object to compare to
160 *
161 * @return <code>true</code> if the 128 bit values of the two
162 * objects are equal, otherwise <code>false</code>
163 *
164 */
165 public boolean equals(Object value) {
166 if (value == null || !(value instanceof UUID)) {
167 return false;
168 }
169 return false;
170 }
171
172 /**
173 * Computes the hash code for this object.
174 * This method retains the same semantic contract as defined in
175 * the class <code>java.lang.Object</code> while overriding the
176 * implementation.
177 *
178 * @return the hash code for this object
179 */
180 public int hashCode() {
181 return 0;
182 }
183 }