org.eclipse.jdt.core
Class NamingConventions

java.lang.Object
  extended by org.eclipse.jdt.core.NamingConventions

public final class NamingConventions
extends java.lang.Object

Provides methods for computing Java-specific names.

The behavior of the methods is dependent of several JavaCore options.

The possible options are :

For a complete description of the configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaCore#setOptions().

This class provides static methods and constants only.

Since:
2.1
See Also:
JavaCore.setOptions(java.util.Hashtable), JavaCore.getDefaultOptions()

Method Summary
static char[] removePrefixAndSuffixForArgumentName(IJavaProject javaProject, char[] argumentName)
          Remove prefix and suffix from an argument name.
static java.lang.String removePrefixAndSuffixForArgumentName(IJavaProject javaProject, java.lang.String argumentName)
          Remove prefix and suffix from an argument name.
static char[] removePrefixAndSuffixForFieldName(IJavaProject javaProject, char[] fieldName, int modifiers)
          Remove prefix and suffix from a field name.
static java.lang.String removePrefixAndSuffixForFieldName(IJavaProject javaProject, java.lang.String fieldName, int modifiers)
          Remove prefix and suffix from a field name.
static char[] removePrefixAndSuffixForLocalVariableName(IJavaProject javaProject, char[] localName)
          Remove prefix and suffix from a local variable name.
static java.lang.String removePrefixAndSuffixForLocalVariableName(IJavaProject javaProject, java.lang.String localName)
          Remove prefix and suffix from a local variable name.
static char[][] suggestArgumentNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[][] excludedNames)
          Suggest names for an argument.
static java.lang.String[] suggestArgumentNames(IJavaProject javaProject, java.lang.String packageName, java.lang.String qualifiedTypeName, int dim, java.lang.String[] excludedNames)
          Suggest names for an argument.
static char[][] suggestFieldNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, int modifiers, char[][] excludedNames)
          Suggest names for a field.
static java.lang.String[] suggestFieldNames(IJavaProject javaProject, java.lang.String packageName, java.lang.String qualifiedTypeName, int dim, int modifiers, java.lang.String[] excludedNames)
          Suggest names for a field.
static char[] suggestGetterName(IJavaProject project, char[] fieldName, int modifiers, boolean isBoolean, char[][] excludedNames)
          Suggest name for a getter method.
static java.lang.String suggestGetterName(IJavaProject project, java.lang.String fieldName, int modifiers, boolean isBoolean, java.lang.String[] excludedNames)
          Suggest name for a getter method.
static char[][] suggestLocalVariableNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[][] excludedNames)
          Suggest names for a local variable.
static java.lang.String[] suggestLocalVariableNames(IJavaProject javaProject, java.lang.String packageName, java.lang.String qualifiedTypeName, int dim, java.lang.String[] excludedNames)
          Suggest names for a local variable.
static char[] suggestSetterName(IJavaProject project, char[] fieldName, int modifiers, boolean isBoolean, char[][] excludedNames)
          Suggest name for a setter method.
static java.lang.String suggestSetterName(IJavaProject project, java.lang.String fieldName, int modifiers, boolean isBoolean, java.lang.String[] excludedNames)
          Suggest name for a setter method.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

removePrefixAndSuffixForArgumentName

public static char[] removePrefixAndSuffixForArgumentName(IJavaProject javaProject,
                                                          char[] argumentName)
Remove prefix and suffix from an argument name.

If argument name prefix is pre and argument name suffix is suf then for an argument named preArgsuf the result of this method is arg. If there is no prefix or suffix defined in JavaCore options the result is the unchanged name preArgsuf.

This method is affected by the following JavaCore options : JavaCore.CODEASSIST_ARGUMENT_PREFIXES and JavaCore.CODEASSIST_ARGUMENT_SUFFIXES.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaCore#setOptions().

Parameters:
javaProject - project which contains the argument.
argumentName - argument's name.
Returns:
char[] the name without prefix and suffix.
See Also:
JavaCore.setOptions(java.util.Hashtable), JavaCore.getDefaultOptions()

removePrefixAndSuffixForArgumentName

