Class AbstractZipFilter

java.lang.Object
org.omegat.filters2.AbstractFilter
org.omegat.filters4.AbstractZipFilter
All Implemented Interfaces:
IFilter
Direct Known Subclasses:
MsOfficeFileFilter, SdlProject

public abstract class AbstractZipFilter extends AbstractFilter
Filter for a file format which is an archive containing XML.
  • Method Details

    • isSourceEncodingVariable

      public boolean isSourceEncodingVariable()
      Description copied from class: AbstractFilter
      Whether source encoding can be varied by the user.

      True means that OmegaT should handle all the encoding mess.

      Return false to state that your filter doesn't need encoding management provided by OmegaT, because it either autodetect the encoding based on file contents (like HTML filter does) or the encoding is fixed (like in OpenOffice files).

      Specified by:
      isSourceEncodingVariable in interface IFilter
      Specified by:
      isSourceEncodingVariable in class AbstractFilter
      Returns:
      whether source encoding can be changed by the user
    • isTargetEncodingVariable

      public boolean isTargetEncodingVariable()
      Description copied from class: AbstractFilter
      Whether target encoding can be varied by the user.

      True means that OmegaT should handle all the encoding mess.

      Return false to state that your filter doesn't need encoding management provided by OmegaT, because the encoding is fixed (like in OpenOffice files), or for some other reason.

      Specified by:
      isTargetEncodingVariable in interface IFilter
      Specified by:
      isTargetEncodingVariable in class AbstractFilter
      Returns:
      whether target encoding can be changed by the user
    • isFileSupported

      public boolean isFileSupported(File inFile, Map<String,String> config, FilterContext context)
      Description copied from class: AbstractFilter
      Returns whether the file is supported by the filter, given the file and possible file's encoding ( null encoding means autodetect). Default implementation creates a reader and calls AbstractFilter.isFileSupported(BufferedReader). You should override only one of the two.

      For example, DocBook files have .xml extension, as possibly many other XML files, so the filter should check a DTD of the document.

      Specified by:
      isFileSupported in interface IFilter
      Overrides:
      isFileSupported in class AbstractFilter
      Parameters:
      inFile - Source file.
      config - filter's configuration options
      context - Filter context.
      Returns:
      Does the filter support the file.
    • processFile

      public void processFile(File inFile, File outFile, FilterContext fc) throws IOException, TranslationException
      Processes a ZIP file.
      Throws:
      IOException
      TranslationException
    • readZipEntryContent

      public static String readZipEntryContent(ZipInputStream zipInputStream) throws IOException
      Read the content of the entry from the ZipInputStream as a string.
      Parameters:
      zipInputStream - The ZipInputStream to read from.
      Returns:
      The content of the input stream as a string.
      Throws:
      IOException