APIdia Launch Partner
Top Description Fields Constructors Methods
java.beans

pack-priv Class NameGenerator

extends Object
Class Inheritance
Imports
java.util.HashMap, .IdentityHashMap, .Map

A utility class which generates unique names for object instances. The name will be a concatenation of the unqualified class name and an instance number.

For example, if the first object instance javax.swing.JButton is passed into instanceName then the returned string identifier will be "JButton0".

Author
Philip Milne

Field Summary

Modifier and TypeField and Description
private Map<String, Integer>
private Map<Object, String>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static String
capitalize(String name)

Returns a String which capitalizes the first letter of the string.

public void
clear()

Clears the name cache.

public String

Returns:

a unique string representing the object
instanceName
(Object
object used to generate string
instance
)

Returns a unique string which identifies the object instance.

public static String
unqualifiedClassName(Class<T> type)

Returns the root name of the class.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nameToCountback to summary
private Map<String, Integer> nameToCount
valueToNameback to summary
private Map<Object, String> valueToName

Constructor Detail

NameGeneratorback to summary
public NameGenerator()

Method Detail

capitalizeback to summary
public static String capitalize(String name)

Returns a String which capitalizes the first letter of the string.

clearback to summary
public void clear()

Clears the name cache. Should be called to near the end of the encoding cycle.

instanceNameback to summary
public String instanceName(Object instance)

Returns a unique string which identifies the object instance. Invocations are cached so that if an object has been previously passed into this method then the same identifier is returned.

Parameters
instance:Object

object used to generate string

Returns:String

a unique string representing the object

unqualifiedClassNameback to summary
public static String unqualifiedClassName(Class<T> type)

Returns the root name of the class.

Annotations
@SuppressWarnings:rawtypes