Package | org.restfulx.utils |
Class | public class UUID |
Given that Flash does not provide an easy way to get at some unique space- based identifier, this implementation does not implement Version 1 of UUIDs (which are 'guaranteed' to be unique in TIME and SPACE). Instead it does a poor man's version of version 4 -- which means it's only as good as Flash's random number generator.
Hopefully the package itself is fairly self-explanatory; you create UUIDs and then can convert them to string and from strings. If you want to seralize one, seralize the string, and all "endianness" will be taken care of when you deseralize via "fromString".
Given that these UUIDs are not guaranteed unique in space (or time for that matter, although it's pretty unlikely you'll ever see two the same), you should take care how you use them.
Good uses of these UUIDs
- You want unique ids for debugging purposes
Bad uses of these UUIDs
- You want to use them as unique resource identifiers in your web site database. Shame on you.
Property | Defined by | ||
---|---|---|---|
variant : uint [read-only]
Returns the variant number associated with this UUID.
| UUID | ||
version : uint [read-only]
Returns the version of UUID this UUID represents.
| UUID |
Method | Defined by | ||
---|---|---|---|
UUID(aUUID:ByteArray)
Create a UUID from a 16-byte byte array.
| UUID | ||
Compare two UUIDs
| UUID | ||
[static]
Creates a new (random) UUID
| UUID | ||
Is this equal to the passed in value?
| UUID | ||
fromString(aUUID:String):UUID
[static]
Create a UUID from a string
| UUID | ||
toString():String
Return a nicely formatted version of the UUID
| UUID |
variant | property |
variant:uint
[read-only]Returns the variant number associated with this UUID. See the spec if you don't know what a variant is.
The variant number can be:
0: Reserved for NCS backward compatibility 2: The Leach-Salz variant 6: Reserved, Microsoft Corporation backward compatibility 7: Reserved for future definition
Implementation
public function get variant():uint
version | property |
version:uint
[read-only]Returns the version of UUID this UUID represents. For any UUIDs created from the Random UUID version it'll be 4 (meaning random is as good as you'll get).
Implementation public function get version():uint
UUID | () | constructor |
public function UUID(aUUID:ByteArray)
Create a UUID from a 16-byte byte array.
ParametersaUUID:ByteArray |
— Throws ArgumentError if the input is not 16 bytes.
|
compare | () | method |
public function compare(aUUID:UUID):int
Compare two UUIDs
ParametersaUUID:UUID — The uuid to compare to.
|
int — -1 if this is less than aUUID; +1 if this is greater than aUUID; else 0
|
— Throws ArgumentError if a null UUID is passed in.
|
createRandom | () | method |
public static function createRandom():UUID
Creates a new (random) UUID
ReturnsUUID —
The new random UUID
|
equals | () | method |
public function equals(aUUID:UUID):Boolean
Is this equal to the passed in value?
ParametersaUUID:UUID |
Boolean — compare(aUUID) == 0
|
See also
fromString | () | method |
public static function fromString(aUUID:String):UUID
Create a UUID from a string
ParametersaUUID:String — The string representation of the UUID; non-hex characters are stripped
|
UUID —
The new UUID
|
— Throws an ArgumentError if the input string is an invalid format
|
toString | () | method |
public function toString():String
Return a nicely formatted version of the UUID
ReturnsString — The string representation of the UUID
|