public class SkipDocumentFilter extends AbstractDocumentFilter
Document
filter that forces a Document to be skipped (or not)
based upon the presence/abscence of a specific Property
,
or based upon a match on one of the Values
of that
property.
Example documentFilters.xml
Configurations:
The following example skips documents that have a NoIndex Property
.
<bean id="NoIndex"
class="com.google.enterprise.connector.util.filter.SkipDocumentFilter">
<property name="propertyName" value="NoIndex"/>
<property name="skipOnMatch" value="true"/>
</bean>
The following example skips documnents whose Classification Property
value is not PUBLIC
or DECLASSIFIED
.
<!-- Filter out all but PUBLIC and DECLASSIFIED documents. -->
<bean id="Classified"
class="com.google.enterprise.connector.util.filter.SkipDocumentFilter">
<property name="propertyName" value="Classification"/>
<property name="pattern" value="(PUBLIC)|(DECLASSIFIED)"/>
<property name="skipOnMatch" value="false"/>
</bean>
Constructor and Description |
---|
SkipDocumentFilter() |
Modifier and Type | Method and Description |
---|---|
Property |
findProperty(Document source,
java.lang.String name)
Finds a
Property by name . |
java.util.Set<java.lang.String> |
getPropertyNames(Document source)
|
void |
setPattern(java.lang.String pattern)
Sets the regular expression pattern to match in the values.
|
void |
setPropertyName(java.lang.String propertyName)
Sets the the name of the
Property to match. |
void |
setSkipOnMatch(boolean skipOnMatch)
Sets the skip document behaviour flag.
|
java.lang.String |
toString() |
getPropertyValues, newDocumentFilter
public void setPropertyName(java.lang.String propertyName)
Property
to match. If no
pattern
is set, then any Document that exposes the
named property is considered a matching document. If a pattern
is set, then any value of the property that matches the
regular expression is considered a match.propertyName
- the name of the Property
to filterjava.lang.IllegalArgumentException
- if propertyName
is null
or emptypublic void setPattern(java.lang.String pattern) throws java.util.regex.PatternSyntaxException
pattern
must conform to the syntax defined in
Pattern
. If one of the property's values
matches this regular expression, this is considered a matching
document.
If no pattern is specified, then the mere presence of the named property would be considered a match.
pattern
- the regular expression pattern to match in the valuesjava.util.regex.PatternSyntaxException
- if pattern
's syntax is invalidpublic void setSkipOnMatch(boolean skipOnMatch)
true
skip the document on a match.
If false
skip the document on a failed match.skipOnMatch
- If true
skip the document on a match,
otherwise skip the document if the match fails.public java.util.Set<java.lang.String> getPropertyNames(Document source) throws RepositoryException
AbstractDocumentFilter
Properties
in the
source
Document
.
Filter subclasses are likely to override this method.
getPropertyNames
in class AbstractDocumentFilter
source
- the source Document
for this filterRepositoryException
- if a repository access error occursRepositoryDocumentException
- if a document has fatal
processing errorspublic Property findProperty(Document source, java.lang.String name) throws RepositoryException
AbstractDocumentFilter
Property
by name
. If the source
Document
has a property of that name, then that property
is returned.
Filter subclasses are likely to override this method.
findProperty
in class AbstractDocumentFilter
source
- the source Document
for this filtername
- the name of the property to findnull
otherwiseRepositoryException
- if a repository access error occursRepositoryDocumentException
- if a document has fatal
processing errorspublic java.lang.String toString()
toString
in class AbstractDocumentFilter