com.norconex.importer.filter.impl
Class RegexMetadataFilter

java.lang.Object
  extended by com.norconex.importer.filter.AbstractOnMatchFilter
      extended by com.norconex.importer.filter.impl.RegexMetadataFilter
All Implemented Interfaces:
IXMLConfigurable, IDocumentFilter, IOnMatchFilter, IImportHandler, Serializable

public class RegexMetadataFilter
extends AbstractOnMatchFilter
implements IDocumentFilter, IXMLConfigurable

Accepts or rejects a document based on its property values using regular expression.

XML configuration usage:

  <filter class="com.norconex.importer.filter.RegexMetadataFilter"
          onMatch="[include|exclude]" 
          caseSensitive="[false|true]" >
          property="(name of metadata name to match)"
      (regular expression of value to match)
  </filter>
 

Author:
Pascal Essiembre
See Also:
Serialized Form

Constructor Summary
RegexMetadataFilter()
           
RegexMetadataFilter(String header, String regex)
           
RegexMetadataFilter(String header, String regex, OnMatch onMatch)
           
RegexMetadataFilter(String header, String regex, OnMatch onMatch, boolean caseSensitive)
           
 
Method Summary
 boolean acceptDocument(InputStream document, Properties metadata, boolean parsed)
          Whether to accepts a document.
 boolean equals(Object obj)
           
 String getProperty()
           
 String getRegex()
           
 int hashCode()
           
 boolean isCaseSensitive()
           
 void loadFromXML(Reader in)
           
 void saveToXML(Writer out)
           
 void setCaseSensitive(boolean caseSensitive)
           
 void setProperty(String property)
           
 void setRegex(String regex)
           
 String toString()
           
 
Methods inherited from class com.norconex.importer.filter.AbstractOnMatchFilter
getOnMatch, loadFromXML, saveToXML, setOnMatch
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RegexMetadataFilter

public RegexMetadataFilter()

RegexMetadataFilter

public RegexMetadataFilter(String header,
                           String regex)

RegexMetadataFilter

public RegexMetadataFilter(String header,
                           String regex,
                           OnMatch onMatch)

RegexMetadataFilter

public RegexMetadataFilter(String header,
                           String regex,
                           OnMatch onMatch,
                           boolean caseSensitive)
Method Detail

getRegex

public String getRegex()

isCaseSensitive

public boolean isCaseSensitive()

getProperty

public String getProperty()

setCaseSensitive

public void setCaseSensitive(boolean caseSensitive)

setProperty

public void setProperty(String property)

setRegex

public void setRegex(String regex)

acceptDocument

public final boolean acceptDocument(InputStream document,
                                    Properties metadata,
                                    boolean parsed)
                             throws IOException
Description copied from interface: IDocumentFilter
Whether to accepts a document.

Specified by:
acceptDocument in interface IDocumentFilter
Parameters:
document - the document to evaluate
metadata - document metadata
parsed - whether the document has been parsed already or not (a parsed document should normally be text-based)
Returns:
true if document is accepted
Throws:
IOException - problem reading the document

loadFromXML

public void loadFromXML(Reader in)
Specified by:
loadFromXML in interface IXMLConfigurable

saveToXML

public void saveToXML(Writer out)
               throws IOException
Specified by:
saveToXML in interface IXMLConfigurable
Throws:
IOException

toString

public String toString()
Overrides:
toString in class AbstractOnMatchFilter

hashCode

public int hashCode()
Overrides:
hashCode in class AbstractOnMatchFilter

equals

public boolean equals(Object obj)
Overrides:
equals in class AbstractOnMatchFilter


Copyright © 2009-2013 Norconex Inc.. All Rights Reserved.