public class AddPropertyFilter extends AbstractDocumentFilter
Document
filter that adds a new Property
or adds values to an existing Property.
If the overwrite
flag is true
, the new
property values replace any existing values of the target property.
Otherwise, the new property values augment any existing values
of the target property.
Example documentFilters.xml
Configurations:
The following example tags all fed documents with source department
identification meta-data. It adds a DeptId
property, with
the single value Finance
to all documents.
<!-- Tag all documents fed from this department with a source ID. -->
<bean id="AddDeptId"
class="com.google.enterprise.connector.util.filter.AddPropertyFilter">
<property name="propertyName" value="DeptId"/>
<property name="propertyValue" value="Finance"/>
<property name="overwrite" value="true"/>
</bean>
The following example adds "Carlton Whitfield" to the list of Authors
for all documents.
<!-- Add myself as co-author of all documents. Gain citation notoriety. -->
<bean id="AddAuthor"
class="com.google.enterprise.connector.util.filter.AddPropertyFilter">
<property name="propertyName" value="Author"/>
<property name="propertyValue" value="Carlton Whitfield"/>
<property name="overwrite" value="false"/>
</bean>
Constructor and Description |
---|
AddPropertyFilter() |
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)
Gets the set of names of all
Properties in the
Document , including any new Properties that might be
added. |
void |
setOverwrite(boolean overwrite)
Sets the
overwrite values flag. |
void |
setPropertyName(java.lang.String propertyName)
Sets the the name of the
Property to add. |
void |
setPropertyValue(java.lang.String value)
Sets the additional String value that will be returned for
the configured Property.
|
void |
setPropertyValues(java.util.List<java.lang.String> values)
Sets the List of additional String values that will be returned for
the configured Property.
|
java.lang.String |
toString() |
getPropertyValues, newDocumentFilter
public void setPropertyName(java.lang.String propertyName)
Property
to add. If the property
already exists for this Document
, either overwrite or
augment the existing property values with the additional values.propertyName
- the name of the Property
to filterjava.lang.IllegalArgumentException
- if propertyName
is null
or emptypublic void setPropertyValues(java.util.List<java.lang.String> values)
values
- a List of String values.public void setPropertyValue(java.lang.String value)
A convenience method that wraps the value
in a single
item List and calls setPropertyValues(java.util.List<java.lang.String>)
.
value
- a String value.public void setOverwrite(boolean overwrite)
overwrite
values flag. If true
, any existing
values of the property are overwritten with the copied values.
If false
, the copied values augment those of the
property. Default overwrite
is false
.overwrite
- the overwrite flagpublic Property findProperty(Document source, java.lang.String name) throws RepositoryException
Property
by name
. If the requested property
is the filtered property, return that property with the configured
additional values.
If the overwrite
flag is true
, the new
property values replace any existing values of the target property.
Otherwise, the new property values augment any existing values
of the target property.
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.util.Set<java.lang.String> getPropertyNames(Document source) throws RepositoryException
Properties
in the
Document
, including any new Properties that might be
added.getPropertyNames
in class AbstractDocumentFilter
source
- the source Document
for this filterRepositoryException
- if a repository access error occursRepositoryDocumentException
- if a document has fatal
processing errorspublic java.lang.String toString()
toString
in class AbstractDocumentFilter