UUID 2.1.1 review

Download
by rbytes.net on

UUID is an implementation of the UUIDs and GUIDs specification in Java

License: MIT/X Consortium License
File size: 32K
Developer: Johann Burkard
0 stars award from rbytes.net

UUID is an implementation of the UUIDs and GUIDs specification in Java. UUIDs are 128 bit long identifiers that are guaranteed to be unique.

Example code

Download the latest version and extract the uuid.jar file from the archive. Open a command prompt and type:

> java -jar uuid.jar

A UUID should get printed out. You should be able to compile the following example if uuid.jar is in your classpath:
import com.eaio.uuid.UUID;

public class UUIDTest {
public static void main(String[] args) {
UUID u = new UUID();
System.out.println(u);
}
}

Try assembling UUIDs yourself:

UUID u = new UUID(4242L, 4242L);
Of course, comparing and equality testing is fully implemented:
UUID u1 = new UUID(4242L, 0L);
UUID u2 = new UUID(5203L, 9412);
System.out.println(u1.equals(u2)); // prints out "false"
System.out.println(u1.compareTo(u2)); // prints out "-1"

As well as cloning:

UUID u1 = new UUID(4242L, 0L);
UUID u2 = (UUID) u1.clone();
UUID u3 = new UUID(u1); // or use the clone constructor

Keep in mind that this UUID implementation has public fields (for compatibility with the EJB primary key specification), so cloning should be used for security purposes between in-VM system boundaries.

What's New in This Release:
MAC address parsing now works on Solaris.

UUID 2.1.1 keywords