com.zipxap.vfs.dal.utility
Class UniqueID

java.lang.Object
  extended by com.zipxap.vfs.dal.utility.UniqueID

public class UniqueID
extends java.lang.Object

Represents a unique hexidecimal value that can be used to identify objects/records/etc. This class is conceptually similar to a UUID or GUID.

There are four variants;

VariantSize (Hexidecimal digits with/without dashes)Common Form
Single User, Single Application26/22HH-HHHH-HHHH-HHHH-HHHHHHHH
Single User, Multi Application26/30HH-HHHH-HHHH-HHHH-HHHHHHHHHHHH
Multi User, Single Application28/32HHHHHHHH-HHHH-HHHH-HHHH-HHHHHHHH
Multi User, Multi Application32/36HHHHHHHH-HHHH-HHHH-HHHH-HHHHHHHHHHHH
MilestoneWhoDate, Time
Initial VersionK PenroseOctober 24, 2007, 8:47 PM

** Note that this table is not intended as an exhaustive list of subtle changes. It is intended to list changes that break the compatibility of older code, or major enhancements/rewrites


Field Summary
static java.lang.String INVALID_UNIQUE_ID
           
static java.lang.String NO_APP_ID_SPECIFIED
           
static java.lang.String NO_USER_ID_SPECIFIED
           
static java.lang.String UNIQUE_ID_DIFFERENT_VERSION
           
static java.lang.String UNKNOWN_APP_ID_DIFFERENT_VERSION
           
static java.lang.String UNKNOWN_APP_ID_INVALID_UNIQUEID
           
static java.lang.String UNKNOWN_IP_DIFFERENT_VERSION
           
static java.lang.String UNKNOWN_IP_INVALID_UNIQUEID
           
static java.lang.String UNKNOWN_USER_ID_DIFFERENT_VERSION
           
static java.lang.String UNKNOWN_USER_ID_INVALID_UNIQUEID
           
static int VERSION_OF_UNIQUEID
           
 
Constructor Summary
UniqueID(java.lang.String uniqueIdString)
          Acceptible Formats: FormatVariantSize (Hexidecimal digits) HHHHHHHHHHHHHHHHHHHHHHSingle User, Single Application22 HH-HHHH-HHHH-HHHH-HHHHHHHHSingle User, Single Application26 HHHHHHHHHHHHHHHHHHHHHHHHHHSingle User, Multi Application26 HH-HHHH-HHHH-HHHH-HHHHHHHHHHHHSingle User, Multi Application30 HHHHHHHHHHHHHHHHHHHHHHHHHHHHMulti User, Single Application28 HHHHHHHH-HHHH-HHHH-HHHH-HHHHHHHHMulti User, Single Application32 HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHMulti User, Multi Application32 HHHHHHHH-HHHH-HHHH-HHHH-HHHHHHHHHHHHMulti User, Multi Application36
 
Method Summary
static UniqueID createUniqueID()
          Create a new UniqueID for single-user, multi-machine, single-application use.
static UniqueID createUniqueID(int userId, int appId)
          Create a new UniqueID for multi-user, multi-machine, multi-application use.
static UniqueID createUniqueID(java.lang.String userId)
          Create a new UniqueID for multi-user, multi-machine, single-application use.
static UniqueID createUniqueID(java.lang.String userId, java.lang.String appId)
          Create a new UniqueID for multi-user, multi-machine, multi-application use.
 java.lang.String getAppId()
          Retrieve the Application ID of the application that created this UniqueID.
 java.lang.String getLast4HexDigitsOfServerIp()
          Retrieve the last 4 hexidecimal digits of the IP address of the machine that created this UniqueID.
 java.lang.String getShortFormattedDate()
          Retrieve the date when this UniqueID was created.
 java.util.Date getTimestamp()
          Retrieve the Date when this UniqueID was created.
 java.lang.String getUserId()
          Retrieve the User ID of the user who created this UniqueID.
 int getVersion()
          Retrieve the version of this instance.
static int getVersionOfUniqueId()
          Get the version of this Class.
 boolean isValid()
          Determine if this is a valid UniqueID.
