Class PrunedTag

java.lang.Object
org.codelibs.fess.util.PrunedTag

public class PrunedTag extends Object
Represents a tag configuration for pruning HTML content during document processing. This class defines tag patterns that match HTML elements based on tag name, CSS class, ID, or custom attributes. It is used to identify and remove unwanted HTML elements from crawled documents.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new PrunedTag instance with the specified tag name.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    int
     
    boolean
    matches(Node node)
    Checks if this pruned tag configuration matches the given DOM node.
    static PrunedTag[]
    parse(String value)
    Parses a comma-separated string of pruned tag configurations into an array of PrunedTag objects.
    void
    setAttr(String name, String value)
    Sets a custom attribute name-value pair that this pruned tag should match.
    void
    Sets the CSS class name that this pruned tag should match.
    void
    Sets the ID attribute value that this pruned tag should match.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • PrunedTag

      public PrunedTag(String tag)
      Creates a new PrunedTag instance with the specified tag name.
      Parameters:
      tag - the HTML tag name to match (e.g., "div", "span", "p")
  • Method Details

    • matches

      public boolean matches(Node node)
      Checks if this pruned tag configuration matches the given DOM node. The matching is based on tag name, and optionally ID, CSS class, or custom attributes.
      Parameters:
      node - the DOM node to check against this pruned tag configuration
      Returns:
      true if the node matches this pruned tag configuration, false otherwise
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • setId

      public void setId(String id)
      Sets the ID attribute value that this pruned tag should match.
      Parameters:
      id - the ID attribute value to match
    • setCss

      public void setCss(String css)
      Sets the CSS class name that this pruned tag should match.
      Parameters:
      css - the CSS class name to match
    • setAttr

      public void setAttr(String name, String value)
      Sets a custom attribute name-value pair that this pruned tag should match.
      Parameters:
      name - the attribute name to match
      value - the attribute value to match
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • parse

      public static PrunedTag[] parse(String value)
      Parses a comma-separated string of pruned tag configurations into an array of PrunedTag objects. Each tag configuration follows the pattern: tagname[attr=value].classname#id Examples: - "div.content" matches div elements with class "content" - "span#header" matches span elements with ID "header" - "p[data-type=ad]" matches p elements with data-type attribute equal to "ad"
      Parameters:
      value - the comma-separated string of pruned tag configurations
      Returns:
      an array of PrunedTag objects parsed from the input string
      Throws:
      FessSystemException - if the input string contains invalid tag patterns