Interface IFilter

All Known Implementing Classes:
AbstractFilter, AbstractXmlFilter, AbstractZipFilter, AndroidFilter, CamtasiaWindowsFilter, DocBookFilter, DokuWikiFilter, FlashFilter, HelpAndManualFilter, HHCFilter2, HTMLFilter2, ILIASFilter, InfixFilter, INIFilter, L10nmgrFilter, LatexFilter, MagentoFilter, MoodlePHPFilter, MozillaDTDFilter, MozillaFTLFilter, MozillaLangFilter, MsOfficeFileFilter, OpenDocFilter, OpenDocXMLFilter, OpenXmlFilter, OpenXMLFilter, OpenXMLXMLFilter, PdfFilter, PoFilter, PropertiesFilter, RcFilter, RelaxNGFilter, ResourceBundleFilter, ResXFilter, SbvFilter, SchematronFilter, ScribusFilter, SdlProject, SdlXliff, SrtFilter, SvgFilter, TextFilter, TXMLFilter, Typo3Filter, VisioFilter, WebVttFilter, WiXFilter, WordpressFilter, XHTMLFilter, Xliff1Filter, Xliff2Filter, XLIFFFilter, XMLFilter, XMLSpreadsheetFilter, XtagFilter, YamlFilter

public interface IFilter
Interface for filters declaration.

Note: each filter should be stateless, i.e., options shouldn't be stored in filter, but should be sent to filter on each parse, align, or translate operation through context. Filters shouldn't use Core, but use Context.

  • Method Details

    • getFileFormatName

      String getFileFormatName()
      Human-readable name of the File Format this filter supports.
      Returns:
      File format name
    • getHint

      String getHint()
      Returns the hint displayed while the user edits the filter, and when she adds/edits the instance of this filter. The hint may be any string, preferably in a non-geek language.
      Returns:
      The hint for editing the filter in a non-geek language.
    • getDefaultInstances

      Instance[] getDefaultInstances()
      The default list of filter instances that this filter class has. One filter class may have different filter instances, different by source file mask, encoding of the source file, etc.

      Note that the user may change the instances freely.

      Returns:
      Default filter instances
    • isSourceEncodingVariable

      boolean isSourceEncodingVariable()
      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).

      Returns:
      whether source encoding can be changed by the user
    • isTargetEncodingVariable

      boolean isTargetEncodingVariable()
      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.

      Returns:
      whether target encoding can be changed by the user
    • getFuzzyMark

      String getFuzzyMark()
      Define fuzzy mark prefix for source which will be stored in TM. It's 'fuzzy' by default, but each filter can redefine it.
      Returns:
      fuzzy mark prefix
    • isFileSupported

      boolean isFileSupported(File inFile, Map<String,String> config, FilterContext context)
      Returns whether the file is supported by the filter, given the file and possible file's encoding ( null encoding means autodetect).

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

      Parameters:
      inFile - Source file.
      config - filter's configuration options
      context - processing context
      Returns:
      Does the filter support the file.
    • parseFile

      void parseFile(File inFile, Map<String,String> config, FilterContext context, IParseCallback callback) throws Exception
      Parse single file.
      Parameters:
      inFile - file to parse
      config - filter's configuration options
      context - processing context
      callback - callback for parsed data
      Throws:
      Exception
    • translateFile

      void translateFile(File inFile, File outFile, Map<String,String> config, FilterContext context, ITranslateCallback callback) throws Exception
      Create translated file.
      Parameters:
      inFile - source file
      outFile - output file
      config - filter's configuration options
      context - processing context
      callback - callback for get translation
      Throws:
      Exception
    • alignFile

      void alignFile(File inFile, File outFile, Map<String,String> config, FilterContext context, IAlignCallback callback) throws Exception
      Align a source and translated files. NB: this is not used for Tools->align files..., but for aligning in console mode
      Parameters:
      inFile - source file
      outFile - translated file
      config - filter's configuration options
      context - processing context
      callback - callback for store aligned data
      Throws:
      Exception
    • hasOptions

      boolean hasOptions()
    • changeOptions

      @Deprecated @Nullable @Nullable Map<String,String> changeOptions(@Nullable @Nullable Dialog parent, Map<String,String> config)
      Deprecated.
      Show change options dialog for able to change options.

      Deprecated; please use changeOptions(Window, Map) instead.

      Parameters:
      parent - parent window
      config - old options
      Returns:
      new options or null if options not changed
    • changeOptions

      @Nullable default @Nullable Map<String,String> changeOptions(Window parent, Map<String,String> config)
      Show change options dialog for able to change options.
      Parameters:
      parent - parent window
      config - old options
      Returns:
      new options or null if options not changed
    • getInEncodingLastParsedFile

      String getInEncodingLastParsedFile()
      Returns the encoding of the last parsed source file.
      Returns:
      the encoding of the last parsed source file, or null when no file has been parsed yet.
    • isBilingual

      default boolean isBilingual()
      Indicates whether the filter is bilingual, and thus can be used as external TM (i.e. files can be added to the /tm/ folder of an OmegaT project). Bilingual filters will supply both source strings and translation strings to IParseCallback.addEntry().
      Returns:
      true if the filter is bilingual
      Since:
      4.1.1
    • isEnabledInDefault

      default boolean isEnabledInDefault()
      Is the filter enabled in default.

      Deprecated filter may be disabled in default. So it can override the method to return false;

      Returns:
      false when the filter is disabled in default.
      Since:
      5.8.0