public class CopyPropertyFilter extends AbstractDocumentFilter
Document
filter that copies a Property's
values to another property. The new property name is added to the
Document's set of properties, if it is not already in that set.
If the overwrite
flag is true
, the copied
property values replace any existing values of the target property.
Otherwise, the copied property values supplement any existing values
of the target property.
Example documentFilters.xml
Configurations:
The following example copies HeadLine
and ByLine
property
values to the Title
and Author
properties, respectively.
The original HeadLine
and ByLine
properties will still be
indexed and searchable.
<!-- Make news articles appear in title and author searches. -->
<bean id="MoveNewsProps"
class="com.google.enterprise.connector.util.filter.CopyPropertyFilter">
<property name="propertyNameMap">
<map>
<entry key="HeadLine" value="Title"/>
<entry key="ByLine" value="Author"/>
</map>
</property>
<property name="overwrite" value="false"/>
</bean>
Constructor and Description |
---|
CopyPropertyFilter() |
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
produced by copying other Properties. |
void |
setOverwrite(boolean overwrite)
Sets the
overwrite values flag. |
void |
setPropertyNameMap(java.util.Map<java.lang.String,java.lang.String> propertyNameMap)
Sets the property name map.
|
java.lang.String |
toString() |
getPropertyValues, newDocumentFilter
public void setPropertyNameMap(java.util.Map<java.lang.String,java.lang.String> propertyNameMap)
Map<String, String>
maps source property name (the key
) to the destination
property name (the value
).propertyNameMap
- sourceName-to-destinationName Map
java.lang.NullPointerException
- if propertyNameMap
is null
public void setOverwrite(boolean overwrite)
overwrite
values flag. If true
, any existing
values of the copied-to property are overwritten with the copied values.
If false
, the copied values augment those of the copied-to
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 configured as a copy from another property, then that other property's
values are copied to the named property. If the overwrite
flag
is true
, then the copied property values replace any existing
values of the requested property. Otherwise, the copied property values
supplement any existing values of the requested 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
produced by copying other Properties.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