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 String convertAllocatedComponentId(String input)
          Utility for stripping out the standard allocator generated portion of a component id string in order to get what the most likely original component id was.
 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.
 
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

convertAllocatedComponentId

public static String convertAllocatedComponentId(String input)
Utility for stripping out the standard allocator generated portion of a component id string in order to get what the most likely original component id was.

Parameters:
input - The generated component id.
Returns:
The id stripped of any allocated id meta, if any was found.

allocateId

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


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.

clear

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



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