Packageorg.restfulx.utils
Classpublic class UUID

This class implements a binary version of UUIDs as specified in the RFC.

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.



Public Properties
 PropertyDefined 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
Public Methods
 MethodDefined by
  
UUID(aUUID:ByteArray)
Create a UUID from a 16-byte byte array.
UUID
  
compare(aUUID:UUID):int
Compare two UUIDs
UUID
  
[static] Creates a new (random) UUID
UUID
  
equals(aUUID:UUID):Boolean
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
Property detail
variantproperty
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

versionproperty 
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
Constructor detail
UUID()constructor
public function UUID(aUUID:ByteArray)

Create a UUID from a 16-byte byte array.

Parameters
aUUID:ByteArray

Throws
— Throws ArgumentError if the input is not 16 bytes.
Method detail
compare()method
public function compare(aUUID:UUID):int

Compare two UUIDs

Parameters
aUUID:UUID — The uuid to compare to.

Returns
int — -1 if this is less than aUUID; +1 if this is greater than aUUID; else 0

Throws
— Throws ArgumentError if a null UUID is passed in.
createRandom()method 
public static function createRandom():UUID

Creates a new (random) UUID

Returns
UUID — The new random UUID
equals()method 
public function equals(aUUID:UUID):Boolean

Is this equal to the passed in value?

Parameters
aUUID:UUID

Returns
Boolean — compare(aUUID) == 0

See also

fromString()method 
public static function fromString(aUUID:String):UUID

Create a UUID from a string

Parameters
aUUID:String — The string representation of the UUID; non-hex characters are stripped

Returns
UUID — The new UUID

Throws
— 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

Returns
String — The string representation of the UUID