The im4java Library, Version 1.4.0

org.im4java.core
Class ImageCommand

java.lang.Object
  extended by org.im4java.process.ProcessStarter
      extended by org.im4java.core.ImageCommand
All Implemented Interfaces:
ErrorConsumer
Direct Known Subclasses:
CompareCmd, CompositeCmd, ConvertCmd, DcrawCmd, DisplayCmd, ExiftoolCmd, GraphicsMagickCmd, IdentifyCmd, ImageMagickCmd, JpegtranCmd, MogrifyCmd, MontageCmd, UFRawCmd

public class ImageCommand
extends ProcessStarter
implements ErrorConsumer

This class implements the processing of image operations. It replaces placeholders within the argument-stack and passes all arguments to the generic run-method of ProcessStarter.

Since:
0.95
Version:
$Revision: 1.32 $
Author:
$Author: bablokb $

Field Summary
 
Fields inherited from class org.im4java.process.ProcessStarter
BUFFER_SIZE
 
Constructor Summary
ImageCommand()
          Constructor.
ImageCommand(java.lang.String... pCommands)
          Constructor setting the commands.
 
Method Summary
 void consumeError(java.io.InputStream pInputStream)
          This method just saves the stderr-output into an internal field.
 void createScript(java.io.PrintWriter pWriter, Operation pOp, java.util.Properties pProps)
          Generate a script.
 void createScript(java.lang.String pFilename, Operation pOp)
          Generate a script.
 void createScript(java.lang.String pFilename, Operation pOp, java.util.Properties pProps)
          Generate a script.
protected  void finished(int pReturnCode)
          Post-processing after the process has terminated.
 java.util.LinkedList<java.lang.String> getCommand()
          Get the command.
 java.util.ArrayList<java.lang.String> getErrorText()
          Get the error-text associated with this command (might be null).
 ProcessTask getProcessTask(Operation pOperation, java.lang.Object... images)
          Return a ProcessTask for future execution (replace given placeholders).
 void run(Operation pOperation, java.lang.Object... images)
          Execute the command (replace given placeholders).
 void setCommand(java.lang.String... pCommands)
          Set the command.
static void setDefaultScriptGenerator(ScriptGenerator pGen)
          Set the default ScriptGenerator.
 void setScriptGenerator(ScriptGenerator pGen)
          Set the ScriptGenerator.
 
Methods inherited from class org.im4java.process.ProcessStarter
addProcessEventListener, addProcessListener, finished, getGlobalSearchPath, getPID, getProcessTask, getSearchPath, isAsyncMode, removeProcessEventListener, run, searchForCmd, setAsyncMode, setErrorConsumer, setGlobalSearchPath, setInputProvider, setOutputConsumer, setPID, setPIDCounter, setSearchPath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageCommand

public ImageCommand()
Constructor.


ImageCommand

public ImageCommand(java.lang.String... pCommands)
Constructor setting the commands.

Method Detail

setCommand

public void setCommand(java.lang.String... pCommands)
Set the command.


getCommand

public java.util.LinkedList<java.lang.String> getCommand()
Get the command.


getErrorText

public java.util.ArrayList<java.lang.String> getErrorText()
Get the error-text associated with this command (might be null).

Returns:
The error-text associated with this command.

run

public void run(Operation pOperation,
                java.lang.Object... images)
         throws java.io.IOException,
                java.lang.InterruptedException,
                IM4JavaException
Execute the command (replace given placeholders).

Parameters:
pOperation - The Operation to execute
images - Zero or more images (replace placeholders in pOperation)
Throws:
IOException, - InterruptedException, IM4JavaException
java.io.IOException
java.lang.InterruptedException
IM4JavaException

getProcessTask

public ProcessTask getProcessTask(Operation pOperation,
                                  java.lang.Object... images)
                           throws java.io.IOException,
                                  IM4JavaException
Return a ProcessTask for future execution (replace given placeholders).

Parameters:
pOperation - The Operation to execute
images - Zero or more images (replace placeholders in pOperation)
Throws:
IOException, - IM4JavaException
java.io.IOException
IM4JavaException

finished

protected void finished(int pReturnCode)
                 throws java.lang.Exception
Post-processing after the process has terminated. Implements the method of the base class.

Overrides:
finished in class ProcessStarter
Parameters:
pReturnCode - the return-code of the process
Throws:
java.lang.Exception

consumeError

public void consumeError(java.io.InputStream pInputStream)
                  throws java.io.IOException
This method just saves the stderr-output into an internal field.

Specified by:
consumeError in interface ErrorConsumer
Throws:
java.io.IOException
See Also:
ErrorConsumer.consumeError(java.io.InputStream)

setDefaultScriptGenerator

public static void setDefaultScriptGenerator(ScriptGenerator pGen)
Set the default ScriptGenerator.


setScriptGenerator

public void setScriptGenerator(ScriptGenerator pGen)
Set the ScriptGenerator.


createScript

public void createScript(java.io.PrintWriter pWriter,
                         Operation pOp,
                         java.util.Properties pProps)
Generate a script.


createScript

public void createScript(java.lang.String pFilename,
                         Operation pOp,
                         java.util.Properties pProps)
                  throws java.io.FileNotFoundException
Generate a script. The method will automatically append the extension ".cmd" on a windows-plattform.

Throws:
java.io.FileNotFoundException

createScript

public void createScript(java.lang.String pFilename,
                         Operation pOp)
                  throws java.io.FileNotFoundException
Generate a script. Convenience-method without a Properties-object.

Throws:
java.io.FileNotFoundException

The im4java Library, Version 1.4.0

Released under the LGPL, (c) Bernhard Bablok 2008-2010
Homepage: http://im4java.sourceforge.net/