Class DocImageHandler
- java.lang.Object
-
- com.norconex.collector.http.fetch.util.DocImageHandler
-
- All Implemented Interfaces:
IXMLConfigurable
- Direct Known Subclasses:
ScreenshotHandler
public class DocImageHandler extends Object implements IXMLConfigurable
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 Classes Modifier and Type Class Description static class
DocImageHandler.DirStructure
static class
DocImageHandler.Target
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_IMAGE_FORMAT
protected static List<DocImageHandler.Target>
DEFAULT_TYPES
-
Constructor Summary
Constructors Constructor Description DocImageHandler()
DocImageHandler(Path defaultDir, String defaultDirField, String defaultMetaField)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object other)
String
getImageFormat()
Path
getTargetDir()
String
getTargetDirField()
DocImageHandler.DirStructure
getTargetDirStructure()
String
getTargetMetaField()
List<DocImageHandler.Target>
getTargets()
void
handleImage(InputStream imageStream, Doc doc)
int
hashCode()
void
loadFromXML(XML xml)
void
saveToXML(XML xml)
void
setImageFormat(String imageFormat)
void
setTargetDir(Path diskDir)
void
setTargetDirField(String diskField)
void
setTargetDirStructure(DocImageHandler.DirStructure dirStructure)
void
setTargetMetaField(String metadataField)
void
setTargets(DocImageHandler.Target... targets)
void
setTargets(List<DocImageHandler.Target> targets)
String
toString()
-
-
-
Field Detail
-
DEFAULT_IMAGE_FORMAT
public static final String DEFAULT_IMAGE_FORMAT
- See Also:
- Constant Field Values
-
DEFAULT_TYPES
protected static final List<DocImageHandler.Target> DEFAULT_TYPES
-
-
Method Detail
-
getTargetDir
public Path getTargetDir()
-
setTargetDir
public void setTargetDir(Path diskDir)
-
getTargetDirField
public String getTargetDirField()
-
setTargetDirField
public void setTargetDirField(String diskField)
-
getTargetDirStructure
public DocImageHandler.DirStructure getTargetDirStructure()
-
setTargetDirStructure
public void setTargetDirStructure(DocImageHandler.DirStructure dirStructure)
-
getTargetMetaField
public String getTargetMetaField()
-
setTargetMetaField
public void setTargetMetaField(String metadataField)
-
getTargets
public List<DocImageHandler.Target> getTargets()
-
setTargets
public void setTargets(DocImageHandler.Target... targets)
-
setTargets
public void setTargets(List<DocImageHandler.Target> targets)
-
getImageFormat
public String getImageFormat()
-
setImageFormat
public void setImageFormat(String imageFormat)
-
handleImage
public void handleImage(InputStream imageStream, Doc doc)
-
loadFromXML
public void loadFromXML(XML xml)
- Specified by:
loadFromXML
in interfaceIXMLConfigurable
-
saveToXML
public void saveToXML(XML xml)
- Specified by:
saveToXML
in interfaceIXMLConfigurable
-
-