com.bea.wli.worklist.build
Class ControlGeneratorUtility
java.lang.Object
com.bea.wli.worklist.build.ControlGeneratorUtility
public class ControlGeneratorUtility
- extends Object
Utility methods for use by the control generator tool.
Method Summary |
static String |
sanitizeName(String name)
Sanitize a user-defined name for use in Java code as an interface,
method, enum, or parameter name. |
static String |
sanitizeName(String name,
Set<String> reservedWordsForContext,
Set<String> existingNames)
Sanitize a user-defined name for use in Java code as an interface,
method, enum, or parameter name. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JAVA_KEY_RESERVED_WORDS
public static final Set<String> JAVA_KEY_RESERVED_WORDS
ControlGeneratorUtility
public ControlGeneratorUtility()
sanitizeName
public static String sanitizeName(String name)
- Sanitize a user-defined name for use in Java code as an interface,
method, enum, or parameter name. The following rules are applied in
order.
- Remove leading/trailing/internal whitespace
- If the name starts with any non-legal first character, the
sanitized name will start with ‘x’
- Any invalid Java identifier character is replaced with ‘X’
- If the resulting name matches any Java reserved word, an ‘x’ is
prepended to the name.
- Parameters:
name
- The user-defined name to be sanitized.
- Returns:
- The sanitized name suitable for use in Java code.
sanitizeName
public static String sanitizeName(String name,
Set<String> reservedWordsForContext,
Set<String> existingNames)
- Sanitize a user-defined name for use in Java code as an interface,
method, enum, or parameter name. The following rules are applied in
order.
- Remove leading/trailing/internal whitespace
- If the name starts with any non-legal first character, the
sanitized name will start with ‘x’
- Any invalid Java identifier character is replaced with ‘X’
- If the resulting name matches any Java reserved word, an ‘x’ is
prepended to the name.
- If the resulting name matches any reserved word for the current
context (as determined by the reservedWordsForContext param), an ‘x’
is prepended to the name.
- If the resulting name matches an existing name, a numeric counter
is appended to the resulting name
- Parameters:
name
- The user-defined name to be sanitized.reservedWordsForContext
- A set of names (as Strings) that would
be reserved (and therefore illegal as return values from this
method) within the context from which this method is being
called. For example, the caller could pass the names of system
defined method or interfaces when trying to generate a
sanitized name for a new method within the interface.existingNames
- A set of names (as Strings) for existing elements
of the same type as the element for which the sanitized name is
being generated. For example, the caller might pass the names
of existing methods when trying to generate a sanitized name for a
new method.
- Returns:
- The sanitized name suitable for use in Java code.