public static java.lang.String removePrefixAndSuffixForArgumentName(IJavaProject javaProject,
                                                                    java.lang.String argumentName)
Remove prefix and suffix from an argument name.

If argument name prefix is pre and argument name suffix is suf then for an argument named preArgsuf the result of this method is arg. If there is no prefix or suffix defined in JavaCore options the result is the unchanged name preArgsuf.

This method is affected by the following JavaCore options : JavaCore.CODEASSIST_ARGUMENT_PREFIXES and JavaCore.CODEASSIST_ARGUMENT_SUFFIXES.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaCore#setOptions().

Parameters:
javaProject - project which contains the argument.
argumentName - argument's name.
Returns:
char[] the name without prefix and suffix.
See Also:
JavaCore.setOptions(java.util.Hashtable), JavaCore.getDefaultOptions()

removePrefixAndSuffixForFieldName

public static char[] removePrefixAndSuffixForFieldName(IJavaProject javaProject,
                                                       char[] fieldName,
                                                       int modifiers)
Remove prefix and suffix from a field name.

If field name prefix is pre and field name suffix is suf then for a field named preFieldsuf the result of this method is field. If there is no prefix or suffix defined in JavaCore options the result is the unchanged name preFieldsuf.

This method is affected by the following JavaCore options : JavaCore.CODEASSIST_FIELD_PREFIXES } , JavaCore.CODEASSIST_FIELD_SUFFIXES for instance field and JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES for static field.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaCore#setOptions().

Parameters:
javaProject - project which contains the field.
fieldName - field's name.
modifiers - field's modifiers as defined by the class Flags.
Returns:
char[] the name without prefix and suffix.
See Also:
Flags, JavaCore.setOptions(java.util.Hashtable), JavaCore.getDefaultOptions()

removePrefixAndSuffixForFieldName

public static java.lang.String removePrefixAndSuffixForFieldName(IJavaProject javaProject,
                                                                 java.lang.String fieldName,
                                                                 int modifiers)
Remove prefix and suffix from a field name.

If field name prefix is pre and field name suffix is suf then for a field named preFieldsuf the result of this method is field. If there is no prefix or suffix defined in JavaCore options the result is the unchanged name preFieldsuf.

This method is affected by the following JavaCore options : JavaCore.CODEASSIST_FIELD_PREFIXES, JavaCore.CODEASSIST_FIELD_SUFFIXES for instance field and JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES for static field.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaCore#setOptions().

Parameters:
javaProject - project which contains the field.
fieldName - field's name.
modifiers - field's modifiers as defined by the class Flags.
Returns:
char[] the name without prefix and suffix.
See Also:
Flags, JavaCore.setOptions(java.util.Hashtable), JavaCore.getDefaultOptions()

removePrefixAndSuffixForLocalVariableName

public static char[] removePrefixAndSuffixForLocalVariableName(IJavaProject javaProject,
                                                               char[] localName)
Remove prefix and suffix from a local variable name.

If local variable name prefix is pre and local variable name suffix is suf then for a local variable named preLocalsuf the result of this method is local. If there is no prefix or suffix defined in JavaCore options the result is the unchanged name preLocalsuf.

This method is affected by the following JavaCore options : JavaCore.CODEASSIST_LOCAL_PREFIXES and JavaCore.CODEASSIST_LOCAL_SUFFIXES.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaCore#setOptions().

Parameters:
javaProject - project which contains the variable.
localName - variable's name.
Returns:
char[] the name without prefix and suffix.
See Also:
JavaCore.setOptions(java.util.Hashtable), JavaCore.getDefaultOptions()

removePrefixAndSuffixForLocalVariableName

public static java.lang.String removePrefixAndSuffixForLocalVariableName(IJavaProject javaProject,
                                                                         java.lang.String localName)
Remove prefix and suffix from a local variable name.

If local variable name prefix is pre and local variable name suffix is suf then for a local variable named preLocalsuf the result of this method is local. If there is no prefix or suffix defined in JavaCore options the result is the unchanged name preLocalsuf.

