org.homeunix.thecave.moss.util
Class Formatter

java.lang.Object
  extended by org.homeunix.thecave.moss.util.Formatter

public class Formatter
extends java.lang.Object

A combination of many Formatting functions.

Author:
wyatt

Nested Class Summary
static class Formatter.StringLengthFormat
          A formatter-style class which cuts strings off after a given length.
 
Constructor Summary
Formatter()
           
 
Method Summary
static java.text.DateFormat getDateFormat()
           
static java.text.DateFormat getDateFormat(java.lang.String format)
           
static java.text.NumberFormat getDecimalFormat()
           
static java.text.NumberFormat getDecimalFormat(int decimalPlaces)
           
static Formatter.StringLengthFormat getStringLengthFormat(int length)
           
static java.lang.String getStringToLength(java.lang.String value, int maxPixelWidth, java.awt.FontMetrics fm)
          Returns a string which will be at most maxPixelWidth pixels long as displayed by the given FontMetrics object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Formatter

public Formatter()
Method Detail

getDecimalFormat

public static java.text.NumberFormat getDecimalFormat()

getDecimalFormat

public static java.text.NumberFormat getDecimalFormat(int decimalPlaces)

getDateFormat

public static java.text.DateFormat getDateFormat()

getDateFormat

public static java.text.DateFormat getDateFormat(java.lang.String format)

getStringLengthFormat

public static Formatter.StringLengthFormat getStringLengthFormat(int length)

getStringToLength

public static java.lang.String getStringToLength(java.lang.String value,
                                                 int maxPixelWidth,
                                                 java.awt.FontMetrics fm)
Returns a string which will be at most maxPixelWidth pixels long as displayed by the given FontMetrics object. If the string is any longer than that, it will be cut off, and show '...' at the end.

Parameters:
value -
maxPixelWidth -
fm -
Returns: