Package com.logicaldoc.core.conversion

# Class AbstractFormatConverter

java.lang.Object
com.logicaldoc.core.conversion.AbstractFormatConverter

All Implemented Interfaces:
  `FormatConverter`

Direct Known Subclasses:
  `CompressedArchiveConverter`, `GhostscriptConverter`, `ImageConverter`, `MarkdownConverter`, `P7MConverter`, `PstConverter`, `XMLConverter`

public abstract class AbstractFormatConverter extends Object implements FormatConverter
Abstract format converter.

Since:
  7.7
Author:
  Marco Meschieri - LogicalDOC

## Method Summary

Modifier and Type
Method
Description
`final void`
`convert(File src, File dest)`
Template method that invokes `convert(String, Document, File, File)`
`final void`
`convert(String sid, Document document, File src, File dest)`
If the converter is enabled it invokes the `internalConvert(String, Document, File, File)`
`boolean`
`equals(Object obj)`
`static String`
`getExtension(String fileNameOrExtension)`
Gets the extension for the given filename, if an alias is found then the value of the alias is returned as well.
`String`
`getParameter(String name)`
Gets the value of a parameter
`List<String>`
`getParameterNames()`
Implementations should return the list of the required parameters.
`Map<String,String>`
`getParameters()`
Returns the map of parameters
`int`
`hashCode()`
`boolean`
`isEnabled()`
Checks if the converter is enabled or not
`void`
`loadParameters()`
Reads it's own parameters and stores them in the parameters map
`void`
`setEnabled(boolean enabled)`
Enables or disables the converter

### Methods inherited from class java.lang.Object

`getClass, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### convert

public final void convert(File src, File dest) throws IOException
Template method that invokes `convert(String, Document, File, File)`

Specified by:
  `convert` in interface `FormatConverter`
Parameters:
  `src` - The source file
  `dest` - The converted file, the extension of it's filename defines the output format
Throws:
  `IOException` - raised if the conversion resulted in an error

### convert

public final void convert(String sid, Document document, File src, File dest) throws IOException
If the converter is enabled it invokes the `internalConvert(String, Document, File, File)`

Specified by:
  `convert` in interface `FormatConverter`
Parameters:
  `sid` - The actual Session ID (optional)
  `document` - The document (optional)
  `src` - The source file
  `dest` - The converted file, the extension of it's filename defines the output format
Throws:
  `IOException` - raised if the conversion resulted in an error

### loadParameters

public void loadParameters()
Description copied from interface: `FormatConverter`
Reads it's own parameters and stores them in the parameters map

Specified by:
  `loadParameters` in interface `FormatConverter`

### isEnabled

public boolean isEnabled()
Description copied from interface: `FormatConverter`
Checks if the converter is enabled or not

Specified by:
  `isEnabled` in interface `FormatConverter`
Returns:
  if the converter is enabled

### setEnabled

public void setEnabled(boolean enabled)
Description copied from interface: `FormatConverter`
Enables or disables the converter

Specified by:
  `setEnabled` in interface `FormatConverter`
Parameters:
  `enabled` - the enabled flag

### getParameters

public Map<String,String> getParameters()
Description copied from interface: `FormatConverter`
Returns the map of parameters

Specified by:
  `getParameters` in interface `FormatConverter`
Returns:
  map param_name = param_value

### getParameter

public String getParameter(String name)
Description copied from interface: `FormatConverter`
Gets the value of a parameter

Specified by:
  `getParameter` in interface `FormatConverter`
Parameters:
  `name` - name of the configuration parameter
Returns:
  the value of the configuration parameter

### getParameterNames

public List<String> getParameterNames()
Description copied from interface: `FormatConverter`
Implementations should return the list of the required parameters. A parameter is stored in the context as converter.SimpleClassName.parameter = value

Specified by:
  `getParameterNames` in interface `FormatConverter`
Returns:
  list of the configuration parameters

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`

### equals

public boolean equals(Object obj)

Overrides:
  `equals` in class `Object`

### getExtension

public static String getExtension(String fileNameOrExtension)
Gets the extension for the given filename, if an alias is found then the value of the alias is returned as well. For instance if in the settings you have `converter.alias.eft=txt` then a file named test.eft will be considered a txt.

Parameters:
  `fileNameOrExtension` - file name or just the extension
Returns:
  the real extension to use