Class DocImageHandler
java.lang.Object
com.norconex.collector.http.fetch.util.DocImageHandler
- All Implemented Interfaces:
IXMLConfigurable
- Direct Known Subclasses:
ScreenshotHandler
Handles images associated with a document (which is different than a document being itself an image). Examples can be screenshots, featured image, etc. Images can be stored in a document metadata/field or in a local directory.
XML configuration usage:
<targets>[metadata|directory] (One or both, separated by comma.)</targets>
<imageFormat>(Image format. Default is "png".)</imageFormat>
<!-- The following applies to the "directory" target: -->
<targetDir
field="(Document field to store the local path to the image.)"
structure="[url2path|date|datetime]">
(Local directory where to save images.)
</targetDir>
<!-- The following applies to the "metadata" target: -->
<targetMetaField>(Document field where to store the image.)</targetMetaField>
The above XML configurable options can be nested in a parent tag of any name. The expected parent tag name is defined by the consuming classes.
- Since:
- 3.0.0
- Author:
- Pascal Essiembre
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enum -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected static final List<DocImageHandler.Target> -
Constructor Summary
ConstructorsConstructorDescriptionDocImageHandler(Path defaultDir, String defaultDirField, String defaultMetaField) -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidhandleImage(InputStream imageStream, Doc doc) inthashCode()voidloadFromXML(XML xml) voidvoidsetImageFormat(String imageFormat) voidsetTargetDir(Path diskDir) voidsetTargetDirField(String diskField) voidsetTargetDirStructure(DocImageHandler.DirStructure dirStructure) voidsetTargetMetaField(String metadataField) voidsetTargets(DocImageHandler.Target... targets) voidsetTargets(List<DocImageHandler.Target> targets) toString()
-
Field Details
-
DEFAULT_IMAGE_FORMAT
- See Also:
-
DEFAULT_TYPES
-
-
Constructor Details
-
DocImageHandler
-
DocImageHandler
public DocImageHandler()
-
-
Method Details
-
getTargetDir
-
setTargetDir
-
getTargetDirField
-
setTargetDirField
-
getTargetDirStructure
-
setTargetDirStructure
-
getTargetMetaField
-
setTargetMetaField
-
getTargets
-
setTargets
-
setTargets
-
getImageFormat
-
setImageFormat
-
handleImage
-
equals
-
hashCode
public int hashCode() -
toString
-
loadFromXML
- Specified by:
loadFromXMLin interfaceIXMLConfigurable
-
saveToXML
- Specified by:
saveToXMLin interfaceIXMLConfigurable
-