--- projects/cms/source/util/uk/org/iscream/cms/util/FormatName.java 2000/12/07 19:49:47 1.1 +++ projects/cms/source/util/uk/org/iscream/cms/util/FormatName.java 2000/12/12 19:15:30 1.4 @@ -10,9 +10,9 @@ package uk.ac.ukc.iscream.util; * a toString String to send to the logger. * * @author $Author: ajm $ - * @version $Id: FormatName.java,v 1.1 2000/12/07 19:49:47 ajm Exp $ + * @version $Id: FormatName.java,v 1.4 2000/12/12 19:15:30 ajm Exp $ */ -public class IscreamName { +public class FormatName { //---FINAL ATTRIBUTES--- @@ -24,18 +24,40 @@ public class IscreamName { * This is of use to the override of the toString() as * implemented by most of the iscream objects. * - * @param friendlyName the friendlyName of the calling class + * 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 * * @return an iscream standard name to be used as a toString() */ - public static String formatName(String friendlyName, String className, String revision) { + 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--- @@ -43,7 +65,7 @@ public class IscreamName { * A private constructor ensures an instance of this * class CANNOT be created. */ - private IscreamName() { + private FormatName() { // do nothing on purpose! }