diff --git a/projects/samskivert/src/java/com/samskivert/servlet/util/HTMLUtil.java b/projects/samskivert/src/java/com/samskivert/servlet/util/HTMLUtil.java index 2c233e4d..e7458c1d 100644 --- a/projects/samskivert/src/java/com/samskivert/servlet/util/HTMLUtil.java +++ b/projects/samskivert/src/java/com/samskivert/servlet/util/HTMLUtil.java @@ -58,4 +58,17 @@ public class HTMLUtil text = StringUtil.replace(text, "\r\n\r\n", "\r\n

\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", "
\n"); + return text; + } } diff --git a/projects/samskivert/src/java/com/samskivert/velocity/StringTool.java b/projects/samskivert/src/java/com/samskivert/velocity/StringTool.java index 86ae7c42..f7d09783 100644 --- a/projects/samskivert/src/java/com/samskivert/velocity/StringTool.java +++ b/projects/samskivert/src/java/com/samskivert/velocity/StringTool.java @@ -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; }