static boolean isValidUniqueId(java.lang.String uniqueIdString)
          Determine if a string represents a valid Unique ID Be forewarned; given the nature of a UniqueID (UUID/GUID), this method is likely to give false positives.
 java.lang.String toCondensedString()
          Retrieves the condensed string representation of this Unique ID, in one of the following forms; HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH, HHHHHHHHHHHHHHHHHHHHHHHHHHHH, HHHHHHHHHHHHHHHHHHHHHHHHHH, or HHHHHHHHHHHHHHHHHHHHHH, where each H represents a hexidecimal digit 0-9, A-F.
 java.lang.String toLegibleString()
          Retrieves a human-legible string representation of this Unique ID, in the form { USERID='HHHHHH', Server IP='HHHH', Timestamp='MM/dd/yyyy hh:mm:ss aa' }, where each H represents a hexidecimal digit 0-9, A-F.
 java.lang.String toString()
          Retrieves the un-condensed string representation of this Unique ID, in one of the following forms; HHHHHHHH-HHHH-HHHH-HHHH-HHHHHHHHHHHH, HH-HHHH-HHHH-HHHH-HHHHHHHHHHHH, HHHHHHHH-HHHH-HHHH-HHHH-HHHHHHHH, or HH-HHHH-HHHH-HHHH-HHHHHHHH, where each H represents a hexidecimal digit 0-9, A-F.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VERSION_OF_UNIQUEID

public static final int VERSION_OF_UNIQUEID
See Also:
Constant Field Values

NO_APP_ID_SPECIFIED

public static final java.lang.String NO_APP_ID_SPECIFIED
See Also:
Constant Field Values

NO_USER_ID_SPECIFIED

public static final java.lang.String NO_USER_ID_SPECIFIED
See Also:
Constant Field Values

UNKNOWN_APP_ID_DIFFERENT_VERSION

public static final java.lang.String UNKNOWN_APP_ID_DIFFERENT_VERSION
See Also:
Constant Field Values

UNKNOWN_USER_ID_DIFFERENT_VERSION

public static final java.lang.String UNKNOWN_USER_ID_DIFFERENT_VERSION
See Also:
Constant Field Values

UNKNOWN_APP_ID_INVALID_UNIQUEID

public static final java.lang.String UNKNOWN_APP_ID_INVALID_UNIQUEID
See Also:
Constant Field Values

UNKNOWN_USER_ID_INVALID_UNIQUEID

public static final java.lang.String UNKNOWN_USER_ID_INVALID_UNIQUEID
See Also:
Constant Field Values

UNKNOWN_IP_DIFFERENT_VERSION

public static final java.lang.String UNKNOWN_IP_DIFFERENT_VERSION
See Also:
Constant Field Values

UNKNOWN_IP_INVALID_UNIQUEID

public static final java.lang.String UNKNOWN_IP_INVALID_UNIQUEID
See Also:
Constant Field Values

INVALID_UNIQUE_ID

public static final java.lang.String INVALID_UNIQUE_ID
See Also:
Constant Field Values

UNIQUE_ID_DIFFERENT_VERSION

public static final java.lang.String UNIQUE_ID_DIFFERENT_VERSION
See Also:
Constant Field Values
Constructor Detail

UniqueID

public UniqueID(java.lang.String uniqueIdString)
Acceptible Formats:
FormatVariantSize (Hexidecimal digits)
HHHHHHHHHHHHHHHHHHHHHHSingle User, Single Application22
HH-HHHH-HHHH-HHHH-HHHHHHHHSingle User, Single Application26
HHHHHHHHHHHHHHHHHHHHHHHHHHSingle User, Multi Application26
HH-HHHH-HHHH-HHHH-HHHHHHHHHHHHSingle User, Multi Application30
HHHHHHHHHHHHHHHHHHHHHHHHHHHHMulti User, Single Application28
HHHHHHHH-HHHH-HHHH-HHHH-HHHHHHHHMulti User, Single Application32
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHMulti User, Multi Application32
HHHHHHHH-HHHH-HHHH-HHHH-HHHHHHHHHHHHMulti User, Multi Application36

Parameters:
uniqueIdString -
Method Detail

createUniqueID

public static UniqueID createUniqueID()
Create a new UniqueID for single-user, multi-machine, single-application use.


createUniqueID

public static UniqueID createUniqueID(java.lang.String userId)
Create a new UniqueID for multi-user, multi-machine, single-application use.

Parameters:
userId - the User ID of the user creating this UniqueID.

createUniqueID

public static UniqueID createUniqueID(int userId,
                                      int appId)
Create a new UniqueID for multi-user, multi-machine, multi-application use.

Parameters:
userId - a value between 0 and 2^24 (16777216) that represents the user creating this UniqueID.
appId - a value between 0 and 2^16 (65536) that must be unique to the host machine running the application.

createUniqueID

public static UniqueID createUniqueID(java.lang.String userId,
                                      java.lang.String appId)
