|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.cleancode.util.StringPlus
public final class StringPlus
Convenience methods for string handling.
| Field Summary | |
|---|---|
static char |
DEFAULT_BORDER_CHAR
Default character replicated to create a top and bottom border. |
static int |
DEFAULT_WIDTH
Default width of borders for various hilight methods. |
static String |
NL
System dependent line separator. |
static String |
VERSION
Current version of this class. |
| Method Summary | |
|---|---|
static String |
delimit(String s)
Wraps a string with double quotes. |
static double |
dollarToNumber(String amt)
Converts a monetary string to a number. |
static String |
getClassName(Object anObject)
Returns the class name for an object, without the package path. |
static String |
getThreadName()
Returns the thread name of the current thread. |
static String |
hilight(String s)
Delimits a text block with a top and bottom border using a default length and default border character. |
static String |
hilight(String s,
int len)
Delimits a String with a top and bottom border
using a default border character. |
static String |
hilight(String s,
int len,
char borderChar)
Delimits a text block with a top and bottom border. |
static String |
hilight(String title,
String s)
Delimits a text block with a top and bottom border, including title, using a default length and default border character. |
static String |
hilight(String title,
String s,
int len)
Delimits a text block with a top and bottom border, including title, using a default border character. |
static String |
hilight(String title,
String s,
int len,
char borderChar)
Delimits a text block with a top and bottom border, including title. |
static String |
hilightInline(String s)
Adds border lines around text (for a single line of output) using a default length and default border character. |
static String |
hilightInline(String s,
int len)
Adds border lines around text (for a single line of output) using a default border character. |
static String |
hilightInline(String s,
int len,
char borderChar)
Adds border lines around text (for a single line of output). |
static String |
replicate(char c,
int len)
Replicates a character into a string of a specified length. |
static String |
showKeys(Properties p)
Creates a comma separated list of keys of a Properties object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final char DEFAULT_BORDER_CHAR
public static final int DEFAULT_WIDTH
hilight methods.
public static final String NL
public static final String VERSION
| Method Detail |
|---|
public static String delimit(String s)
String is null, returns the empty string.
s - a string
public static String getClassName(Object anObject)
anObject - any Object
Objectpublic static String getThreadName()
public static String hilight(String s,
int len,
char borderChar)
hilight("my list of stuff", 25, "+") yields
+++++++++++++++++++++++++
my list of stuff
+++++++++++++++++++++++++
s - a string to delimitlen - length of borderborderChar - character to use for border
string highlighted with bordershilight
public static String hilight(String title,
String s,
int len,
char borderChar)
hilight("Category A", "my list of stuff", 25, "+") yields
+++++++ Category A ++++++ my list of stuff +++++++++++++++++++++++++
s - a string to delimitlen - length of borderborderChar - character to use for bordertitle - string to use in top border
string highlighted with bordershilightpublic static String hilight(String s)
s - a string to delimit
string highlighted with bordershilight
public static String hilight(String s,
int len)
String with a top and bottom border
using a default border character.
The default is the equals (=) character.
s - a string to delimitlen - length of border
string highlighted with bordershilight
public static String hilight(String title,
String s)
title - string to use in top borders - a string to delimit
string highlighted with bordershilight
public static String hilight(String title,
String s,
int len)
title - string to use in top borders - a string to delimitlen - length of border
string highlighted with bordershilight
public static String hilightInline(String s,
int len,
char borderChar)
hilight("my title", 25, "+") yields
+++++++ my title ++++++++
Effectively a string of the borderChar characters
is constructed of length len, then the msg
is overlaid in the middle with a space on either side.
If the msg itself is longer than the specified len,
then just a single borderChar plus a space is added to both ends.
s - a string to delimitlen - length of borderborderChar - character to use for border
string highlighted with borders
public static String hilightInline(String s,
int len)
s - a string to delimitlen - length of border
string highlighted with bordershilightInLinepublic static String hilightInline(String s)
s - a string to delimit
string highlighted with bordershilightInLine
public static String replicate(char c,
int len)
c - character to replicatelen - length of string to create
string of character cpublic static String showKeys(Properties p)
p - Properties object
public static double dollarToNumber(String amt)
amt - string representing a dollar amount
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
| CleanCode Java Libraries | Copyright © 2001-2012 Michael Sorens - Revised 2012.12.10 |