public class GenericMetadataChecksummer extends AbstractMetadataChecksummer
Generic implementation of IMetadataChecksummer
that uses
specified source field names and their values for the checksum. The name
and values are simply returned as is, joined using this format:
fieldName=fieldValue;fieldName=fieldValue;...
.
You have the option to keep the checksum as a document metadata field.
When AbstractMetadataChecksummer.setKeep(boolean)
is true
, the checksum will be
stored in the target field name specified. If you do not specify any,
it stores it under the metadata field name
CollectorMetadata.COLLECTOR_CHECKSUM_METADATA
.
Since 1.9.0, it is possible to use regular expressions to match
fields.
Use sourceFields
to list all fields to use, separated by commas.
Use sourceFieldsRegex
to match fields to use using a regular
expression.
Both sourceFields
and sourceFieldsRegex
can be used
together. Matching fields from both will be combined, in the order
provided/matched, starting with sourceFields
entries.
<metadataChecksummer class="com.norconex.collector.core.checksum.impl.GenericMetadataChecksummer" disabled="[false|true]" keep="[false|true]" targetField="(field to store checksum)"> <sourceFields> (optional coma-separated list fields used to create checksum) </sourceFields> <sourceFieldsRegex> (regular expression matching fields used to create checksum) </sourceFieldsRegex> </metadataChecksummer>
The following uses a combination of two (fictitious) fields called "docLastModified" and "docSize" to make the checksum.
<metadataChecksummer class="com.norconex.collector.core.checksum.impl.GenericMetadataChecksummer"> <sourceFields>docLastModified,docSize</sourceFields> </metadataChecksummer>
Constructor and Description |
---|
GenericMetadataChecksummer() |
Modifier and Type | Method and Description |
---|---|
protected String |
doCreateMetaChecksum(Properties metadata) |
boolean |
equals(Object other) |
String[] |
getSourceFields()
Gets the metadata fields used to construct a checksum.
|
String |
getSourceFieldsRegex()
Gets the regular expression matching metadata fields used to construct
a checksum.
|
int |
hashCode() |
boolean |
isDisabled()
Whether this checksummer is disabled or not.
|
protected void |
loadChecksummerFromXML(XMLConfiguration xml) |
protected void |
saveChecksummerToXML(EnhancedXMLStreamWriter writer) |
void |
setDisabled(boolean disabled)
Sets whether this checksummer is disabled or not.
|
void |
setSourceFields(String... fields)
Sets the metadata header fields used construct a checksum.
|
void |
setSourceFieldsRegex(String sourceFieldsRegex)
Sets the regular expression matching metadata fields used construct
a checksum.
|
String |
toString() |
createMetadataChecksum, getTargetField, isKeep, loadFromXML, saveToXML, setKeep, setTargetField
protected String doCreateMetaChecksum(Properties metadata)
doCreateMetaChecksum
in class AbstractMetadataChecksummer
public String[] getSourceFields()
public void setSourceFields(String... fields)
fields
- fields to use for checksumpublic String getSourceFieldsRegex()
public void setSourceFieldsRegex(String sourceFieldsRegex)
sourceFieldsRegex
- regular expressionpublic boolean isDisabled()
null
).true
if disabledpublic void setDisabled(boolean disabled)
null
).disabled
- true
if disabledprotected void loadChecksummerFromXML(XMLConfiguration xml)
loadChecksummerFromXML
in class AbstractMetadataChecksummer
protected void saveChecksummerToXML(EnhancedXMLStreamWriter writer) throws XMLStreamException
saveChecksummerToXML
in class AbstractMetadataChecksummer
XMLStreamException
public boolean equals(Object other)
equals
in class AbstractMetadataChecksummer
public int hashCode()
hashCode
in class AbstractMetadataChecksummer
public String toString()
toString
in class AbstractMetadataChecksummer
Copyright © 2014–2021 Norconex Inc.. All rights reserved.