Class DefaultHeaderFilterStrategy

java.lang.Object
org.apache.camel.support.DefaultHeaderFilterStrategy
All Implemented Interfaces:
org.apache.camel.spi.HeaderFilterStrategy

public class DefaultHeaderFilterStrategy extends Object implements org.apache.camel.spi.HeaderFilterStrategy
The default header filtering strategy. Users can configure filter by setting filter set and/or setting a regular expression. Subclass can add extended filter logic in extendedFilter(org.apache.camel.spi.HeaderFilterStrategy.Direction, String, Object, org.apache.camel.Exchange) Filters are associated with directions (in or out). "In" direction is referred to propagating headers "to" Camel message. The "out" direction is opposite which is referred to propagating headers from Camel message to a native message like JMS and CXF message. You can see example of DefaultHeaderFilterStrategy are being extended and invoked in camel-jms and camel-cxf components.
  • Field Details

    • CAMEL_FILTER_PATTERN

      @Deprecated public static final Pattern CAMEL_FILTER_PATTERN
      Deprecated.
      A filter pattern that only accepts keys starting with Camel or org.apache.camel.
    • CAMEL_FILTER_STARTS_WITH

      public static final String[] CAMEL_FILTER_STARTS_WITH
      A filter pattern for keys starting with Camel, camel, or org.apache.camel.
  • Constructor Details

    • DefaultHeaderFilterStrategy

      public DefaultHeaderFilterStrategy()
  • Method Details

    • applyFilterToCamelHeaders

      public boolean applyFilterToCamelHeaders(String headerName, Object headerValue, org.apache.camel.Exchange exchange)
      Specified by:
      applyFilterToCamelHeaders in interface org.apache.camel.spi.HeaderFilterStrategy
    • applyFilterToExternalHeaders

      public boolean applyFilterToExternalHeaders(String headerName, Object headerValue, org.apache.camel.Exchange exchange)
      Specified by:
      applyFilterToExternalHeaders in interface org.apache.camel.spi.HeaderFilterStrategy
    • getOutFilter

      public Set<String> getOutFilter()
      Gets the "out" direction filter set. The "out" direction is referred to copying headers from a Camel message to an external message.
      Returns:
      a set that contains header names that should be excluded.
    • setOutFilter

      public void setOutFilter(Set<String> value)
      Sets the "out" direction filter set. The "out" direction is referred to copying headers from a Camel message to an external message.
      Parameters:
      value - the filter
    • setOutFilterStartsWith

      public void setOutFilterStartsWith(String... outFilterStartsWith)
      Sets the "out" direction filter by starts with pattern. The "out" direction is referred to copying headers from a Camel message to an external message.
      Parameters:
      outFilterStartsWith - one or more key names to use for filtering using starts with
    • getOutFilterPattern

      public String getOutFilterPattern()
      Gets the "out" direction filter regular expression Pattern. The "out" direction is referred to copying headers from Camel message to an external message. If the pattern matches a header, the header will be filtered (skipped).
      Returns:
      regular expression filter pattern
    • setOutFilterPattern

      public void setOutFilterPattern(String value)
      Sets the "out" direction filter regular expression Pattern. The "out" direction is referred to copying headers from Camel message to an external message. If the pattern matches a header, the header will be filtered (skipped).
      Parameters:
      value - regular expression filter pattern
    • setOutFilterPattern

      public void setOutFilterPattern(Pattern pattern)
      Sets the "out" direction filter regular expression Pattern. The "out" direction is referred to copying headers from Camel message to an external message. If the pattern matches a header, the header will be filtered (skipped).
      Parameters:
      pattern - regular expression filter pattern
    • getInFilter

      public Set<String> getInFilter()
      Gets the "in" direction filter set. The "in" direction is referred to copying headers from an external message to a Camel message.
      Returns:
      a set that contains header names that should be excluded.
    • setInFilter

      public void setInFilter(Set<String> value)
      Sets the "in" direction filter set. The "in" direction is referred to copying headers from an external message to a Camel message.
      Parameters:
      value - the filter
    • setInFilterStartsWith

      public void setInFilterStartsWith(String... inFilterStartsWith)
      Sets the "in" direction filter by starts with pattern. The "in" direction is referred to copying headers from an external message to a Camel message.
      Parameters:
      inFilterStartsWith - one or more key names to use for filtering using starts with
    • getInFilterPattern

      public String getInFilterPattern()
      Gets the "in" direction filter regular expression Pattern. The "in" direction is referred to copying headers from an external message to a Camel message. If the pattern matches a header, the header will be filtered (skipped).
      Returns:
      regular expression filter pattern
    • setInFilterPattern

      public void setInFilterPattern(String value)
      Sets the "in" direction filter regular expression Pattern. The "in" direction is referred to copying headers from an external message to a Camel message. If the pattern matches a header, the header will be filtered (skipped).
      Parameters:
      value - regular expression filter pattern
    • setInFilterPattern

      public void setInFilterPattern(Pattern pattern)
      Sets the "in" direction filter regular expression Pattern. The "in" direction is referred to copying headers from an external message to a Camel message. If the pattern matches a header, the header will be filtered (skipped).
      Parameters:
      pattern - regular expression filter pattern
    • isLowerCase

      public boolean isLowerCase()
      Gets the isLowercase property which is a boolean to determine whether header names should be converted to lower case before checking it with the filter Set. It does not affect filtering using regular expression pattern.
    • setLowerCase

      public void setLowerCase(boolean value)
      Sets the isLowercase property which is a boolean to determine whether header names should be converted to lower case before checking it with the filter Set. It does not affect filtering using regular expression pattern.
    • isCaseInsensitive

      public boolean isCaseInsensitive()
      Gets the caseInsensitive property which is a boolean to determine whether header names should be case insensitive when checking it with the filter set. It does not affect filtering using regular expression pattern.
      Returns:
      true if header names is case insensitive.
    • setCaseInsensitive

      public void setCaseInsensitive(boolean caseInsensitive)
      Sets the caseInsensitive property which is a boolean to determine whether header names should be case insensitive when checking it with the filter set. It does not affect filtering using regular expression pattern,
      Parameters:
      caseInsensitive - true if header names is case insensitive.
    • isAllowNullValues

      public boolean isAllowNullValues()
    • setAllowNullValues

      public void setAllowNullValues(boolean value)
      Whether to allow null values. By default a header is skipped if its value is null. Setting this to true will preserve the header.
    • isFilterOnMatch

      public boolean isFilterOnMatch()
    • setFilterOnMatch

      public void setFilterOnMatch(boolean filterOnMatch)
      Sets the filterOnMatch property which is a boolean to determine what to do when a pattern or filter set is matched. When set to true, a match will filter out the header. This is the default value for backwards compatibility. When set to false, the pattern or filter will indicate that the header must be kept; anything not matched will be filtered (skipped).
      Parameters:
      filterOnMatch - true if a match filters (skips) the header.
    • extendedFilter

      protected boolean extendedFilter(org.apache.camel.spi.HeaderFilterStrategy.Direction direction, String key, Object value, org.apache.camel.Exchange exchange)