prefuse.util
Class StringLib

java.lang.Object
  extended by prefuse.util.StringLib

public class StringLib
extends java.lang.Object

Library of utility routines pertaining to Strings.

Author:
jeffrey heer

Method Summary
static java.lang.String abbreviate(java.lang.String str, java.awt.FontMetrics fm, int width)
          Abbreviate a String by simply truncating it.
static java.lang.String abbreviateName(java.lang.String str, java.awt.FontMetrics fm, int width)
          Abbreviate a String as a given name.
static java.lang.String capitalizeFirstOnly(java.lang.String s)
          Capitalize all letters preceded by whitespace, and lower case all other letters.
static java.lang.String formatNumber(double number, int decimalPlaces)
          Format the given number as a String, including the given number of decimal places.
static java.lang.String getArrayString(java.lang.Object a)
          Given an array object, create a String showing the contents of the array using a "[a[0], a[1], ..., a[a.length-1]]" format.
static java.lang.String getStackTrace(java.lang.Throwable t)
          Get the stack trace of the given Throwable as a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getArrayString

public static final java.lang.String getArrayString(java.lang.Object a)
Given an array object, create a String showing the contents of the array using a "[a[0], a[1], ..., a[a.length-1]]" format.

Parameters:
a - the array object
Returns:
the array string

formatNumber

public static java.lang.String formatNumber(double number,
                                            int decimalPlaces)
Format the given number as a String, including the given number of decimal places.

Parameters:
number - the number to format
decimalPlaces - the number of decimal places to include
Returns:
the formatted String

capitalizeFirstOnly

public static java.lang.String capitalizeFirstOnly(java.lang.String s)
Capitalize all letters preceded by whitespace, and lower case all other letters.

Parameters:
s - the String to capitalize
Returns:
the capitalized string

getStackTrace

public static java.lang.String getStackTrace(java.lang.Throwable t)
Get the stack trace of the given Throwable as a String.

Parameters:
t - the Throwable
Returns:
the stack trace of the Throwable

abbreviate

public static java.lang.String abbreviate(java.lang.String str,
                                          java.awt.FontMetrics fm,
                                          int width)
Abbreviate a String by simply truncating it.

Parameters:
str - the String to abbreviate
fm - the FontMetrics for measuring the String length
width - the maximum string width, in pixels
Returns:
an abbreviated String

abbreviateName

public static java.lang.String abbreviateName(java.lang.String str,
                                              java.awt.FontMetrics fm,
                                              int width)
Abbreviate a String as a given name.

Parameters:
str - the String to abbreviate
fm - the FontMetrics for measuring the String length
width - the maximum string width, in pixels
Returns:
an abbreviated String


Copyright © 2007 Regents of the University of California