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 a target field with the same name already exists for a document,
values will be added to the end of the existing value list.
It is possible to change this default behavior by supplying a
PropertySetter
.
Can be used both as a pre-parse or post-parse handler.
<handler
class="com.norconex.importer.handler.tagger.impl.UUIDTagger"
toField="(target field)"
onSet="[append|prepend|replace|optional]">
<!-- multiple "restrictTo" tags allowed (only one needs to match) -->
<restrictTo>
<fieldMatcher
method="[basic|csv|wildcard|regex]"
ignoreCase="[false|true]"
ignoreDiacritic="[false|true]"
partial="[false|true]">
(field-matching expression)
</fieldMatcher>
<valueMatcher
method="[basic|csv|wildcard|regex]"
ignoreCase="[false|true]"
ignoreDiacritic="[false|true]"
partial="[false|true]">
(value-matching expression)
</valueMatcher>
</restrictTo>
</handler>
<handler
class="UUIDTagger"
field="uuid"
onSet="replace"/>
The above generates a UUID and stores it in a "uuid" field, overwriting any existing values under that field.
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()
Deprecated.
Since 3.0.0, use
getToField() |
PropertySetter |
getOnSet()
Gets the property setter to use when a value is set.
|
String |
getToField()
Gets the target field.
|
int |
hashCode() |
boolean |
isOverwrite()
Deprecated.
Since 3.0.0 use
getOnSet() . |
protected void |
loadHandlerFromXML(XML xml)
Loads configuration settings specific to the implementing class.
|
protected void |
saveHandlerToXML(XML xml)
Saves configuration settings specific to the implementing class.
|
void |
setField(String toField)
Deprecated.
Since 3.0.0, use
setToField(String) |
void |
setOnSet(PropertySetter onSet)
Sets the property setter to use when a value is set.
|
void |
setOverwrite(boolean overwrite)
Deprecated.
Since 3.0.0 use
setOnSet(PropertySetter) . |
void |
setToField(String toField)
Sets the target field.
|
void |
tagApplicableDocument(HandlerDoc doc,
InputStream document,
ParseState parseState) |
String |
toString() |
tagDocument
addRestriction, addRestriction, addRestrictions, clearRestrictions, detectCharsetIfBlank, getRestrictions, isApplicable, loadFromXML, removeRestriction, removeRestriction, saveToXML
public static final String DEFAULT_FIELD
public void tagApplicableDocument(HandlerDoc doc, InputStream document, ParseState parseState) throws ImporterHandlerException
tagApplicableDocument
in class AbstractDocumentTagger
ImporterHandlerException
public String getToField()
public void setToField(String toField)
toField
- target field@Deprecated public String getField()
getToField()
@Deprecated public void setField(String toField)
setToField(String)
toField
- target field@Deprecated public boolean isOverwrite()
getOnSet()
.true
if overwriting existing value.@Deprecated public void setOverwrite(boolean overwrite)
setOnSet(PropertySetter)
.overwrite
- true
if overwriting existing value.public PropertySetter getOnSet()
public void setOnSet(PropertySetter onSet)
onSet
- property setterprotected void loadHandlerFromXML(XML xml)
AbstractImporterHandler
loadHandlerFromXML
in class AbstractImporterHandler
xml
- XML configurationprotected void saveHandlerToXML(XML xml)
AbstractImporterHandler
saveHandlerToXML
in class AbstractImporterHandler
xml
- the XMLpublic boolean equals(Object other)
equals
in class AbstractImporterHandler
public int hashCode()
hashCode
in class AbstractImporterHandler
public String toString()
toString
in class AbstractImporterHandler
Copyright © 2009–2023 Norconex Inc.. All rights reserved.