public class UUIDTagger extends AbstractDocumentTagger
Generates a random Universally unique identifier (UUID) and stores it
in the specified field
.
If no field
is provided, the UUID will be added to
document.uuid
.
If field
already has one or more values,
the new UUID will be added to the list of
existing values, unless "overwrite" is set to true
.
Can be used both as a pre-parse or post-parse handler.
<tagger class="com.norconex.importer.handler.tagger.impl.UUIDTagger" field="(target field)" overwrite="[false|true]" > <restrictTo caseSensitive="[false|true]" field="(name of header/metadata field name to match)"> (regular expression of value to match) </restrictTo> <!-- multiple "restrictTo" tags allowed (only one needs to match) --> </tagger>
The following generates a UUID and stores it in a "uuid" field, overwriting any existing values under that field.
<tagger class="com.norconex.importer.handler.tagger.impl.UUIDTagger" field="uuid" overwrite="true" />
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_FIELD |
Constructor and Description |
---|
UUIDTagger()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other) |
String |
getField() |
int |
hashCode() |
boolean |
isOverwrite() |
protected void |
loadHandlerFromXML(org.apache.commons.configuration.XMLConfiguration xml)
Loads configuration settings specific to the implementing class.
|
protected void |
saveHandlerToXML(EnhancedXMLStreamWriter writer)
Saves configuration settings specific to the implementing class.
|
void |
setField(String toField) |
void |
setOverwrite(boolean overwrite) |
void |
tagApplicableDocument(String reference,
InputStream document,
ImporterMetadata metadata,
boolean parsed) |
String |
toString() |
tagDocument
addRestriction, addRestriction, addRestrictions, clearRestrictions, detectCharsetIfBlank, getRestrictions, isApplicable, loadFromXML, removeRestriction, removeRestriction, saveToXML
public static final String DEFAULT_FIELD
public void tagApplicableDocument(String reference, InputStream document, ImporterMetadata metadata, boolean parsed) throws ImporterHandlerException
tagApplicableDocument
in class AbstractDocumentTagger
ImporterHandlerException
public String getField()
public void setField(String toField)
public boolean isOverwrite()
public void setOverwrite(boolean overwrite)
protected void loadHandlerFromXML(org.apache.commons.configuration.XMLConfiguration xml) throws IOException
AbstractImporterHandler
loadHandlerFromXML
in class AbstractImporterHandler
xml
- xml configurationIOException
- could not load from XMLprotected void saveHandlerToXML(EnhancedXMLStreamWriter writer) throws XMLStreamException
AbstractImporterHandler
saveHandlerToXML
in class AbstractImporterHandler
writer
- the xml writerXMLStreamException
- could not save to XMLpublic String toString()
toString
in class AbstractImporterHandler
public boolean equals(Object other)
equals
in class AbstractImporterHandler
public int hashCode()
hashCode
in class AbstractImporterHandler
Copyright © 2009–2021 Norconex Inc.. All rights reserved.