public class JHTMLUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
REVISION |
Constructor and Description |
---|
JHTMLUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getAbstract(java.lang.String jhtml)
Retrieves the declared abstract content for the specified JHTML.
|
static boolean |
isEmpty(java.util.Collection<java.lang.String> coll)
Check if the all specified collection of string (raw text or HTML) is considered empty.
|
static boolean |
isEmpty(java.lang.String str)
Check if the specified string (raw text or HTML) is considered empty.
|
static boolean |
isEmpty(java.lang.String[] array)
Check if the specified array of string (raw text or HTML) is considered empty.
|
static boolean |
isJHTML(TypeFieldEntry tfe,
java.lang.String text)
Check if the specified text contains JHTML.
|
static org.jsoup.nodes.Document |
parseJHTML(java.lang.String jhtml)
Parse the specified JHTML string to a JSoup Document.
|
static java.lang.String |
sanitize(java.lang.String str)
Sanitize the specified string, which may be wiki or HTML, before storage in JCMS.
|
static org.jsoup.select.Elements |
selectJHTML(org.jsoup.nodes.Document document,
java.lang.String tagName)
Find all JHTML tags of the specified name.
|
public static final java.lang.String REVISION
public static boolean isJHTML(TypeFieldEntry tfe, java.lang.String text)
A text is considered as JHTML if any of the following condition is met:
wysiwg.jhtml.regex
(compiled with DOTALL
and CASE_INSENSITIVE
).<div
tag (omitting any leading whitespaces)TypeFieldEntry
is specified) which are
neither wysiwyg nor wiki are NEVER considered as HTML.tfe
- the TypeFieldEntry corresponding to the field in which text is stored, optionnal but highly recommended for better detectiontext
- the text to checkpublic static org.jsoup.nodes.Document parseJHTML(java.lang.String jhtml)
jhtml
- some JTHML (can be null)public static org.jsoup.select.Elements selectJHTML(org.jsoup.nodes.Document document, java.lang.String tagName)
Example: Given a document for the following JHTML :
<div class="wysiwyg"> <jalios:mention id="j_2">, can you <strong>delete</strong> <jalios:link id="a_42"/> and <jalios:link id="a_43"/> ? </div>Invoking
selectJTHML(document, "link")
will return 2 jalios:link
elements.document
- the document in which to perform the element search.tagName
- the JHTML tag to search for.public static java.lang.String getAbstract(java.lang.String jhtml)
Search the first <jalios:abstract>...<jalios:abstract>
and returns its JHTML content.
When a valid abstract is found it is always returned surrounded with
<div class="wysiwyg abstract">...</div>
to ensure
it is considered as JHTML by isJHTML(TypeFieldEntry, String)
.
jhtml
- the JHTML in which to retrieve the abstract contentpublic static boolean isEmpty(java.lang.String str)
img
jalios:...
str
- the string to testpublic static boolean isEmpty(java.util.Collection<java.lang.String> coll)
coll
- the collection to testisEmpty(String)
, true if collection or all its element are empty.isEmpty(String)
public static boolean isEmpty(java.lang.String[] array)
array
- the array to testisEmpty(String)
, true if array or all its element are empty.isEmpty(String)
public static java.lang.String sanitize(java.lang.String str)
If string is considered as HTML (see isJHTML(TypeFieldEntry, String)
), it gets cleaned by Wysiwyg sanitization process.
Otherwise, string is considered to be wiki or raw text and is escaped using JcmsUtil.escapeHtml(String)
str
- the String to sanitizeCopyright © 2001-2017 Jalios SA. All Rights Reserved.