chemaxon.marvin.plugin
Class CalculatorPluginOutput

java.lang.Object
  extended by chemaxon.marvin.plugin.CalculatorPluginOutput
All Implemented Interfaces:
chemaxon.marvin.plugin.CalculatorResultAccess

public class CalculatorPluginOutput
extends java.lang.Object
implements chemaxon.marvin.plugin.CalculatorResultAccess

Class providing plugin output in table form. The default implementation provides the following output:

id<type1><type2><type3>...
<id1><result11><result12><result13>...
<id2><result21><result22><result23>...
...............
where type1, type2, ... are the result types, id1, id2, ... are the molecule ID-s fetched from the given ID tag of the input SDF file or molecule indices if no such tag is given, the resultij is the result string for the i-th molecule and the j-th result type. Other output formats can be implemented by subclassing this class and returning the class name in the plugin-specific implementation of chemaxon.plugin.CalculatorPlugin.getOutputClassName().

Since:
Marvin 3.0
Version:
Marvin 4.1, 05/19/2006
Author:
Nora Mate

Field Summary
protected  java.util.Properties params
          The plugin parameter table.
protected  CalculatorPlugin plugin
          The CalculatorPlugin object.
protected  java.lang.String separator
          The separator string separating the results for different result types.
 
Constructor Summary
CalculatorPluginOutput()
          Default constructor.
CalculatorPluginOutput(CalculatorPlugin plugin)
          Constructor that sets plugin.
 
Method Summary
 void close()
          Closes the output.
 void close(int opts)
          Closes the output.
 chemaxon.marvin.plugin.CalculatorPluginCachedResults getCachedResults(Molecule target, boolean stringResult)
          Returns cached results, separated from the plugin object, so that no further enqueries needed to the plugin to get the result.
 java.lang.String getHeader()
          Returns the table header.
 CalculatorPlugin getPlugin()
          Returns the calculator plugin object.
 java.util.Properties getPluginParameters()
          Returns the plugin parameter table (this should be set in the plugin).
 java.lang.String getRemark()
          Returns the calculation remark.
 java.lang.String getResult(Molecule target)
          Returns the result string for the given molecule.
 int getResultDomain()
          Returns the domain for the first result type.
 java.lang.String getResultMessage()
          Returns the plugin calculation error message, error or warning.
 Molecule getResultMolecule(Molecule target)
          Returns the decorated result molecule for the given target molecule.
 Molecule[] getResultMolecules(Molecule target)
          Returns the result molecules for the given target molecule.
protected  java.lang.String getResults(java.lang.Object type)
          Returns result items for the given result type.
 double getSpecResult(Molecule target, java.lang.String arg)
          Returns a specific plugin result corresponding to the given molecule and argument string.
 java.lang.Throwable getThrowable()
          Returns the throwable object.
 boolean isMolecular()
          Returns true if molecule output.
 boolean isOK()
          Returns true if the calculation has run without error.
 boolean isStreamOutput()
          Returns true if stream output.
 void setOutputParameters(java.lang.Object[] types)
          Prepares the output based on the result type string.
 void setOutputStream(java.io.OutputStream os)
          Sets the output stream.
 void setParameters(java.util.Properties params)
          Sets the parameter table.
 void setPlugin(CalculatorPlugin plugin)
          Sets the calculator plugin object.
 void setSeparator(java.lang.String separator)
          Sets the separator string.
 void setThrowable(java.lang.Throwable throwable)
          Sets the throwable object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

plugin

protected CalculatorPlugin plugin
The CalculatorPlugin object.


params

protected java.util.Properties params
The plugin parameter table.


separator

protected java.lang.String separator
The separator string separating the results for different result types.

Constructor Detail

CalculatorPluginOutput

public CalculatorPluginOutput()
Default constructor.


CalculatorPluginOutput

public CalculatorPluginOutput(CalculatorPlugin plugin)
Constructor that sets plugin.

Parameters:
plugin - is the plugin
Method Detail

setPlugin

public final void setPlugin(CalculatorPlugin plugin)
Sets the calculator plugin object.

Parameters:
plugin - is the CalculatorPlugin object

getPlugin

public final CalculatorPlugin getPlugin()
Returns the calculator plugin object.

Returns:
the calculator plugin object

setThrowable

public final void setThrowable(java.lang.Throwable throwable)
Sets the throwable object.

Parameters:
throwable - is the CalculatorPlugin object

getThrowable

public final java.lang.Throwable getThrowable()
Returns the throwable object.

Specified by:
getThrowable in interface chemaxon.marvin.plugin.CalculatorResultAccess
Returns:
the throwable plugin object

setSeparator

public void setSeparator(java.lang.String separator)
Sets the separator string.

Parameters:
separator - is the separator string

setParameters

public void setParameters(java.util.Properties params)
                   throws PluginException
Sets the parameter table.