Create a new UniqueID for multi-user, multi-machine, multi-application use.

Parameters:
userId - a 6 digit hexidecimal value that represents the user creating this UniqueID.
appId - a 4 digit hexidecimal value that must be unique to the host machine running the application.

isValidUniqueId

public static boolean isValidUniqueId(java.lang.String uniqueIdString)
Determine if a string represents a valid Unique ID Be forewarned; given the nature of a UniqueID (UUID/GUID), this method is likely to give false positives.

Parameters:
uniqueIdString -

getVersionOfUniqueId

public static int getVersionOfUniqueId()
Get the version of this Class.

Returns:
1

isValid

public boolean isValid()
Determine if this is a valid UniqueID. There isn't really much to base this on, so expect many false positives on this method.

Returns:
true if this is a valid UniqueID, else false

getUserId

public java.lang.String getUserId()
Retrieve the User ID of the user who created this UniqueID.

Returns:
The User ID of the user who created this UniqueID, else NO_USER_ID_SPECIFIED if no User ID was specified in the creation of this UniqueID, UNKNOWN_USER_ID_DIFFERENT_VERSION if the UniqueID was created from a different version of the specification, or UNKNOWN_USER_ID_INVALID_UNIQUEID if this is an invalid UniqueID.

getLast4HexDigitsOfServerIp

public java.lang.String getLast4HexDigitsOfServerIp()
Retrieve the last 4 hexidecimal digits of the IP address of the machine that created this UniqueID.

Returns:
The last 4 hexidecimal digits of the IP address of the machine that created, elseUNKNOWN_IP_DIFFERENT_VERSION if the UniqueID was created from a different version of the specification, or UNKNOWN_IP_INVALID_UNIQUEID if this is an invalid UniqueID.

getTimestamp

public java.util.Date getTimestamp()
Retrieve the Date when this UniqueID was created.

Returns:
If the UniqueID is valid and from the same version of the UniqueID specification, then this method returns the Date when this UniqueID was created, else it returns null.

getVersion

public int getVersion()
Retrieve the version of this instance.

Returns:
The version of this instance, or 0 if the UniqueID is invalid.

getAppId

public java.lang.String getAppId()
Retrieve the Application ID of the application that created this UniqueID.

Returns:
the Application ID of the application that created this UniqueID, else NO_APP_ID_SPECIFIED if no Application ID was specified in the creation of this UniqueID, UNKNOWN_APP_ID_DIFFERENT_VERSION if the UniqueID was created from a different version of the specification, or UNKNOWN_APP_ID_INVALID_UNIQUEID if this is an invalid UniqueID.

toString

public java.lang.String toString()
Retrieves the un-condensed string representation of this Unique ID, in one of the following forms; HHHHHHHH-HHHH-HHHH-HHHH-HHHHHHHHHHHH, HH-HHHH-HHHH-HHHH-HHHHHHHHHHHH, HHHHHHHH-HHHH-HHHH-HHHH-HHHHHHHH, or HH-HHHH-HHHH-HHHH-HHHHHHHH, where each H represents a hexidecimal digit 0-9, A-F. If the Unique ID is invalid, then INVALID_UNIQUE_ID is returned. Letter digits are always in uppercase.

Overrides:
toString in class java.lang.Object
Returns:
The un-condensed string representation of this Unique ID, or INVALID_UNIQUE_ID if invalid.

toCondensedString

public java.lang.String toCondensedString()
Retrieves the condensed string representation of this Unique ID, in one of the following forms; HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH, HHHHHHHHHHHHHHHHHHHHHHHHHHHH, HHHHHHHHHHHHHHHHHHHHHHHHHH, or HHHHHHHHHHHHHHHHHHHHHH, where each H represents a hexidecimal digit 0-9, A-F. If the Unique ID is invalid, then INVALID_UNIQUE_ID is returned. Letter digits are always in uppercase.

Returns:
The uncompressed string representation of this Unique ID.

toLegibleString

public java.lang.String toLegibleString()
Retrieves a human-legible string representation of this Unique ID, in the form { USERID='HHHHHH', Server IP='HHHH', Timestamp='MM/dd/yyyy hh:mm:ss aa' }, where each H represents a hexidecimal digit 0-9, A-F. Letter digits are always in uppercase.

Returns:
The uncompressed string representation of this Unique ID.

getShortFormattedDate

public java.lang.String getShortFormattedDate()
Retrieve the date when this UniqueID was created.

Returns:
the date when this UniqueID was created, in the format: MM/dd/yyyy hh:mm:ss aa