Package com.jalios.jcms.wysiwyg
Class JHTMLUtils
- java.lang.Object
 - 
- com.jalios.jcms.wysiwyg.JHTMLUtils
 
 
- 
public class JHTMLUtils extends java.lang.ObjectUtility class providing helper methods to work with JHTML documents.- Since:
 - jcms-10.0.0
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description static java.lang.StringREVISION 
- 
Constructor Summary
Constructors Constructor Description JHTMLUtils() 
- 
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringgetAbstract(java.lang.String jhtml)Retrieves the declared abstract content for the specified JHTML.static booleanisEmpty(java.lang.String str)Check if the specified string (raw text or HTML) is considered empty.static booleanisEmpty(java.lang.String[] array)Check if the specified array of string (raw text or HTML) is considered empty.static booleanisEmpty(java.util.Collection<java.lang.String> coll)Check if the all specified collection of string (raw text or HTML) is considered empty.static booleanisJHTML(TypeFieldEntry tfe, java.lang.String text)Check if the specified text contains JHTML.static org.jsoup.nodes.DocumentparseJHTML(java.lang.String jhtml)Parse the specified JHTML string to a JSoup Document.static java.lang.Stringsanitize(java.lang.String str)Sanitize the specified string, which may be wiki or HTML, before storage in JCMS.static org.jsoup.select.ElementsselectJHTML(org.jsoup.nodes.Document document, java.lang.String tagName)Find all JHTML tags of the specified name. 
 - 
 
- 
- 
Field Detail
- 
REVISION
public static final java.lang.String REVISION
- See Also:
 - Constant Field Values
 
 
 - 
 
- 
Method Detail
- 
isJHTML
public static boolean isJHTML(TypeFieldEntry tfe, java.lang.String text)
Check if the specified text contains JHTML.A text is considered as JHTML if any of the following condition is met:
- It is stored in a wysiwyg field,
 - It is null or empty,
 - The text match the regular expression specified by property 
wysiwg.jhtml.regex(compiled withDOTALLandCASE_INSENSITIVE).
In its default value, this regex consider a text to be JHTML if it starts with a<divtag (omitting any leading whitespaces) 
TypeFieldEntryis specified) which are neither wysiwyg nor wiki are NEVER considered as HTML.- Parameters:
 tfe- the TypeFieldEntry corresponding to the field in which text is stored, optional but highly recommended for better detectiontext- the text to check- Returns:
 - true if this text is HTML/JHTML, false otherwise.
 - Since:
 - jcms-10.0.0
 
 
- 
parseJHTML
public static org.jsoup.nodes.Document parseJHTML(java.lang.String jhtml)
Parse the specified JHTML string to a JSoup Document.- Parameters:
 jhtml- some JTHML (can be null)- Returns:
 - a JSoup Document, never returns null
 
 
- 
selectJHTML
public static org.jsoup.select.Elements selectJHTML(org.jsoup.nodes.Document document, java.lang.String tagName)Find all JHTML tags of the specified name.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>
InvokingselectJTHML(document, "link")will return an Elements instance containing onejalios:linkElement.- Parameters:
 document- the document in which to perform the element search.tagName- the JHTML tag to search for.- Returns:
 - an Elements instance, never return null
 - Since:
 - jcms-10.0.0
 
 
- 
getAbstract
public static java.lang.String getAbstract(java.lang.String jhtml)
Retrieves the declared abstract content for the specified 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 byisJHTML(TypeFieldEntry, String).- Parameters:
 jhtml- the JHTML in which to retrieve the abstract content- Returns:
 - some HTML surrounded with a <div> or an empty string. Never returns null.
 
 
- 
isEmpty
public static boolean isEmpty(java.lang.String str)
Check if the specified string (raw text or HTML) is considered empty. A string is considered empty if :- it exclusively contains whitespace characters
 - it consists of HTML without any text and without any of the following elements :
   
img- JHTML tag 
jalios:... 
 
- Parameters:
 str- the string to test- Returns:
 - true if is considered as empty per criteria explained in method, false otherwise.
 
 
- 
isEmpty
public 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.- Parameters:
 coll- the collection to test- Returns:
 - false it there is at least one element which is not considered empty by 
isEmpty(String), true if collection or all its element are empty. - See Also:
 isEmpty(String)
 
- 
isEmpty
public static boolean isEmpty(java.lang.String[] array)
Check if the specified array of string (raw text or HTML) is considered empty.- Parameters:
 array- the array to test- Returns:
 - false it there is at least one element which is not considered empty by 
isEmpty(String), true if array or all its element are empty. - See Also:
 isEmpty(String)
 
- 
sanitize
public static java.lang.String sanitize(java.lang.String str)
Sanitize the specified string, which may be wiki or HTML, before storage in JCMS.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 usingJcmsUtil.escapeHtml(String)- Parameters:
 str- the String to sanitize- Returns:
 - the sanitized string, suitable for storage in JCMS data
 
 
 - 
 
 -