Class GenericMetadataChecksummer
- java.lang.Object
-
- com.norconex.collector.core.checksum.AbstractMetadataChecksummer
-
- com.norconex.collector.core.checksum.impl.GenericMetadataChecksummer
-
- All Implemented Interfaces:
IMetadataChecksummer
,IXMLConfigurable
public class GenericMetadataChecksummer extends AbstractMetadataChecksummer
Generic implementation of
IMetadataChecksummer
that uses specified field names and their values to create a 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)
istrue
, the checksum will be stored in the target field name specified. If you do not specify any, it stores it under the metadata field nameCrawlDocMetadata.CHECKSUM_METADATA
.XML configuration usage:
<metadataChecksummer class="com.norconex.collector.core.checksum.impl.GenericMetadataChecksummer" keep="[false|true]" toField="(optional field to store the checksum)"> <fieldMatcher> (expression matching fields used to create the checksum) </fieldMatcher> </metadataChecksummer>
toField
is ignored unless thekeep
attribute is set totrue
.XML usage example:
<metadataChecksummer class="GenericMetadataChecksummer"> <fieldMatcher method="csv"> docLastModified,docSize </fieldMatcher> </metadataChecksummer>
The above example uses a combination of two (fictitious) fields called "docLastModified" and "docSize" to make the checksum.
Since 2.0.0, a self-closing
<metadataChecksummer/>
tag without any attributes is used to disable checksum generation.- Since:
- 1.2.0
- Author:
- Pascal Essiembre
-
-
Constructor Summary
Constructors Constructor Description GenericMetadataChecksummer()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected String
doCreateMetaChecksum(Properties metadata)
boolean
equals(Object other)
TextMatcher
getFieldMatcher()
Gets the field matcher.List<String>
getSourceFields()
Deprecated.Since 2.0.0, usegetFieldMatcher()
.String
getSourceFieldsRegex()
Deprecated.Since 2.0.0, usegetFieldMatcher()
.int
hashCode()
boolean
isDisabled()
Deprecated.Since 2.0.0, not having a checksummer defined or setting one explicitly tonull
effectively disables it.protected void
loadChecksummerFromXML(XML xml)
protected void
saveChecksummerToXML(XML xml)
void
setDisabled(boolean disabled)
Deprecated.Since 2.0.0, not having a checksummer defined or setting one explicitly tonull
effectively disable it.void
setFieldMatcher(TextMatcher fieldMatcher)
Sets the field matcher.void
setSourceFields(String... sourceFields)
Deprecated.Since 2.0.0, usesetFieldMatcher(TextMatcher)
.void
setSourceFields(List<String> sourceFields)
Deprecated.Since 2.0.0, usesetFieldMatcher(TextMatcher)
.void
setSourceFieldsRegex(String sourceFieldsRegex)
Deprecated.Since 2.0.0, usesetFieldMatcher(TextMatcher)
.String
toString()
-
Methods inherited from class com.norconex.collector.core.checksum.AbstractMetadataChecksummer
createMetadataChecksum, getOnSet, getTargetField, getToField, isKeep, loadFromXML, saveToXML, setKeep, setOnSet, setTargetField, setToField
-
-
-
-
Method Detail
-
doCreateMetaChecksum
protected String doCreateMetaChecksum(Properties metadata)
- Specified by:
doCreateMetaChecksum
in classAbstractMetadataChecksummer
-
getFieldMatcher
public TextMatcher getFieldMatcher()
Gets the field matcher.- Returns:
- field matcher
- Since:
- 2.0.0
-
setFieldMatcher
public void setFieldMatcher(TextMatcher fieldMatcher)
Sets the field matcher.- Parameters:
fieldMatcher
- field matcher- Since:
- 2.0.0
-
getSourceFields
@Deprecated public List<String> getSourceFields()
Deprecated.Since 2.0.0, usegetFieldMatcher()
.Gets the metadata fields used to construct a checksum.- Returns:
- fields to use for checksum
-
setSourceFields
@Deprecated public void setSourceFields(String... sourceFields)
Deprecated.Since 2.0.0, usesetFieldMatcher(TextMatcher)
.Sets the metadata header fields used construct a checksum.- Parameters:
sourceFields
- fields to use for checksum
-
setSourceFields
@Deprecated public void setSourceFields(List<String> sourceFields)
Deprecated.Since 2.0.0, usesetFieldMatcher(TextMatcher)
.Sets the metadata header fields used construct a checksum.- Parameters:
sourceFields
- fields to use for checksum
-
getSourceFieldsRegex
@Deprecated public String getSourceFieldsRegex()
Deprecated.Since 2.0.0, usegetFieldMatcher()
.Gets the regular expression matching metadata fields used to construct a checksum.- Returns:
- regular expression
- Since:
- 1.9.0
-
setSourceFieldsRegex
@Deprecated public void setSourceFieldsRegex(String sourceFieldsRegex)
Deprecated.Since 2.0.0, usesetFieldMatcher(TextMatcher)
.Sets the regular expression matching metadata fields used construct a checksum.- Parameters:
sourceFieldsRegex
- regular expression- Since:
- 1.9.0
-
isDisabled
@Deprecated public boolean isDisabled()
Deprecated.Since 2.0.0, not having a checksummer defined or setting one explicitly tonull
effectively disables it.Deprecated.- Returns:
- always
false
-
setDisabled
@Deprecated public void setDisabled(boolean disabled)
Deprecated.Since 2.0.0, not having a checksummer defined or setting one explicitly tonull
effectively disable it.Deprecated. Invoking this method has no effect- Parameters:
disabled
- argument is ignored
-
loadChecksummerFromXML
protected void loadChecksummerFromXML(XML xml)
- Specified by:
loadChecksummerFromXML
in classAbstractMetadataChecksummer
-
saveChecksummerToXML
protected void saveChecksummerToXML(XML xml)
- Specified by:
saveChecksummerToXML
in classAbstractMetadataChecksummer
-
equals
public boolean equals(Object other)
- Overrides:
equals
in classAbstractMetadataChecksummer
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classAbstractMetadataChecksummer
-
toString
public String toString()
- Overrides:
toString
in classAbstractMetadataChecksummer
-
-