public abstract class AbstractDocumentChecksummer extends Object implements IDocumentChecksummer, IXMLConfigurable
Abstract implementation of IDocumentChecksummer
giving the option
to keep the generated checksum in a metadata field.
The checksum can be stored
in a target field name specified. If no target field name is specified,
it stores it under the
metadata field name CrawlDocMetadata.CHECKSUM_DOC
.
Implementors do not need to store the checksum themselves, this abstract class does it.
Implementors should offer this XML configuration usage:
<documentChecksummer
class="(subclass)"
keep="[false|true]"
toField="(optional metadata field to store the checksum)"
onSet="[append|prepend|replace|optional]"/>
toField
is ignored unless the keep
attribute is set to true
.
Constructor and Description |
---|
AbstractDocumentChecksummer() |
Modifier and Type | Method and Description |
---|---|
String |
createDocumentChecksum(Doc document)
Creates a document checksum.
|
protected abstract String |
doCreateDocumentChecksum(Doc document) |
boolean |
equals(Object other) |
PropertySetter |
getOnSet()
Gets the property setter to use when a value is set.
|
String |
getTargetField()
Deprecated.
Since 2.0.0, use
getToField() . |
String |
getToField()
Gets the metadata field to use to store the checksum value.
|
int |
hashCode() |
boolean |
isKeep()
Whether to keep the document checksum value as a new field in the
document metadata.
|
protected abstract void |
loadChecksummerFromXML(XML xml) |
void |
loadFromXML(XML xml) |
protected abstract void |
saveChecksummerToXML(XML xml) |
void |
saveToXML(XML xml) |
void |
setKeep(boolean keep)
Sets whether to keep the document checksum value as a new field in the
document metadata.
|
void |
setOnSet(PropertySetter onSet)
Sets the property setter to use when a value is set.
|
void |
setTargetField(String targetField)
Deprecated.
Since 2.0.0, use
setToField(String) . |
void |
setToField(String toField)
Sets the metadata field name to use to store the checksum value.
|
String |
toString() |
public final String createDocumentChecksum(Doc document)
IDocumentChecksummer
createDocumentChecksum
in interface IDocumentChecksummer
document
- an HTTP documentpublic boolean isKeep()
true
to keep the checksumpublic void setKeep(boolean keep)
keep
- true
to keep the checksum@Deprecated public String getTargetField()
getToField()
.CrawlDocMetadata.CHECKSUM_METADATA
.
Only applicable if isKeep()
returns true
@Deprecated public void setTargetField(String targetField)
setToField(String)
.targetField
- the metadata field namepublic String getToField()
CrawlDocMetadata.CHECKSUM_METADATA
.
Only applicable if isKeep()
returns true
public void setToField(String toField)
toField
- the metadata field namepublic PropertySetter getOnSet()
public void setOnSet(PropertySetter onSet)
onSet
- property setterpublic final void loadFromXML(XML xml)
loadFromXML
in interface IXMLConfigurable
protected abstract void loadChecksummerFromXML(XML xml)
public final void saveToXML(XML xml)
saveToXML
in interface IXMLConfigurable
protected abstract void saveChecksummerToXML(XML xml)
Copyright © 2014–2023 Norconex Inc.. All rights reserved.