Class CmsTagReplaceParser
- java.lang.Object
-
- org.htmlparser.visitors.NodeVisitor
-
- org.opencms.util.CmsHtmlParser
-
- org.opencms.workplace.tools.content.CmsTagReplaceParser
-
- All Implemented Interfaces:
org.opencms.util.I_CmsHtmlNodeVisitor
public final class CmsTagReplaceParser extends org.opencms.util.CmsHtmlParser
Html parser / visitor combination that visits a document and replaces Tag names by using the replacement configuration of aCmsTagReplaceSettings
instance.Instances are reusable.
- Since:
- 6.1.7
-
-
Constructor Summary
Constructors Constructor Description CmsTagReplaceParser(CmsTagReplaceSettings settings)
Default constructor that turns echo on and uses the settings for replacing tags.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getTagHtml(org.htmlparser.Tag tag)
Overridden to also return the attributes of the Tag.boolean
isChangedContent()
Returns the changedContent.java.lang.String
process(java.lang.String html, java.lang.String encoding)
Extracts the text from the given html content, assuming the given html encoding.void
visitEndTag(org.htmlparser.Tag tag)
void
visitTag(org.htmlparser.Tag tag)
-
Methods inherited from class org.opencms.util.CmsHtmlParser
collapse, configureNoAutoCorrectionTags, getConfiguration, getNoAutoCloseTags, getResult, setConfiguration, setNoAutoCloseTags, visitRemarkNode, visitStringNode
-
-
-
-
Constructor Detail
-
CmsTagReplaceParser
public CmsTagReplaceParser(CmsTagReplaceSettings settings)
Default constructor that turns echo on and uses the settings for replacing tags.- Parameters:
settings
- the settings to use for tag replacement.
-
-
Method Detail
-
getTagHtml
public java.lang.String getTagHtml(org.htmlparser.Tag tag)
Overridden to also return the attributes of the Tag.- Overrides:
getTagHtml
in classorg.opencms.util.CmsHtmlParser
- See Also:
CmsHtmlParser.getTagHtml(org.htmlparser.Tag)
-
process
public java.lang.String process(java.lang.String html, java.lang.String encoding) throws org.htmlparser.util.ParserException
Extracts the text from the given html content, assuming the given html encoding.Additionally tags are replaced / removed according to the configuration of this instance.
Please note:
There are static process methods in the superclass that will not do the replacements / removals. Don't mix them up with this method.- Specified by:
process
in interfaceorg.opencms.util.I_CmsHtmlNodeVisitor
- Overrides:
process
in classorg.opencms.util.CmsHtmlParser
- Parameters:
html
- the content to extract the plain text from.encoding
- the encoding to use.- Returns:
- the text extracted from the given html content.
- Throws:
org.htmlparser.util.ParserException
- if something goes wrong.
-
visitEndTag
public void visitEndTag(org.htmlparser.Tag tag)
- Specified by:
visitEndTag
in interfaceorg.opencms.util.I_CmsHtmlNodeVisitor
- Overrides:
visitEndTag
in classorg.opencms.util.CmsHtmlParser
- See Also:
CmsHtmlParser.visitEndTag(org.htmlparser.Tag)
-
visitTag
public void visitTag(org.htmlparser.Tag tag)
- Specified by:
visitTag
in interfaceorg.opencms.util.I_CmsHtmlNodeVisitor
- Overrides:
visitTag
in classorg.opencms.util.CmsHtmlParser
- See Also:
CmsHtmlParser.visitTag(org.htmlparser.Tag)
-
isChangedContent
public boolean isChangedContent()
Returns the changedContent.- Returns:
- the changedContent
-
-