| java.lang.Object org.sakaiproject.util.FormattedText
FormattedText | public class FormattedText (Code) | | FormattedText provides support for user entry of formatted text; the formatted text is HTML. This includes text formatting in user input such as bold, underline, and fonts.
|
Method Summary | |
public static String | convertFormattedTextToPlaintext(String value) Converts the given HTML formatted text to plain text - loses formatting information. | public static String | convertOldFormattedText(String value) Converts old-style formatted text to the new style. | public static String | convertPlaintextToFormattedText(String value) Converts the given plain text into HTML formatted text. | public static String | decodeFormattedTextAttribute(Element element, String baseAttributeName) Retrieves a formatted text attribute from an XML element; converts from older forms of formatted text or plaintext, if found. | public static String | decodeNumericCharacterReferences(String value) | public static void | encodeFormattedTextAttribute(Element element, String baseAttributeName, String value) Store the given formatted text in the given XML element; stores both a formatted text representation, and a plaintext representation (plaintext means the formatting has been stripped). | public static String | encodeUnicode(String value) Returns a String with characters above 128 as entity references.
Parameters: value - The text to encode. | public static String | escapeHtml(String value, boolean escapeNewlines) Escape the given value so that it appears as-is in HTML - that is, HTML meta-characters like '<' are escaped to HTML character entity references like '<'. | public static String | escapeHtmlFormattedText(String value) Prepares the given HTML formatted text for output as part of an HTML document.
Parameters: value - The formatted text to output in an HTML document. | public static String | escapeHtmlFormattedTextSupressNewlines(String value) Prepares the given HTML formatted text for output as part of an HTML document, removing newlines ("<br />").
Parameters: value - The formatted text to output in an HTML document. | public static String | escapeHtmlFormattedTextarea(String value) Prepares the given formatted text for editing within the WYSIWYG editor. | public static String | processAnchor(String anchor) Returns a String with HTML anchor normalized to include only href and target="_blank" for safe display by a browser.
Parameters: anchor - The anchor tag to be normalized. | public static String | processEscapedHtml(String source) Processes and validates character data as HTML. | public static String | processFormattedText(String strFromBrowser, StringBuffer errorMessages) Processes and validates user-entered HTML received from the web browser (from the WYSIWYG editor). | public static String | processFormattedText(String strFromBrowser, StringBuffer errorMessages, boolean checkForEvilTags, boolean replaceWhitespaceTags) Processes and validates HTML formatted text received from the web browser (from the WYSIWYG editor). | public static String | processHtmlDocument(String strFromBrowser, StringBuffer errorMessages) Process an HTML document that has been edited using the formatted text widget. | public static boolean | trimFormattedText(String formattedText, int maxNumOfChars, StringBuffer strTrimmed) Trims a formatted text string to the given maximum number of displayed characters, preserving formatting. | public static String | unEscapeHtml(String value) Returns a String with HTML entity references converted to characters suitable for processing as formatted text.
Parameters: value - The text containing entity references (e.g., a News item description). |
convertFormattedTextToPlaintext | public static String convertFormattedTextToPlaintext(String value)(Code) | | Converts the given HTML formatted text to plain text - loses formatting information. For example, The formatted text "Hello
World!" becomes plain text "Hello \nWorld!" Strips all formatting information from the formatted text
Parameters: value - The formatted text to convert The plain text (all formatting removed) |
convertOldFormattedText | public static String convertOldFormattedText(String value)(Code) | | Converts old-style formatted text to the new style. Previous to Sakai release 1.5, displayed line breaks were stored as "\n". Now, displayed like breaks are properly stored in the HTML-standard way as " ". This method converts from the
previous form.
Parameters: value - |
convertPlaintextToFormattedText | public static String convertPlaintextToFormattedText(String value)(Code) | | Converts the given plain text into HTML formatted text. Conversion to formatted text involves escaping characters that are used for formatting (such as the '<' character). Also converts plaintext line breaks into HTML line breaks ("
").
Parameters: value - The plain text to convert to formatted text The converted plain text, now as formatted text |
decodeFormattedTextAttribute | public static String decodeFormattedTextAttribute(Element element, String baseAttributeName)(Code) | | Retrieves a formatted text attribute from an XML element; converts from older forms of formatted text or plaintext, if found. For example, if the baseAttributeName "foo" is specified, the attribute "foo-html" will be looked for first, and then
"foo-formatted", and finally just "foo" (plaintext).
Parameters: element - The XML element from which to retrieve the formatted text attribute Parameters: baseAttributeName - The base attribute name of the formatted text attribute |
decodeNumericCharacterReferences | public static String decodeNumericCharacterReferences(String value)(Code) | | decode any HTML Numeric Character References of the style: hexnumber; or decimalnumber; or of our own special style: ^^Xhexnumber^ or ^^decimalnumber^
|
encodeFormattedTextAttribute | public static void encodeFormattedTextAttribute(Element element, String baseAttributeName, String value)(Code) | | Store the given formatted text in the given XML element; stores both a formatted text representation, and a plaintext representation (plaintext means the formatting has been stripped).
|
encodeUnicode | public static String encodeUnicode(String value)(Code) | | Returns a String with characters above 128 as entity references.
Parameters: value - The text to encode. The encoded text. |
escapeHtml | public static String escapeHtml(String value, boolean escapeNewlines)(Code) | | Escape the given value so that it appears as-is in HTML - that is, HTML meta-characters like '<' are escaped to HTML character entity references like '<'. Markup, amper, quote are escaped. Whitespace is not.
Parameters: value - The string to escape. Parameters: escapeNewlines - Whether to escape newlines as "<br />\n" so that they appear as HTML line breaks. value fully escaped for HTML. |
escapeHtmlFormattedText | public static String escapeHtmlFormattedText(String value)(Code) | | Prepares the given HTML formatted text for output as part of an HTML document.
Parameters: value - The formatted text to output in an HTML document. The string to include in an HTML document. |
escapeHtmlFormattedTextSupressNewlines | public static String escapeHtmlFormattedTextSupressNewlines(String value)(Code) | | Prepares the given HTML formatted text for output as part of an HTML document, removing newlines ("<br />").
Parameters: value - The formatted text to output in an HTML document. The string to include in an HTML document. |
escapeHtmlFormattedTextarea | public static String escapeHtmlFormattedTextarea(String value)(Code) | | Prepares the given formatted text for editing within the WYSIWYG editor. All HTML meta-characters in the string will be escaped.
Parameters: value - The formatted text to escape The string to use as the value of the formatted textarea widget |
processAnchor | public static String processAnchor(String anchor)(Code) | | Returns a String with HTML anchor normalized to include only href and target="_blank" for safe display by a browser.
Parameters: anchor - The anchor tag to be normalized. The anchor tag containing only href and target="_blank". |
processEscapedHtml | public static String processEscapedHtml(String source)(Code) | | Processes and validates character data as HTML. Disallows dangerous stuff such as <SCRIPT> JavaScript tags. Encodes the text according to the formatted text specification, for the rest of the system to use.
Parameters: source - The escaped HTML (e.g., from the News service) The validated processed formatted text, ready for use by the system. |
processFormattedText | public static String processFormattedText(String strFromBrowser, StringBuffer errorMessages)(Code) | | Processes and validates user-entered HTML received from the web browser (from the WYSIWYG editor). Validates that the user input follows the Sakai formatted text specification; disallows dangerous stuff such as <SCRIPT> JavaScript tags.
Encodes the text according to the formatted text specification, for the rest of the system to use.
Parameters: strFromBrowser - The formatted text as sent from the web browser (from the WYSIWYG editor) Parameters: errorMessages - User-readable error messages will be returned here. The validated processed formatted text, ready for use by the system. |
processFormattedText | public static String processFormattedText(String strFromBrowser, StringBuffer errorMessages, boolean checkForEvilTags, boolean replaceWhitespaceTags)(Code) | | Processes and validates HTML formatted text received from the web browser (from the WYSIWYG editor). Validates that the user input follows the Sakai formatted text specification; can disallow dangerous stuff such as <SCRIPT> JavaScript tags.
Encodes the text according to the formatted text specification, for the rest of the system to use.
Parameters: strFromBrowser - The formatted text as sent from the web browser (from the WYSIWYG editor) Parameters: errorMessages - User-readable error messages will be returned here. Parameters: checkForEvilTags - If true, check for tags and attributes that shouldn't be in formatted text Parameters: replaceWhitespaceTags - If true, clean up line breaks to be like "<br />". The validated processed HTML formatted text, ready for use by the system. |
processHtmlDocument | public static String processHtmlDocument(String strFromBrowser, StringBuffer errorMessages)(Code) | | Process an HTML document that has been edited using the formatted text widget. The document can contain any valid HTML; it will NOT be checked to eliminate things like image tags, script tags, etc, because it is its own document.
Parameters: strFromBrowser - Parameters: errorMessages - |
trimFormattedText | public static boolean trimFormattedText(String formattedText, int maxNumOfChars, StringBuffer strTrimmed)(Code) | | Trims a formatted text string to the given maximum number of displayed characters, preserving formatting. For example, trim("Hello & World!", 9) returns "Hello & W" Ignores HTML comments like ""
Parameters: formattedText - The formatted text to trim Parameters: maxNumOfChars - The maximum number of displayed characters in the returned trimmed formatted text. Parameters: strTrimmed - A StringBuffer to hold the trimmed formatted text true If the formatted text was trimmed |
unEscapeHtml | public static String unEscapeHtml(String value)(Code) | | Returns a String with HTML entity references converted to characters suitable for processing as formatted text.
Parameters: value - The text containing entity references (e.g., a News item description). The HTML, ready for processing. |
|
|