Class MetadataFilter

  • All Implemented Interfaces:
    IDocumentFilter, IMetadataFilter, IXMLConfigurable, IOnMatchFilter

    public class MetadataFilter
    extends Object
    implements IOnMatchFilter, IMetadataFilter, IDocumentFilter, IXMLConfigurable

    Accepts or rejects a reference based on whether one or more metadata field values are matching.

    XML configuration usage:

    
    <filter
        class="com.norconex.collector.core.filter.impl.MetadataFilter"
        onMatch="[include|exclude]">
      <fieldMatcher>
        (Expression matching one or more fields to evaluate.)
      </fieldMatcher>
      <valueMatcher>
        (Expression matching one or more values from matching fields.)
      </valueMatcher>
    </filter>

    XML usage example:

    
    <filter
        class="MetadataFilter"
        onMatch="exclude">
      <fieldMatcher>Content-Type</fieldMatcher>
      <valueMatcher>application/zip</valueMatcher>
    </filter>

    Used in a web context, the above example filters out Zip documents base on a "Content-Type" metadata field.

    Since:
    2.0.0
    Author:
    Pascal Essiembre
    • Method Detail

      • setOnMatch

        public void setOnMatch​(OnMatch onMatch)
      • getFieldMatcher

        public TextMatcher getFieldMatcher()
        Gets the field matcher.
        Returns:
        field matcher
      • setFieldMatcher

        public void setFieldMatcher​(TextMatcher fieldMatcher)
        Sets the field matcher.
        Parameters:
        fieldMatcher - field matcher
      • getValueMatcher

        public TextMatcher getValueMatcher()
        Gets the value matcher.
        Returns:
        value matcher
      • setValueMatcher

        public void setValueMatcher​(TextMatcher valueMatcher)
        Sets the value matcher.
        Parameters:
        valueMatcher - value matcher
      • acceptMetadata

        public boolean acceptMetadata​(String reference,
                                      Properties metadata)
        Description copied from interface: IMetadataFilter
        Whether to accept the metadata.
        Specified by:
        acceptMetadata in interface IMetadataFilter
        Parameters:
        reference - the reference associated with the metadata
        metadata - metadata associated with the reference
        Returns:
        true if accepted, false otherwise
      • acceptDocument

        public boolean acceptDocument​(Doc document)
        Description copied from interface: IDocumentFilter
        Whether to accept a document.
        Specified by:
        acceptDocument in interface IDocumentFilter
        Parameters:
        document - the document to accept/reject
        Returns:
        true if accepted, false otherwise
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object