com.bowstreet.webapp
Class IDGenerator

java.lang.Object
  extended by com.bowstreet.webapp.IDGenerator

public class IDGenerator
extends java.lang.Object

The IDGenerator is a helper class for creating unique ID's that are suitable for use in HTML "id" attributes.


Constructor Summary
IDGenerator()
           
 
Method Summary
static java.lang.String getCurrentID(WebAppAccess webAppAccess, java.lang.String key)
          Method to get the current unique ID using the the value set by the getNextID(..) method.
static java.lang.String getNextID(WebAppAccess webAppAccess, java.lang.String key)
          Method to get the next unique ID using the current WebApp, Request, and specified key.
static java.lang.String getUniqueRegenID(WebApp webApp, java.lang.String key)
          Get a generation-time unique ID: this value won't collide with other ID's generated similarly across a given webapp.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IDGenerator

public IDGenerator()
Method Detail

getCurrentID

public static java.lang.String getCurrentID(WebAppAccess webAppAccess,
                                            java.lang.String key)
Method to get the current unique ID using the the value set by the getNextID(..) method.

You should call getNextID(..) prior calling this method.

Parameters:
webAppAccess - The current WebAppAccess.
key - A key to use for this instance. This should be made unique for the current model. For example build a key using the Builder type name plus the builder instance call name (e.g. CalendarBuilder_HireDate).
Returns:
The unique ID String (e.g. toolTipsimple1fdfb53).

getNextID

public static java.lang.String getNextID(WebAppAccess webAppAccess,
                                         java.lang.String key)
Method to get the next unique ID using the current WebApp, Request, and specified key.

The ID will be incremented each time this method is called. This shoud be used prior calling the getCurrentID(..) method.

Parameters:
webAppAccess - The current WebAppAccess.
key - A key to use for this instance. This should be made unique for the current model. For example build a key using the Builder type name plus the builder instance call name (e.g. CalendarBuilder_HireDate).
Returns:
The unique ID String (e.g. toolTipsimple1fdfb53).

getUniqueRegenID

public static java.lang.String getUniqueRegenID(WebApp webApp,
                                                java.lang.String key)
Get a generation-time unique ID: this value won't collide with other ID's generated similarly across a given webapp.

Parameters:
webApp -
key - prefix, to which a sequence number wil be appended
Returns:
per-WebApp gen-time unique ID string: key plus sequence


Copyright © 2009 IBM. All Rights Reserved.