This method is affected by the following JavaCore options : JavaCore.CODEASSIST_LOCAL_PREFIXES and JavaCore.CODEASSIST_LOCAL_SUFFIXES.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaCore#setOptions().

Parameters:
javaProject - project which contains the variable.
localName - variable's name.
Returns:
char[] the name without prefix and suffix.
See Also:
JavaCore.setOptions(java.util.Hashtable), JavaCore.getDefaultOptions()

suggestArgumentNames

public static char[][] suggestArgumentNames(IJavaProject javaProject,
                                            char[] packageName,
                                            char[] qualifiedTypeName,
                                            int dim,
                                            char[][] excludedNames)
Suggest names for an argument. The name is computed from argument's type and possible prefixes or suffixes are added.

If the type of the argument is TypeName, the prefix for argument is pre and the suffix for argument is suf then the proposed names are preTypeNamesuf and preNamesuf. If there is no prefix or suffix the proposals are typeName and name.

This method is affected by the following JavaCore options : JavaCore.CODEASSIST_ARGUMENT_PREFIXES and JavaCore.CODEASSIST_ARGUMENT_SUFFIXES.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaCore#setOptions().

Parameters:
javaProject - project which contains the argument.
packageName - package of the argument's type.
qualifiedTypeName - argument's type.
dim - argument's dimension (0 if the argument is not an array).
excludedNames - a list of names which cannot be suggested (already used names). Can be null if there is no excluded names.
Returns:
char[][] an array of names.
See Also:
JavaCore.setOptions(java.util.Hashtable), JavaCore.getDefaultOptions()

suggestArgumentNames

public static java.lang.String[] suggestArgumentNames(IJavaProject javaProject,
                                                      java.lang.String packageName,
                                                      java.lang.String qualifiedTypeName,
                                                      int dim,
                                                      java.lang.String[] excludedNames)
Suggest names for an argument. The name is computed from argument's type and possible prefixes or suffixes are added.

If the type of the argument is TypeName, the prefix for argument is pre and the suffix for argument is suf then the proposed names are preTypeNamesuf and preNamesuf. If there is no prefix or suffix the proposals are typeName and name.

This method is affected by the following JavaCore options : JavaCore.CODEASSIST_ARGUMENT_PREFIXES and JavaCore.CODEASSIST_ARGUMENT_SUFFIXES.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaCore#setOptions().

Parameters:
javaProject - project which contains the argument.
packageName - package of the argument's type.
qualifiedTypeName - argument's type.
dim - argument's dimension (0 if the argument is not an array).
excludedNames - a list of names which cannot be suggested (already used names). Can be null if there is no excluded names.
Returns:
char[][] an array of names.
See Also:
JavaCore.setOptions(java.util.Hashtable), JavaCore.getDefaultOptions()

suggestFieldNames

public static char[][] suggestFieldNames(IJavaProject javaProject,
                                         char[] packageName,
                                         char[] qualifiedTypeName,
                                         int dim,
                                         int modifiers,
                                         char[][] excludedNames)
Suggest names for a field. The name is computed from field's type and possible prefixes or suffixes are added.

If the type of the field is TypeName, the prefix for field is pre and the suffix for field is suf then the proposed names are preTypeNamesuf and preNamesuf. If there is no prefix or suffix the proposals are typeName and name.

This method is affected by the following JavaCore options : JavaCore.CODEASSIST_FIELD_PREFIXES, JavaCore.CODEASSIST_FIELD_SUFFIXES and for instance field and JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES for static field.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaCore#setOptions().

Parameters:
javaProject - project which contains the field.
packageName - package of the field's type.
qualifiedTypeName - field's type.
dim - field's dimension (0 if the field is not an array).
modifiers - field's modifiers as defined by the class Flags.
excludedNames - a list of names which cannot be suggested (already used names). Can be null if there is no excluded names.
Returns:
char[][] an array of names.
See Also:
Flags, JavaCore.setOptions(java.util.Hashtable), JavaCore.getDefaultOptions()

suggestFieldNames

public static java.lang.String[] suggestFieldNames(IJavaProject javaProject,
                                                   java.lang.String packageName,
                                                   java.lang.String qualifiedTypeName,
                                                   int dim,
                                                   int modifiers,
                                                   java.lang.String[] excludedNames)
