Class AbstractDirective
- java.lang.Object
-
- org.silverpeas.core.contribution.content.wysiwyg.service.directive.AbstractDirective
-
- All Implemented Interfaces:
WysiwygContentTransformerDirective
- Direct Known Subclasses:
ImageUrlAccordingToHtmlSizeDirective
,MailLinkCssApplierDirective
,OpenLinkOnBlankPageDirective
,SilverpeasLinkCssApplierDirective
,VariablesReplacementDirective
public abstract class AbstractDirective extends Object implements WysiwygContentTransformerDirective
Centralization of code.- Author:
- silveryocha
-
-
Constructor Summary
Constructors Constructor Description AbstractDirective()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
execute(String wysiwygContent)
Executes the directive on the given WYSIWYG content.protected void
modifyElementAttribute(net.htmlparser.jericho.StartTag linkStartTag, String attrName, UnaryOperator<String> newValue, Map<String,String> replacements)
Centralizes the modification of the value of an attribute.protected void
modifyElementAttributes(net.htmlparser.jericho.StartTag linkStartTag, Collection<org.silverpeas.kernel.util.Pair<String,UnaryOperator<String>>> attrDirectives, Map<String,String> replacements)
Centralizes the modification of the value of an attribute.protected abstract void
prepareReplacements(net.htmlparser.jericho.Source source, Map<String,String> replacements)
Prepares all replacements to perform.
-
-
-
Method Detail
-
execute
public String execute(String wysiwygContent)
Description copied from interface:WysiwygContentTransformerDirective
Executes the directive on the given WYSIWYG content.- Specified by:
execute
in interfaceWysiwygContentTransformerDirective
- Parameters:
wysiwygContent
- the WYSIWYG content source.- Returns:
- the WYSIWYG content on which the directive has been performed.
-
prepareReplacements
protected abstract void prepareReplacements(net.htmlparser.jericho.Source source, Map<String,String> replacements)
Prepares all replacements to perform.- Parameters:
source
- the initial source content.replacements
- the map into which replacements MUST be specified. The key represents the occurrence into source, the value the replacements.
-
modifyElementAttribute
protected void modifyElementAttribute(net.htmlparser.jericho.StartTag linkStartTag, String attrName, UnaryOperator<String> newValue, Map<String,String> replacements)
Centralizes the modification of the value of an attribute.- Parameters:
linkStartTag
- theStartTag
instance of current element.attrName
- the name of aimed attribute to modify.newValue
- theFunction
implementation taking as parameter the current value of attribute and returns the modified one. Null parameter means that attribute does not yet exist.replacements
- the map into which replacements MUST be specified. The key represents the occurrence into source, the value the replacements.
-
modifyElementAttributes
protected void modifyElementAttributes(net.htmlparser.jericho.StartTag linkStartTag, Collection<org.silverpeas.kernel.util.Pair<String,UnaryOperator<String>>> attrDirectives, Map<String,String> replacements)
Centralizes the modification of the value of an attribute.- Parameters:
linkStartTag
- theStartTag
instance of current element.attrDirectives
- collection of attributes directives. Each directive is represented by aPair
instance which on left is the name of the attribute and on the right theFunction
implementation taking as parameter the current value of attribute and returns the modified one. Null parameter means that attribute does not yet exist.replacements
- the map into which replacements MUST be specified. The key represents the occurrence into source, the value the replacements.
-
-