com.google.enterprise.adaptor.prebuilt
Class PrebuiltTransforms

java.lang.Object
  extended by com.google.enterprise.adaptor.prebuilt.PrebuiltTransforms

public class PrebuiltTransforms
extends Object

Common transforms that you would expect to have available.


Method Summary
static DocumentTransform copyMetadata(Map<String,String> config)
          Returns a transform that copies metadata values from one key to another.
static DocumentTransform deleteMetadata(Map<String,String> config)
          Returns a transform that deletes metadata keys.
static DocumentTransform moveMetadata(Map<String,String> config)
          Returns a transform that moves metadata values from one key to another.
static DocumentTransform replaceMetadata(Map<String,String> config)
          Returns a transform that preforms string replacements within metadata values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

copyMetadata

public static DocumentTransform copyMetadata(Map<String,String> config)
Returns a transform that copies metadata values from one key to another. The "overwrite" key can be set to "true" to cause the destination to be replaced; otherwise the destination key is supplemented.

Copies are defined by pairs of "X.from" and "X.to" configuration entries (where X is an integer). The value for each is a metadata key. Copies are applied in the increasing order of the integers.

Example configuration:

overwrite=false
3.from=colour
3.to=color
5.from=author
5.to=contributors


moveMetadata

public static DocumentTransform moveMetadata(Map<String,String> config)
Returns a transform that moves metadata values from one key to another. This method returns a transform that behaves identically to copyMetadata(java.util.Map), except that the source keys are removed. If the source key has no metadata values then the destination is left as-is.


deleteMetadata

public static DocumentTransform deleteMetadata(Map<String,String> config)
Returns a transform that deletes metadata keys. The keys to be deleted are defined by "keyX" configuration entries (where X is an integer).

Example configuration:

key2=sensitive
key4=unhelpful


replaceMetadata

public static DocumentTransform replaceMetadata(Map<String,String> config)
Returns a transform that preforms string replacements within metadata values. The keys to have replacements done on their values are defined by "keyX" configuration entries (where X is an integer). The "overwrite" configuration key can be set to "false" to cause the original string to be left intact; otherwise the original string is replaced.

The needle to be found is configured via a "string" or "pattern" configuration key. string's value is treated as a literal string to be found whereas pattern's value is treated as a regular expression. The replacement is defined by "replacement" and is interpreted as a literal string if "string" was provided and a regular expression replacement if "pattern" was provided.

Example configuration:

overwrite=false
key1=favorite
key5=least favorite
pattern=(Java|C|Perl)
replacement=$1 (but it should be x86 assembler)