Parameters:
params - is the parameter table
Throws:
PluginException - on error

getPluginParameters

public java.util.Properties getPluginParameters()
                                         throws PluginException
Returns the plugin parameter table (this should be set in the plugin). The default implementation returns the given parameter table itself.

Returns:
the original parameter table if it is the same, a new table with the plugin params otherwise
Throws:
PluginException - on error

setOutputParameters

public void setOutputParameters(java.lang.Object[] types)
                         throws PluginException
Prepares the output based on the result type string. The default implementation does nothing.

Parameters:
types - the result types
Throws:
PluginException - on error

isMolecular

public boolean isMolecular()
Returns true if molecule output. The default implementation returns false.

Returns:
true if molecule output

isStreamOutput

public boolean isStreamOutput()
Returns true if stream output. The default implementation returns false.

Returns:
true if stream output

setOutputStream

public void setOutputStream(java.io.OutputStream os)
                     throws java.io.IOException
Sets the output stream. Used for molecule output. The default implementation does nothing.

Parameters:
os - the output stream
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Closes the output. The default implementation calls close(int) with MolExporter.C_CLOSE_STREAM parameter.

Throws:
java.io.IOException

close

public void close(int opts)
           throws java.io.IOException
Closes the output. The default implementation does nothing.

Parameters:
opts - closing options, MolExporter.C_CLOSE_STREAM or MolExporter.C_FLUSH_STREAM
Throws:
java.io.IOException
Since:
Marvin 5.1.1

getCachedResults

public final chemaxon.marvin.plugin.CalculatorPluginCachedResults getCachedResults(Molecule target,
                                                                                   boolean stringResult)
                                                                            throws PluginException
Returns cached results, separated from the plugin object, so that no further enqueries needed to the plugin to get the result.

Parameters:
target - the target molecule
stringResult - is true if string result is needed, false if decorated molecule is needed
Returns:
the cached results
Throws:
PluginException
Since:
Marvin 5.2

getResultMessage

public final java.lang.String getResultMessage()
Returns the plugin calculation error message, error or warning.

Specified by:
getResultMessage in interface chemaxon.marvin.plugin.CalculatorResultAccess
Returns:
the plugin calculation error message

getRemark

public java.lang.String getRemark()
Returns the calculation remark.

Specified by:
getRemark in interface chemaxon.marvin.plugin.CalculatorResultAccess
Returns:
the calculation remark

isOK

public boolean isOK()
Returns true if the calculation has run without error.

Specified by:
isOK in interface chemaxon.marvin.plugin.CalculatorResultAccess
Returns:
true if the calculation has run without error

getHeader

public java.lang.String getHeader()
Returns the table header. The default implementation returns "id" and the result types.

Specified by:
getHeader in interface chemaxon.marvin.plugin.CalculatorResultAccess
Returns:
the table header

getResult

public java.lang.String getResult(Molecule target)
                           throws PluginException
Returns the result string for the given molecule. The default implementation returns the result strings corresponding to the result types.

Specified by:
getResult in interface chemaxon.marvin.plugin.CalculatorResultAccess
Parameters:
target - is the target molecule
Returns:
the result row
Throws:
PluginException - on error

getResults

protected java.lang.String getResults(java.lang.Object type)
                               throws PluginException
Returns result items for the given result type.

Parameters:
type - is the result type
Returns:
result items separated by ';'
Throws:
PluginException - on error

getResultMolecule

public Molecule getResultMolecule(Molecule target)
                           throws PluginException
Returns the decorated result molecule for the given target molecule. Used in case of MRV output (-M, --mrv-output).

Specified by:
getResultMolecule in interface chemaxon.marvin.plugin.CalculatorResultAccess
Parameters:
target - is the target molecule
Returns:
the result molecule
Throws:
PluginException - on error

getResultMolecules

public Molecule[] getResultMolecules(Molecule target)
                              throws PluginException
Returns the result molecules for the given target molecule. The default implementation returns null.

Specified by:
getResultMolecules in interface chemaxon.marvin.plugin.CalculatorResultAccess
Parameters:
target - is the target molecules
Returns:
the result molecules
Throws:
PluginException - on error

getResultDomain

public int getResultDomain()
Returns the domain for the first result type.

Returns:
the domain for the first result type: CalculatorPlugin.ATOM, CalculatorPlugin.MOLECULE or CalculatorPlugin.MOLECULES

getSpecResult

public double getSpecResult(Molecule target,
                            java.lang.String arg)
                     throws PluginException
Returns a specific plugin result corresponding to the given molecule and argument string. The default implementation returns the result value returned by CalculatorPlugin.getResult(int index) (converted to double) with index given in the argument string: the argument string format is <result index>.

Parameters:
target - is the target molecule
arg - is the argument string
Returns:
the queried plugin result
Throws:
PluginException - in case of plugin calculation error