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:
@@ -58,4 +58,17 @@ public class HTMLUtil
|
||||
text = StringUtil.replace(text, "\r\n\r\n", "\r\n<p>\r\n");
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a <br> 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 <br> 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user