1 |
ajm |
1.1 |
//---PACKAGE DECLARATION--- |
2 |
|
|
package uk.ac.ukc.iscream.util; |
3 |
|
|
|
4 |
|
|
//---IMPORTS--- |
5 |
|
|
|
6 |
|
|
/** |
7 |
|
|
* This class provides static methods to format the |
8 |
|
|
* name of a calling object. It's main use is by |
9 |
|
|
* the various objects within the system to create |
10 |
|
|
* a toString String to send to the logger. |
11 |
|
|
* |
12 |
ajm |
1.2 |
* @author $Author: ajm4 $ |
13 |
ajm |
1.3 |
* @version $Id: FormatName.java,v 1.2 2000/12/08 11:40:08 ajm4 Exp $ |
14 |
ajm |
1.1 |
*/ |
15 |
ajm |
1.2 |
public class FormatName { |
16 |
ajm |
1.1 |
|
17 |
|
|
//---FINAL ATTRIBUTES--- |
18 |
|
|
|
19 |
|
|
//---STATIC METHODS--- |
20 |
|
|
|
21 |
|
|
/** |
22 |
|
|
* This method takes a set of information about the calling |
23 |
|
|
* class and constructs a tidy String name to be returned. |
24 |
|
|
* This is of use to the override of the toString() as |
25 |
|
|
* implemented by most of the iscream objects. |
26 |
|
|
* |
27 |
ajm |
1.3 |
* It has support for null friendly name and null class name |
28 |
|
|
* bit NOT both at the same time. |
29 |
|
|
* |
30 |
ajm |
1.2 |
* @param friendlyName the configured name of the instance of the calling component the class is in (eg "filter1") |
31 |
ajm |
1.1 |
* @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 |
ajm |
1.2 |
public static String getName(String friendlyName, String className, String revision) { |
37 |
ajm |
1.1 |
if (friendlyName == null) { |
38 |
ajm |
1.3 |
return "{"+ 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 + "{"+ className + "(v" + revision.substring(11, revision.length() - 2) + ")}"; |
43 |
ajm |
1.1 |
} |
44 |
|
|
} |
45 |
|
|
|
46 |
|
|
//---CONSTRUCTORS--- |
47 |
|
|
|
48 |
|
|
/** |
49 |
|
|
* A private constructor ensures an instance of this |
50 |
|
|
* class CANNOT be created. |
51 |
|
|
*/ |
52 |
ajm |
1.2 |
private FormatName() { |
53 |
ajm |
1.1 |
// do nothing on purpose! |
54 |
|
|
} |
55 |
|
|
|
56 |
|
|
//---PUBLIC METHODS--- |
57 |
|
|
|
58 |
|
|
//---PRIVATE METHODS--- |
59 |
|
|
|
60 |
|
|
//---ACCESSOR/MUTATOR METHODS--- |
61 |
|
|
|
62 |
|
|
//---ATTRIBUTES--- |
63 |
|
|
|
64 |
|
|
//---STATIC ATTRIBUTES--- |
65 |
|
|
|
66 |
|
|
} |