Suggest names for a field. The name is computed from field's type and possible prefixes or suffixes are added.

If the type of the field is TypeName, the prefix for field is pre and the suffix for field is suf then the proposed names are preTypeNamesuf and preNamesuf. If there is no prefix or suffix the proposals are typeName and name.

This method is affected by the following JavaCore options : JavaCore.CODEASSIST_FIELD_PREFIXES, JavaCore.CODEASSIST_FIELD_SUFFIXES and for instance field and JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES for static field.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaCore#setOptions().

Parameters:
javaProject - project which contains the field.
packageName - package of the field's type.
qualifiedTypeName - field's type.
dim - field's dimension (0 if the field is not an array).
modifiers - field's modifiers as defined by the class Flags.
excludedNames - a list of names which cannot be suggested (already used names). Can be null if there is no excluded names.
Returns:
char[][] an array of names.
See Also:
Flags, JavaCore.setOptions(java.util.Hashtable), JavaCore.getDefaultOptions()

suggestLocalVariableNames

public static char[][] suggestLocalVariableNames(IJavaProject javaProject,
                                                 char[] packageName,
                                                 char[] qualifiedTypeName,
                                                 int dim,
                                                 char[][] excludedNames)
Suggest names for a local variable. The name is computed from variable's type and possible prefixes or suffixes are added.

If the type of the local variable is TypeName, the prefix for local variable is pre and the suffix for local variable is suf then the proposed names are preTypeNamesuf and preNamesuf. If there is no prefix or suffix the proposals are typeName and name.

This method is affected by the following JavaCore options : JavaCore.CODEASSIST_LOCAL_PREFIXES and JavaCore.CODEASSIST_LOCAL_SUFFIXES.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaCore#setOptions().

Parameters:
javaProject - project which contains the variable.
packageName - package of the variable's type.
qualifiedTypeName - variable's type.
dim - variable's dimension (0 if the variable is not an array).
excludedNames - a list of names which cannot be suggested (already used names). Can be null if there is no excluded names.
Returns:
char[][] an array of names.
See Also:
JavaCore.setOptions(java.util.Hashtable), JavaCore.getDefaultOptions()

suggestLocalVariableNames

public static java.lang.String[] suggestLocalVariableNames(IJavaProject javaProject,
                                                           java.lang.String packageName,
                                                           java.lang.String qualifiedTypeName,
                                                           int dim,
                                                           java.lang.String[] excludedNames)
Suggest names for a local variable. The name is computed from variable's type and possible prefixes or suffixes are added.

If the type of the local variable is TypeName, the prefix for local variable is pre and the suffix for local variable is suf then the proposed names are preTypeNamesuf and preNamesuf. If there is no prefix or suffix the proposals are typeName and name.

This method is affected by the following JavaCore options : JavaCore.CODEASSIST_LOCAL_PREFIXES and JavaCore.CODEASSIST_LOCAL_SUFFIXES.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaCore#setOptions().

Parameters:
javaProject - project which contains the variable.
packageName - package of the variable's type.
qualifiedTypeName - variable's type.
dim - variable's dimension (0 if the variable is not an array).
excludedNames - a list of names which cannot be suggested (already used names). Can be null if there is no excluded names.
Returns:
char[][] an array of names.
See Also:
JavaCore.setOptions(java.util.Hashtable), JavaCore.getDefaultOptions()

suggestGetterName

public static char[] suggestGetterName(IJavaProject project,
                                       char[] fieldName,
                                       int modifiers,
                                       boolean isBoolean,
                                       char[][] excludedNames)
Suggest name for a getter method. The name is computed from field's name and possible prefixes or suffixes are removed.

If the field name is preFieldNamesuf and the prefix for field is pre and the suffix for field is suf then the prosposed name is isFieldName for boolean field or getFieldName for others. If there is no prefix and suffix the proposal is isPreFieldNamesuf for boolean field or getPreFieldNamesuf for others.

