Implemented experimental formatParagraphs() method that uses p tags to format paragraphs

This commit is contained in:
hns 2003-09-19 16:12:48 +00:00
parent 253ca75822
commit 186f7d37d7

View file

@ -65,7 +65,7 @@ public class GlobalObject extends ScriptableObject {
String[] globalFuncs = {
"renderSkin", "renderSkinAsString", "getProperty",
"authenticate", "createSkin", "format", "encode",
"encodeXml", "encodeForm", "stripTags",
"encodeXml", "encodeForm", "stripTags", "formatParagraphs",
"getXmlDocument", "getHtmlDocument",
"getDBConnection", "getURL", "write", "writeln"
};
@ -372,6 +372,34 @@ public class GlobalObject extends ScriptableObject {
return HtmlEncoder.encode(toString(obj));
}
/**
*
*
* @param str ...
*
* @return ...
*/
public String formatParagraphs(Object obj) {
String str = toString(obj);
if (str == null) {
return null;
}
int l = str.length();
if (l == 0) {
return "";
}
// try to make stringbuffer large enough from the start
StringBuffer buffer = new StringBuffer(Math.round(l * 1.4f));
HtmlEncoder.encode(str, buffer, true, null);
return buffer.toString();
}
/**
*
*