/** * Strips string of HTML and returns plain text. * * @param s * @return */ public static String stripHtml(String s) { return FormattedText.convertFormattedTextToPlaintext(s); }
/** * Strips string of HTML and returns plain text. * * @param s * @return */ public static String stripHtml(String s) { return FormattedText.convertFormattedTextToPlaintext(s); }
/** * Strips string of HTML, escaping anything that is left to return plain text. * * <p>Deals better with poorly formed HTML than just stripHtml and is best for XSS protection, not for storing actual data. * * @param s The string to process * @return */ public static String stripAndCleanHtml(String s) { //Attempt to strip HTML. This doesn't work on poorly formatted HTML though String stripped = FormattedText.convertFormattedTextToPlaintext(s); //so we escape anything that is left return StringEscapeUtils.escapeHtml(stripped); }
/** * Strips string of HTML, escaping anything that is left to return plain text. * * <p>Deals better with poorly formed HTML than just stripHtml and is best for XSS protection, not for storing actual data. * * @param s The string to process * @return */ public static String stripAndCleanHtml(String s) { //Attempt to strip HTML. This doesn't work on poorly formatted HTML though String stripped = FormattedText.convertFormattedTextToPlaintext(s); //so we escape anything that is left return StringEscapeUtils.escapeHtml(stripped); }
/** * customized html from fck editor for calendar * * @param htmlText * a html formatted text * @return a plain text */ public static String convertFormattedHtmlTextToPlaintext(String htmlText) { /* * replace "<p>" with nothing. Replace "</p>" and "<p />" HTML * tags with "<br />" */ if (htmlText == null) return ""; htmlText = htmlText.replaceAll("<p>", ""); htmlText = htmlText.replaceAll("</p>", "<br />"); htmlText = htmlText.replaceAll("<p />", "<br />"); return FormattedText.convertFormattedTextToPlaintext(htmlText); }
protected String plainTextContent(AssignmentSubmission s, String submissionOrReleaseGrade) { if("submission".equals(submissionOrReleaseGrade)) return FormattedText.convertFormattedTextToPlaintext(htmlContent(s)); else if ("releasegrade".equals(submissionOrReleaseGrade)) return FormattedText.convertFormattedTextToPlaintext(htmlContentReleaseGrade(s)); else return FormattedText.convertFormattedTextToPlaintext(htmlContentReleaseResubmission(s)); }
protected String plainTextContent(Event event) { String content = htmlContent(event); content = FormattedText.convertFormattedTextToPlaintext(content); return content; }
/** * @param formattedText The formatted text to convert to plain text and then to trim * @param maxNumOfChars The maximum number of characters for the trimmed text. * @return Ellipse A String to represent the ending pattern of the trimmed text */ public String doPlainTextAndLimit(String formattedText, int maxNumOfChars, String ellipse) { formattedText = StringUtils.trimToNull(formattedText); if(formattedText == null || formattedText.equalsIgnoreCase("<br/>") || formattedText.equalsIgnoreCase("<br>")|| formattedText.equals(" ") || FormattedText.escapeHtml(formattedText,false).equals("<br type="_moz" />")){ return ""; } StringBuilder sb = new StringBuilder(); String text = FormattedText.convertFormattedTextToPlaintext(formattedText); if(maxNumOfChars>text.length()){ maxNumOfChars=text.length(); } String trimmedText=text.substring(0, maxNumOfChars); sb.setLength(0); sb.append(trimmedText).append(ellipse); return Validator.escapeHtml(sb.toString()); } }
/** * Get the message for the email. * * @param event * The event that matched criteria to cause the notification. * @return the message for the email. */ protected String getNotificationMessage(AssignmentSubmission s, String submissionOrReleaseGrade) { StringBuilder message = new StringBuilder(); message.append(MIME_ADVISORY); message.append(BOUNDARY_LINE); message.append(plainTextHeaders()); message.append(plainTextContent(s, submissionOrReleaseGrade)); message.append(FormattedText.convertFormattedTextToPlaintext(htmlContentAttachments(s))); message.append(BOUNDARY_LINE); message.append(htmlHeaders()); message.append(htmlPreamble(submissionOrReleaseGrade)); if("submission".equals(submissionOrReleaseGrade)) message.append(htmlContent(s)); else if ("releasegrade".equals(submissionOrReleaseGrade)) message.append(htmlContentReleaseGrade(s)); else message.append(htmlContentReleaseResubmission(s)); message.append(htmlContentAttachments(s)); message.append(htmlEnd()); message.append(TERMINATION_LINE); return message.toString(); }
buf.append( msg.getBody() ); else buf.append(FormattedText.convertFormattedTextToPlaintext(msg.getHtmlBody()));
buf.append(FormattedText.convertFormattedTextToPlaintext(rb.getFormattedMessage("noti.header.add", new Object[]{title,url}))); buf.append(FormattedText.convertFormattedTextToPlaintext(rb.getFormattedMessage("noti.header.update", new Object[]{title,url}))); buf.append(hdr.getDate().toStringLocalFull()); buf.append(newline); buf.append(FormattedText.convertFormattedTextToPlaintext(msg.getBody())); buf.append(newline);
/** * Update XML from persistence * @param section */ public void update(SectionDataIfc section) { // identity setIdent("" + section.getSectionId()); setTitle(FormattedText.convertFormattedTextToPlaintext(section.getTitle())); // metadata // Where the heck do these come from? Looks like not being used. // If required we could extract keywords by weighting, and // set rubrics identical to description, or, we could eliminate these from XML. // well, we can add metadata from users' input - lydial setFieldentry("SECTION_INFORMATION", section.getDescription()); setFieldentry("SECTION_OBJECTIVE", section.getSectionMetaDataByLabel(SectionMetaDataIfc.OBJECTIVES)); setFieldentry("SECTION_KEYWORD", section.getSectionMetaDataByLabel(SectionMetaDataIfc.KEYWORDS)); setFieldentry("SECTION_RUBRIC", section.getSectionMetaDataByLabel(SectionMetaDataIfc.RUBRICS)); setFieldentry("ATTACHMENT", getAttachment(section)); setFieldentry("QUESTIONS_ORDERING", section.getSectionMetaDataByLabel(SectionDataIfc.QUESTIONS_ORDERING)); // items addItems(section.getItemArray()); }
/** * Update XML from persistence * @param section */ public void update(SectionDataIfc section) { // identity setIdent("" + section.getSectionId()); setTitle(FormattedText.convertFormattedTextToPlaintext(section.getTitle())); // metadata // Where the heck do these come from? Looks like not being used. // If required we could extract keywords by weighting, and // set rubrics identical to description, or, we could eliminate these from XML. // well, we can add metadata from users' input - lydial setFieldentry("SECTION_INFORMATION", section.getDescription()); setFieldentry("SECTION_OBJECTIVE", section.getSectionMetaDataByLabel(SectionMetaDataIfc.OBJECTIVES)); setFieldentry("SECTION_KEYWORD", section.getSectionMetaDataByLabel(SectionMetaDataIfc.KEYWORDS)); setFieldentry("SECTION_RUBRIC", section.getSectionMetaDataByLabel(SectionMetaDataIfc.RUBRICS)); setFieldentry("ATTACHMENT", getAttachment(section)); setFieldentry("QUESTIONS_ORDERING", section.getSectionMetaDataByLabel(SectionDataIfc.QUESTIONS_ORDERING)); // items addItems(section.getItemArray()); }
Assessment assessmentXml = assessmentHelper.readXMLDocument(is); assessmentXml.setIdent(assessmentId); assessmentXml.setTitle(FormattedText.convertFormattedTextToPlaintext(assessment.getTitle())); assessmentHelper.setDescriptiveText(assessment.getDescription(), assessmentXml);
Assessment assessmentXml = assessmentHelper.readXMLDocument(is); assessmentXml.setIdent(assessmentId); assessmentXml.setTitle(FormattedText.convertFormattedTextToPlaintext(assessment.getTitle())); assessmentHelper.setDescriptiveText(assessment.getDescription(), assessmentXml);