This method is affected by the following JavaCore options : JavaCore.CODEASSIST_FIELD_PREFIXES, JavaCore.CODEASSIST_FIELD_SUFFIXES for instance field and JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES for static field.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaCore#setOptions().

Parameters:
project - project which contains the field.
fieldName - field's name's.
modifiers - field's modifiers as defined by the class Flags.
isBoolean - true if the field's type is boolean
excludedNames - a list of names which cannot be suggested (already used names). Can be null if there is no excluded names.
Returns:
char[] a name.
See Also:
Flags, JavaCore.setOptions(java.util.Hashtable), JavaCore.getDefaultOptions()

suggestGetterName

public static java.lang.String suggestGetterName(IJavaProject project,
                                                 java.lang.String fieldName,
                                                 int modifiers,
                                                 boolean isBoolean,
                                                 java.lang.String[] excludedNames)
Suggest name for a getter method. The name is computed from field's name and possible prefixes or suffixes are removed.

If the field name is preFieldNamesuf and the prefix for field is pre and the suffix for field is suf then the prosposed name is isFieldName for boolean field or getFieldName for others. If there is no prefix and suffix the proposal is isPreFieldNamesuf for boolean field or getPreFieldNamesuf for others.

This method is affected by the following JavaCore options : JavaCore.CODEASSIST_FIELD_PREFIXES, JavaCore.CODEASSIST_FIELD_SUFFIXES for instance field and JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES for static field.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaCore#setOptions().

Parameters:
project - project which contains the field.
fieldName - field's name's.
modifiers - field's modifiers as defined by the class Flags.
isBoolean - true if the field's type is boolean
excludedNames - a list of names which cannot be suggested (already used names). Can be null if there is no excluded names.
Returns:
char[] a name.
See Also:
Flags, JavaCore.setOptions(java.util.Hashtable), JavaCore.getDefaultOptions()

suggestSetterName

public static char[] suggestSetterName(IJavaProject project,
                                       char[] fieldName,
                                       int modifiers,
                                       boolean isBoolean,
                                       char[][] excludedNames)
Suggest name for a setter method. The name is computed from field's name and possible prefixes or suffixes are removed.

If the field name is preFieldNamesuf and the prefix for field is pre and the suffix for field is suf then the proposed name is setFieldName. If there is no prefix and suffix the proposal is setPreFieldNamesuf.

This method is affected by the following JavaCore options : JavaCore.CODEASSIST_FIELD_PREFIXES, JavaCore.CODEASSIST_FIELD_SUFFIXES for instance field and JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES for static field.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaCore#setOptions().

Parameters:
project - project which contains the field.
fieldName - field's name's.
modifiers - field's modifiers as defined by the class Flags.
isBoolean - true if the field's type is boolean
excludedNames - a list of names which cannot be suggested (already used names). Can be null if there is no excluded names.
Returns:
char[] a name.
See Also:
Flags, JavaCore.setOptions(java.util.Hashtable), JavaCore.getDefaultOptions()

suggestSetterName

public static java.lang.String suggestSetterName(IJavaProject project,
                                                 java.lang.String fieldName,
                                                 int modifiers,
                                                 boolean isBoolean,
                                                 java.lang.String[] excludedNames)
Suggest name for a setter method. The name is computed from field's name and possible prefixes or suffixes are removed.

If the field name is preFieldNamesuf and the prefix for field is pre and the suffix for field is suf then the proposed name is setFieldName. If there is no prefix and suffix the proposal is setPreFieldNamesuf.

This method is affected by the following JavaCore options : JavaCore.CODEASSIST_FIELD_PREFIXES, JavaCore.CODEASSIST_FIELD_SUFFIXES for instance field and JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES for static field.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaCore#setOptions().

Parameters:
project - project which contains the field.
fieldName - field's name's.
modifiers - field's modifiers as defined by the class Flags.
isBoolean - true if the field's type is boolean
excludedNames - a list of names which cannot be suggested (already used names). Can be null if there is no excluded names.
Returns:
char[] a name.
See Also:
Flags, JavaCore.setOptions(java.util.Hashtable), JavaCore.getDefaultOptions()