--- projects/cms/source/util/uk/org/iscream/cms/util/FormatName.java 2000/12/08 11:40:08 1.2 +++ projects/cms/source/util/uk/org/iscream/cms/util/FormatName.java 2000/12/12 19:15:30 1.4 @@ -10,7 +10,7 @@ package uk.ac.ukc.iscream.util; * a toString String to send to the logger. * * @author $Author: ajm $ - * @version $Id: FormatName.java,v 1.2 2000/12/08 11:40:08 ajm Exp $ + * @version $Id: FormatName.java,v 1.4 2000/12/12 19:15:30 ajm Exp $ */ public class FormatName { @@ -24,6 +24,9 @@ public class FormatName { * This is of use to the override of the toString() as * implemented by most of the iscream objects. * + * It has support for null friendly name and null class name + * bit NOT both at the same time. + * * @param friendlyName the configured name of the instance of the calling component the class is in (eg "filter1") * @param className the class name of the calling class, as obtained by getClass().getName() * @param revision the CVS Revision number for the calling class @@ -32,9 +35,28 @@ public class FormatName { */ public static String getName(String friendlyName, String className, String revision) { if (friendlyName == null) { - return "{"+ className + "}(" + revision.substring(11, revision.length() - 2) + ")"; + return "{"+ tidyClassName(className) + "(v" + revision.substring(11, revision.length() - 2) + ")}"; + } else if (className == null) { + return friendlyName + "{static(v" + revision.substring(11, revision.length() - 2) + ")}"; + } else { + return friendlyName + "{"+ tidyClassName(className) + "(v" + revision.substring(11, revision.length() - 2) + ")}"; } - return friendlyName + "{"+ className + "}(" + revision.substring(11, revision.length() - 2) + ")"; + } + + /** + * If the class name begins with uk.ac.ukc.iscream + * this method will trim it off, otherwise it + * leaves the string unchanged. + * + * @param className the name of a class + * + * @return the tidy version of it + */ + private static String tidyClassName(String className) { + if (className.startsWith("uk.ac.ukc.iscream")) { + return className.substring(18); + } + return className; } //---CONSTRUCTORS---