12 |
|
* @author $Author$ |
13 |
|
* @version $Id$ |
14 |
|
*/ |
15 |
< |
public class IscreamName { |
15 |
> |
public class FormatName { |
16 |
|
|
17 |
|
//---FINAL ATTRIBUTES--- |
18 |
|
|
24 |
|
* This is of use to the override of the toString() as |
25 |
|
* implemented by most of the iscream objects. |
26 |
|
* |
27 |
< |
* @param friendlyName the friendlyName of the calling class |
27 |
> |
* It has support for null friendly name and null class name |
28 |
> |
* bit NOT both at the same time. |
29 |
> |
* |
30 |
> |
* @param friendlyName the configured name of the instance of the calling component the class is in (eg "filter1") |
31 |
|
* @param className the class name of the calling class, as obtained by getClass().getName() |
32 |
|
* @param revision the CVS Revision number for the calling class |
33 |
|
* |
34 |
|
* @return an iscream standard name to be used as a toString() |
35 |
|
*/ |
36 |
< |
public static String formatName(String friendlyName, String className, String revision) { |
36 |
> |
public static String getName(String friendlyName, String className, String revision) { |
37 |
|
if (friendlyName == null) { |
38 |
< |
return "{"+ className + "}(" + revision.substring(11, revision.length() - 2) + ")"; |
38 |
> |
return "{"+ tidyClassName(className) + "(v" + revision.substring(11, revision.length() - 2) + ")}"; |
39 |
> |
} else if (className == null) { |
40 |
> |
return friendlyName + "{static(v" + revision.substring(11, revision.length() - 2) + ")}"; |
41 |
> |
} else { |
42 |
> |
return friendlyName + "{"+ tidyClassName(className) + "(v" + revision.substring(11, revision.length() - 2) + ")}"; |
43 |
|
} |
37 |
– |
return friendlyName + "{"+ className + "}(" + revision.substring(11, revision.length() - 2) + ")"; |
44 |
|
} |
45 |
+ |
|
46 |
+ |
/** |
47 |
+ |
* If the class name begins with uk.ac.ukc.iscream |
48 |
+ |
* this method will trim it off, otherwise it |
49 |
+ |
* leaves the string unchanged. |
50 |
+ |
* |
51 |
+ |
* @param className the name of a class |
52 |
+ |
* |
53 |
+ |
* @return the tidy version of it |
54 |
+ |
*/ |
55 |
+ |
private static String tidyClassName(String className) { |
56 |
+ |
if (className.startsWith("uk.ac.ukc.iscream")) { |
57 |
+ |
return className.substring(18); |
58 |
+ |
} |
59 |
+ |
return className; |
60 |
+ |
} |
61 |
|
|
62 |
|
//---CONSTRUCTORS--- |
63 |
|
|
65 |
|
* A private constructor ensures an instance of this |
66 |
|
* class CANNOT be created. |
67 |
|
*/ |
68 |
< |
private IscreamName() { |
68 |
> |
private FormatName() { |
69 |
|
// do nothing on purpose! |
70 |
|
} |
71 |
|
|