Name |
|
---|---|
Description |
An implementation of Universal Unique Identifier (UUID). See http://tools.ietf.org/html/rfc4122 The current implementation supports only a JVM backend due to dependencies upon [[java.security::MessageDigest]], to produce random bytes, and to implement MD5/SHA-1 hashing, respectively. According to the standard, the following components make up a
For example, for the following UUID: 5561de0e-64ad-4d9b-94f2-46926fc44121:
Since the above UUID was generated randomly, its version is 4, and is the first digit of the timeHiVersion. The variant is 2. Despite any variant with a leading bit of 1 being supported, with all variants supported for either backward or future compatibility, only variant 2 is in actual use. Currently, only versions 3 (MD5 sum), 4 (randomly generated), and 5 (SHA1) are supported. Usage: To obtain a UUID? uuidFromString = fromString("01c17b28-380d-48e2-9d6d-5c9f92b3546d"); To generate a UUID version 3 as an MD5 hash of a String with UUID uuidVersion3 = uuid3Md5("some string"); To generate a UUID version 5 as an SHA1 hash of a String and namespace with UUID uuidVersion5 = uuid5Sha1("some string", fromString("08110431-c913-4e72-b3e6-d3baad15f4db")); To generate a random UUID version 4: UUID uuidVersion4 = uuid4Random(); In addition support functions to convert from/to Java [[java.util::UUID]]s. To obtain a Java [[java.util::UUID]] from a import java.util { JUUID=UUID } JUUID javaUuid = toJavaUuid(ceylonUuid); To obtain a UUID javaUuid = toUuid(javaUuid); Also, there is a class AccountId(UUID baseValue) extends WrappedUUID(baseValue) {} class ReferenceId(UUID baseValue) extends WrappedUUID(baseValue) {} value accountId1 = AccountId(fromString()); value accountId2 = AccountId(fromString()); value refId1 = ReferenceId(fromString()); value refId2 = ReferenceId(fromString()); assertFalse(accountId1.equals(accountId2); assertFalse(accountId1.equals(referenceId1); assertFalse(referenceId2.equals(accountId2); |
Last Published | Apr 9, 2016 |
Stats |
Downloads (JVM): 517 Downloads (JS): 0 Source downloads: 582 |
Module links |
Imported By Browse |
0.0.12 | JVM JVM: 1.2.x, 1.3.x (latest) | Published Apr 9, 2016 |
Browse |
View docs |
|
0.0.11 | JVM JVM: 1.2.x, 1.3.x (latest) | Published Feb 14, 2016 |
Browse |
View docs |
|
0.0.10 | JVM JVM: 1.2.x, 1.3.x (latest) | Published Nov 10, 2015 |
Browse |
View docs |