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 a CmsTagReplaceSettings instance.

Instances are reusable.

Since:
6.1.7
  • Field Summary

    Fields inherited from class org.opencms.util.CmsHtmlParser

    m_echo, m_noAutoCloseTags, m_result, TAG_ARRAY, TAG_LIST
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor that turns echo on and uses the settings for replacing tags.
  • Method Summary

    Modifier and Type
    Method
    Description
    getTagHtml(org.htmlparser.Tag tag)
    Overridden to also return the attributes of the Tag.
    boolean
    Returns the changedContent.
    process(String html, 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

    Methods inherited from class org.htmlparser.visitors.NodeVisitor

    beginParsing, finishedParsing, shouldRecurseChildren, shouldRecurseSelf

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CmsTagReplaceParser

      Default constructor that turns echo on and uses the settings for replacing tags.

      Parameters:
      settings - the settings to use for tag replacement.
  • Method Details

    • getTagHtml

      public String getTagHtml(org.htmlparser.Tag tag)
      Overridden to also return the attributes of the Tag.

      Overrides:
      getTagHtml in class org.opencms.util.CmsHtmlParser
      See Also:
      • CmsHtmlParser.getTagHtml(org.htmlparser.Tag)
    • process

      public String process(String html, 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 interface org.opencms.util.I_CmsHtmlNodeVisitor
      Overrides:
      process in class org.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 interface org.opencms.util.I_CmsHtmlNodeVisitor
      Overrides:
      visitEndTag in class org.opencms.util.CmsHtmlParser
      See Also:
      • CmsHtmlParser.visitEndTag(org.htmlparser.Tag)
    • visitTag

      public void visitTag(org.htmlparser.Tag tag)
      Specified by:
      visitTag in interface org.opencms.util.I_CmsHtmlNodeVisitor
      Overrides:
      visitTag in class org.opencms.util.CmsHtmlParser
      See Also:
      • CmsHtmlParser.visitTag(org.htmlparser.Tag)
    • isChangedContent

      public boolean isChangedContent()
      Returns the changedContent.

      Returns:
      the changedContent