DumpProcessingAction, org.wikidata.wdtk.datamodel.interfaces.EntityDocumentDumpProcessor, org.wikidata.wdtk.datamodel.interfaces.EntityDocumentProcessorJsonSerializationAction, RdfSerializationActionpublic abstract class DumpProcessingOutputAction extends java.lang.Object implements DumpProcessingAction
DumpProcessingAction that represents
actions which generate outputs (in the form of files). It supports options
OPTION_DESTINATION, OPTION_COMPRESSION, and
OPTION_USE_STDOUT. Moreover, it provides some static helper
functions for opening files for writing.| Modifier and Type | Class | Description |
|---|---|---|
protected static interface |
DumpProcessingOutputAction.FinishableRunnable |
Simple interface for a Runnable that can be stopped gracefully by calling
a method
DumpProcessingOutputAction.FinishableRunnable.finish(). |
| Modifier and Type | Field | Description |
|---|---|---|
static java.lang.String |
COMPRESS_BZ2 |
|
static java.lang.String |
COMPRESS_GZIP |
|
static java.lang.String |
COMPRESS_NONE |
|
protected java.lang.String |
compressionType |
String to indicate the output compression to be used, if any.
|
protected java.lang.String |
dateStamp |
Date stamp of the dump to be processed.
|
protected java.lang.String |
name |
The name of the action.
|
static java.lang.String |
OPTION_COMPRESSION |
Name of the option used to define that output be compressed in a
particular way.
|
static java.lang.String |
OPTION_DESTINATION |
Name of the option to set the destination file name (may include path)
for outputs generated by this action.
|
static java.lang.String |
OPTION_USE_STDOUT |
Name of the option to redirect output to stdout.
|
protected java.lang.String |
outputDestination |
For operations that generate output, this is the name of the output file,
or null to use the default file name for the given options.
|
protected java.util.Set<java.io.Closeable> |
outputStreams |
Output streams that were created by this class.
|
protected java.lang.String |
project |
String name of the site that the processed dump file comes from.
|
protected org.wikidata.wdtk.datamodel.interfaces.Sites |
sites |
The
Sites object if provided. |
protected boolean |
useStdOut |
Specifies if output should be redirected to stdout rather than being
written to a file.
|
| Constructor | Description |
|---|---|
DumpProcessingOutputAction() |
| Modifier and Type | Method | Description |
|---|---|---|
void |
close() |
|
java.lang.String |
getActionName() |
Returns the name of the action.
|
protected java.io.OutputStream |
getAsynchronousOutputStream(java.io.OutputStream outputStream) |
Creates a separate thread for writing into the given output stream and
returns a pipe output stream that can be used to pass data to this
thread.
|
java.lang.String |
getOutputFilename() |
|
protected java.io.OutputStream |
getOutputStream(boolean useStdOut,
java.lang.String filePath,
java.lang.String compressionType) |
Creates an compressing
OutputStream. |
java.lang.String |
insertDumpInformation(java.lang.String pattern) |
|
void |
setActionName(java.lang.String name) |
Sets the name of the action.
|
void |
setDumpInformation(java.lang.String project,
java.lang.String dateStamp) |
Provides the action with general information about the dump that is to be
processed.
|
boolean |
setOption(java.lang.String option,
java.lang.String value) |
Sets the options of the specified name to the given value.
|
void |
setSites(org.wikidata.wdtk.datamodel.interfaces.Sites sites) |
Sets the sites information to the given value.
|
boolean |
useStdOut() |
Returns true if this action will write results (not log messages) to
stdout.
|
getDefaultActionName, getReport, isReady, needsSitesopenpublic static final java.lang.String OPTION_COMPRESSION
public static final java.lang.String OPTION_DESTINATION
public static final java.lang.String OPTION_USE_STDOUT
public static final java.lang.String COMPRESS_BZ2
public static final java.lang.String COMPRESS_GZIP
public static final java.lang.String COMPRESS_NONE
protected java.util.Set<java.io.Closeable> outputStreams
protected java.lang.String name
protected org.wikidata.wdtk.datamodel.interfaces.Sites sites
Sites object if provided.DumpProcessingAction.needsSites()protected java.lang.String outputDestination
protected boolean useStdOut
protected java.lang.String compressionType
protected java.lang.String dateStamp
protected java.lang.String project
public void setSites(org.wikidata.wdtk.datamodel.interfaces.Sites sites)
DumpProcessingActionDumpProcessingAction.needsSites() is used to find out if this is actually needed.setSites in interface DumpProcessingActionsites - the sites information for the data that will be processedpublic boolean setOption(java.lang.String option,
java.lang.String value)
DumpProcessingActionsetOption in interface DumpProcessingActionoption - name of the option to be setvalue - the new value of the optionpublic boolean useStdOut()
DumpProcessingActionuseStdOut in interface DumpProcessingActionpublic void setDumpInformation(java.lang.String project,
java.lang.String dateStamp)
DumpProcessingActionsetDumpInformation in interface DumpProcessingActionproject - the name of the project that the dump is fromdateStamp - the datestamp (YYYYMMDD) for the dumppublic void setActionName(java.lang.String name)
DumpProcessingActionsetActionName in interface DumpProcessingActionpublic java.lang.String getActionName()
DumpProcessingActiongetActionName in interface DumpProcessingActionpublic java.lang.String getOutputFilename()
public java.lang.String insertDumpInformation(java.lang.String pattern)
public void close()
close in interface org.wikidata.wdtk.datamodel.interfaces.EntityDocumentDumpProcessorprotected java.io.OutputStream getOutputStream(boolean useStdOut,
java.lang.String filePath,
java.lang.String compressionType)
throws java.io.IOException
OutputStream. The result is owned by the
caller and should be closed later. Neverhteless, the close()
method of this class must also be called, since it may free additional
resources created.useStdOut - if true, System.out is returned and the other
parameters are ignoredfilePath - the string name of the output file, possibly including path
informationcompressionType - a string that refers to a type of output compression or the
empty string (no compression); a suitable file extension will
be added to the output fileOutputStreamjava.io.IOException - if there were problems opening the required streamsprotected java.io.OutputStream getAsynchronousOutputStream(java.io.OutputStream outputStream)
throws java.io.IOException
This code is inspired by http://stackoverflow.com/questions/12532073/gzipoutputstream -that-does-its-compression-in-a-separate-thread
outputStream - the stream to write to in the threadjava.io.IOException - if the pipes could not be created for some reasonCopyright © 2014–2017 Wikidata Toolkit Developers. Generated from source code published under the Apache License 2.0. For more information, see the Wikidata Toolkit homepage