org.apache.tapestry.util
Class IdAllocator

java.lang.Object
  extended by org.apache.tapestry.util.IdAllocator

public class IdAllocator
extends Object

Used to "uniquify" names within a given context. A base name is passed in, and the return value is the base name, or the base name extended with a suffix to make it unique.

Since:
3.0
Author:
Howard Lewis Ship

Constructor Summary
IdAllocator()
           
IdAllocator(String namespace)
           
 
Method Summary
 String allocateId(String name)
          Allocates the id.
 void clear()
          Clears the allocator, resetting it to freshly allocated state.
static IdAllocator fromExternalString(String seed)
           
 String peekNextId(String name)
          Should return the exact same thing as allocateId(String), with the difference that the calculated id is not allocated and stored so multiple calls will always return the same thing.
 String toExternalString()
          Creates a custom string representation of the current state of this instance, capable of being re-created by using the corresponding fromExternalString(String) method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IdAllocator

public IdAllocator()

IdAllocator

public IdAllocator(String namespace)
Method Detail

allocateId

public String allocateId(String name)
Allocates the id. Repeated calls for the same name will return "name", "name_0", "name_1", etc.

Parameters:
name - The base id to allocate new unique ids from.
Returns:
A unique version of the passed in id.

peekNextId

public String peekNextId(String name)
Should return the exact same thing as allocateId(String), with the difference that the calculated id is not allocated and stored so multiple calls will always return the same thing.

Parameters:
name - The name to peek at.
Returns:
The next id that will be allocated for the given name.

toExternalString

public String toExternalString()
Creates a custom string representation of the current state of this instance, capable of being re-created by using the corresponding fromExternalString(String) method.

Returns:
The external string representation of the current state of this instance.

clear

public void clear()
Clears the allocator, resetting it to freshly allocated state.


fromExternalString

public static IdAllocator fromExternalString(String seed)


Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.