uk.org.iscream.cms.util
Class FormatName

java.lang.Object
  extended byuk.org.iscream.cms.util.FormatName

public class FormatName
extends Object

This class provides static methods to format the name of a calling object. It's main use is by the various objects within the system to create a toString String to send to the logger.

Version:
$Id: FormatName.java,v 1.15 2003/02/05 14:27:59 tdb Exp $
Author:
$Author: tdb $

Field Summary
private static String[] VERBOSITY_NAMES
          An array of names of verbosity levels.
 
Constructor Summary
private FormatName()
          A private constructor ensures an instance of this class CANNOT be created.
 
Method Summary
static String formatLogLine(String source, int verbosity, String message)
          This method generates a nicely formatted line for the log, including the date/time and the source of the message.
static String getName(String friendlyName, String className, String revision)
          This method takes a set of information about the calling class and constructs a tidy String name to be returned.
private static String tidyClassName(String className)
          If the class name begins with uk.org.iscream.cms.server this method will trim it off, otherwise it leaves the string unchanged.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERBOSITY_NAMES

private static final String[] VERBOSITY_NAMES
An array of names of verbosity levels. Thus logging messages are now "classed" by the level

Constructor Detail

FormatName

private FormatName()
A private constructor ensures an instance of this class CANNOT be created.

Method Detail

getName

public static String getName(String friendlyName,
                             String className,
                             String revision)
This method takes a set of information about the calling class and constructs a tidy String name to be returned. This is of use to the override of the toString() as implemented by most of the iscream objects.

Parameters:
friendlyName - the configured name of the instance of the calling component the class is in (eg "filter1")
className - the class name of the calling class, as obtained by getClass().getName()
revision - the CVS Revision number for the calling class
Returns:
an iscream standard name to be used as a toString()

formatLogLine

public static String formatLogLine(String source,
                                   int verbosity,
                                   String message)
This method generates a nicely formatted line for the log, including the date/time and the source of the message. The date and time are formatted using the DateFormat class, and the source class is formatted using the toString() method found in every source file. This is then prepended to the message and returned.

Parameters:
source - A string representation of the calling object.
verbosity - The verbosity of the message.
message - The message to be logged.
Returns:
The string to be written to the log.

tidyClassName

private static String tidyClassName(String className)
If the class name begins with uk.org.iscream.cms.server this method will trim it off, otherwise it leaves the string unchanged.

Parameters:
className - the name of a class
Returns:
the tidy version of it


Copyright © 2000-2003 i-scream. All Rights Reserved.