Added truncate() and makeLinear() to StringTool and delineate() to

StringUtil.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@1593 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2005-02-22 06:44:56 +00:00
parent 97cddd5493
commit 26d7a7d02e
2 changed files with 30 additions and 0 deletions
@@ -58,4 +58,17 @@ public class HTMLUtil
text = StringUtil.replace(text, "\r\n\r\n", "\r\n<p>\r\n");
return text;
}
/**
* Inserts a &lt;br&gt; tag before every newline.
*/
public static String makeLinear (String text)
{
if (text == null) {
return text;
}
// handle both line ending formats
text = StringUtil.replace(text, "\n", "<br>\n");
return text;
}
}
@@ -80,6 +80,14 @@ public class StringTool
return HTMLUtil.makeParagraphs(text);
}
/**
* Adds a &lt;br&gt; tag before every newline.
*/
public static String delineate (String text)
{
return HTMLUtil.makeLinear(text);
}
/**
* Converts a float to a reasonably formatted string.
*/
@@ -88,6 +96,15 @@ public class StringTool
return NumberFormat.getInstance().format(value);
}
/**
* Truncates the supplied text at the specified length, appending the
* specified "elipsis" indicator to the text if truncated.
*/
public static String truncate (String text, int length, String append)
{
return StringUtil.truncate(text, length, append);
}
/** For formatting percentages. */
protected NumberFormat _percFormat;
}