Package org.apache.camel.support
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.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.camel.spi.HeaderFilterStrategy
org.apache.camel.spi.HeaderFilterStrategy.Direction
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
applyFilterToCamelHeaders
(String headerName, Object headerValue, org.apache.camel.Exchange exchange) boolean
applyFilterToExternalHeaders
(String headerName, Object headerValue, org.apache.camel.Exchange exchange) protected boolean
extendedFilter
(org.apache.camel.spi.HeaderFilterStrategy.Direction direction, String key, Object value, org.apache.camel.Exchange exchange) Gets the "in" direction filter set.Gets the "in" direction filter regular expressionPattern
.Gets the "out" direction filter set.Gets the "out" direction filter regular expressionPattern
.boolean
boolean
Gets the caseInsensitive property which is a boolean to determine whether header names should be case insensitive when checking it with the filter set.boolean
boolean
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.void
setAllowNullValues
(boolean value) Whether to allow null values.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.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.void
setInFilter
(Set<String> value) Sets the "in" direction filter set.void
setInFilterPattern
(String value) Sets the "in" direction filter regular expressionPattern
.void
setInFilterPattern
(Pattern pattern) Sets the "in" direction filter regular expressionPattern
.void
setInFilterStartsWith
(String... inFilterStartsWith) Sets the "in" direction filter by starts with pattern.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.void
setOutFilter
(Set<String> value) Sets the "out" direction filter set.void
setOutFilterPattern
(String value) Sets the "out" direction filter regular expressionPattern
.void
setOutFilterPattern
(Pattern pattern) Sets the "out" direction filter regular expressionPattern
.void
setOutFilterStartsWith
(String... outFilterStartsWith) Sets the "out" direction filter by starts with pattern.
-
Field Details
-
CAMEL_FILTER_PATTERN
Deprecated.A filter pattern that only accepts keys starting with Camel or org.apache.camel. -
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 interfaceorg.apache.camel.spi.HeaderFilterStrategy
-
applyFilterToExternalHeaders
public boolean applyFilterToExternalHeaders(String headerName, Object headerValue, org.apache.camel.Exchange exchange) - Specified by:
applyFilterToExternalHeaders
in interfaceorg.apache.camel.spi.HeaderFilterStrategy
-
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
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
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
Gets the "out" direction filter regular expressionPattern
. 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
Sets the "out" direction filter regular expressionPattern
. 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
Sets the "out" direction filter regular expressionPattern
. 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
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
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
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
Gets the "in" direction filter regular expressionPattern
. 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
Sets the "in" direction filter regular expressionPattern
. 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
Sets the "in" direction filter regular expressionPattern
. 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
-
CAMEL_FILTER_STARTS_WITH