|
JAC project AOPSYS CEDRIC & LIP6 labs |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.objectweb.jac.core.rtti.NamingConventions
This class provides some useful methods to get some information regarding the naming conventions.
Field Summary | |
static int |
ADDER
Constant to represent collection adders. |
static String[] |
adderPrefixes
Store default collection adder prefixes (add..., put...). |
static int |
GETTER
Constant to represent field getters. |
static String[] |
getterPrefixes
Store default field getter prefixes (get...). |
static int |
MODIFIER
Constant to represent field modifiers. |
static int |
REMOVER
Constant to represent collection removers. |
static String[] |
removerPrefixes
Store default collection remover prefixes (rmv..., del..., remove...). |
static int |
SETTER
Constant to represent field setters. |
static String[] |
setterPrefixes
Store default field setter prefixes (set...). |
Constructor Summary | |
NamingConventions()
|
Method Summary | |
static String |
capitalize(String str)
Takes a string and returns a new capitalized one. |
static String |
fieldForMethod(Class cl,
String method)
Returns the field name for a given method (modifier or getter). |
static Method |
getDeclaredMethodByName(Class c,
String name)
Returns a declared method of a class c only by
knowing its name. |
static String |
getNormalizedAspectClassName(String programName,
String aspectName)
Returns the normalized class name of an aspect regarding its normalized name and the program it belongs to. |
static String |
getNormalizedAspectName(String name)
Returns the normalized name of an aspect regarding its class name. |
static String |
getNormalizedString(String string)
Returns the normalized name for a string. |
static String |
getPackageName(Class cl)
Returns the package name of the given class. |
static String |
getPlural(String name)
Returns the plural of a name |
static String |
getPrintableParameterTypes(AbstractMethodItem method)
Returns a printable representation of the argument types of a method (or a constructor if needed). |
static String |
getPrintableParameterTypes(AccessibleObject method)
Returns a printable representation of the argument types of a method (or a constructor if needed). |
static String |
getShortClassName(Class cl)
Returns the short name of a class. |
static String |
getShortClassName(ClassItem cli)
Returns the short name of a class. |
static String |
getShortConstructorName(Constructor constructor)
Returns the short name of a given constructor. |
static String |
getShortConstructorName(ConstructorItem constructor)
Returns the short name of a given constructor. |
static String |
getSingular(String name)
Return the singular of a name. |
static String |
getStandardClassName(Class cl)
|
static String |
getUnderscoredString(String string)
Returns the underscored name for a normalized string. |
static String |
getUnprefixedString(String string)
Get an unprefixed string from a prefixed string. |
static boolean |
isAdder(String name)
Return true if the name matches a adder profile (i.e. |
static boolean |
isGetter(String name)
Return true if the name matches a getter profile (i.e. |
static boolean |
isInPrefixes(String candidate,
String[] prefixes)
Tells if the the method name is equal to one of the given prefixes. |
static boolean |
isModifier(String name)
Returns true if the name matches a modifier profile (i.e. |
static int |
isPrefixedWith(String candidate,
String[] prefixes)
Tell if the string is prefixed with one of the given prefixes. |
static boolean |
isRemover(String name)
Return true if the name matches a remover profile (i.e. |
static boolean |
isSetter(String name)
Return true if the name matches a setter profile (i.e. |
static String |
lowerFirst(String string)
Lower case the first character of a string. |
static String |
maybeLowerFirst(String string)
Lower case the first character of a string unless it starts with at least two upper case letters. |
static String |
removePrefixFrom(String string)
Removes the prefix from a prefixed string. |
static String |
textForName(String name)
Returns the printable textual representation of a field or method name. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int MODIFIER
public static final int GETTER
public static final int SETTER
public static final int ADDER
public static final int REMOVER
public static final String[] getterPrefixes
public static final String[] setterPrefixes
public static final String[] adderPrefixes
public static final String[] removerPrefixes
Constructor Detail |
public NamingConventions()
Method Detail |
public static String getShortClassName(ClassItem cli)
If it is a well-known java class or a well-known JAC class, truncates the packages to give only the class name. It is is an array, add [] after the primitive type.
public static String getShortClassName(Class cl)
If it is a well-known java class or a well-known JAC class, truncates the packages to give only the class name. It is is an array, add [] after the primitive type.
cl
- the classpublic static String getStandardClassName(Class cl)
public static String getShortConstructorName(Constructor constructor)
By default, the name of a constructor contains the full path name of the constructor class. Thus, this method is equivalent to get the short name of the constructor class.
constructor
- a constructor
getShortClassName(Class)
public static String getShortConstructorName(ConstructorItem constructor)
By default, the name of a constructor contains the full path name of the constructor class. Thus, this method is equivalent to get the short name of the constructor class.
constructor
- a constructor
getShortClassName(ClassItem)
public static String getPackageName(Class cl)
cl
- the class to get the package of
cl
is definedpublic static String getPrintableParameterTypes(AccessibleObject method)
For instance, for a method that takes one object, one string, and one string array, the result will look like "Object, String, String[]".
method
- the involved method
getPrintableParameterTypes(AbstractMethodItem)
public static String getPrintableParameterTypes(AbstractMethodItem method)
Same as its homonym but uing RTTI meta item.
method
- the involved method
getPrintableParameterTypes(AccessibleObject)
public static Method getDeclaredMethodByName(Class c, String name)
c
only by
knowing its name. Returns null if not found (to be modified to
raise an exception.
c
- the class.name
- the name of the method to find.
public static int isPrefixedWith(String candidate, String[] prefixes)
Returns 0 if the candidate is not prefixed by any of the given prefixes and also if the candidate exactly equals one of the prefixes.
candidate
- the string to testprefixes
- the tested prefixes
public static boolean isInPrefixes(String candidate, String[] prefixes)
public static boolean isSetter(String name)
name
- the string to test
public static boolean isGetter(String name)
name
- the string to test
public static boolean isAdder(String name)
name
- the string to test
public static boolean isRemover(String name)
name
- the string to test
public static boolean isModifier(String name)
name
- the string to test
public static String capitalize(String str)
str
- the original string
str
public static String getNormalizedString(String string)
A normalized string is a blank-free word where each relevant
substring starts with an upcase character.
For instance:
- one string --> OneString - one_string --> OneString - oneString --> OneString - one.s-tring --> OneSTring
string
- the string to normalize
public static String getUnderscoredString(String string)
A normalized string is a blank-free word where each relevant
substring starts with an upcase character.
For instance:
- OneString --> one_string
string
- a normalized string
public static String lowerFirst(String string)
string
- the string to transform
public static String maybeLowerFirst(String string)
string
- the string to transform
public static String getUnprefixedString(String string)
NOTE: this method is not semantically indentical to
removePrefixFrom
.
For instance:
- getName --> Name - addName --> Names - removeName --> Names
string
- a prefixed string
removePrefixFrom(String)
public static String getPlural(String name)
name
- the name
public static String getSingular(String name)
public static String removePrefixFrom(String string)
NOTE: this method is not semantically indentical to
getUnprefixedString
.
For instance:
- getName --> Name - addName --> Name - removeName --> Name
string
- a prefixed string
getUnprefixedString(String)
public static String fieldForMethod(Class cl, String method)
cl
- the class where the method is supposed to bemethod
- the name of the method
public static String textForName(String name)
name
- the field or method name
public static String getNormalizedAspectName(String name)
E.g.:
name
- the aspect name to normalize
public static String getNormalizedAspectClassName(String programName, String aspectName)
|
Contact JAC development team: Renaud Pawlak Lionel Seinturier Laurent Martelli |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |