public class PrebuiltTransforms extends Object
Modifier and Type | Method and Description |
---|---|
static MetadataTransform |
copyMetadata(Map<String,String> config)
Returns a transform that copies metadata or param values from one key to
another.
|
static MetadataTransform |
deleteMetadata(Map<String,String> config)
Returns a transform that deletes metadata or param keys.
|
static MetadataTransform |
moveMetadata(Map<String,String> config)
Returns a transform that moves metadata or param values from one key to
another.
|
static MetadataTransform |
replaceMetadata(Map<String,String> config)
Returns a transform that preforms string replacements within metadata
values.
|
public static MetadataTransform copyMetadata(Map<String,String> config)
"overwrite"
key can be set to "true"
to cause
the destination to be replaced. Otherwise if the destination is a metadata
key, its values is are supplemented. If unspecified, the default value for
"overwrite"
is "false"
for metadata and "true"
for
params.
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 or param key. Copies are applied in the increasing order of
the integers. The config keys "X.from.keyset"
and
"X.to.keyset"
may be set to metadata
or to params
to restrict the source and destination to only Metadata
or
params
, respectively. Most keys/values of interest will normally
be specified in the document's Metadata
, but some key/values of
interest (e.g. Content-Type, DocId) exist in the document's params
.
Example configuration:
overwrite=false
1.from=colour
1.to=color
2.from=author
2.to=contributors
Example configuration:
1.from=Content-Type
1.from.keyset=params
1.to=Original-Content-Type
1.to.keyset=params
config
- transform configurationpublic static MetadataTransform moveMetadata(Map<String,String> config)
copyMetadata(java.util.Map<java.lang.String, java.lang.String>)
, except that the source keys are removed.
If the source key has no values then the destination is left as-is.config
- transform configurationpublic static MetadataTransform deleteMetadata(Map<String,String> config)
"keyX"
configuration entries (where
X
is an integer). The config keys "keysetX"
may be set
to metadata
or to params
to restrict the keyX
to only Metadata
or params
, respectively.
Example configuration:
key2=sensitive
key4=unhelpful
config
- transform configurationpublic static MetadataTransform replaceMetadata(Map<String,String> config)
"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. If unspecified, the default value of
"overwrite"
is "true"
for both metadata and parames.
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)
config
- transform configuration