Interface IFilter

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods 
      Modifier and Type Method Description
      void alignFile​(java.io.File inFile, java.io.File outFile, java.util.Map<java.lang.String,​java.lang.String> config, FilterContext context, IAlignCallback callback)
      Align source and translated files.
      java.util.Map<java.lang.String,​java.lang.String> changeOptions​(java.awt.Dialog parent, java.util.Map<java.lang.String,​java.lang.String> config)
      Deprecated.
      default java.util.Map<java.lang.String,​java.lang.String> changeOptions​(java.awt.Window parent, java.util.Map<java.lang.String,​java.lang.String> config)
      Show change options dialog for able to change options.
      Instance[] getDefaultInstances()
      The default list of filter instances that this filter class has.
      java.lang.String getFileFormatName()
      Human-readable name of the File Format this filter supports.
      java.lang.String getFuzzyMark()
      Define fuzzy mark prefix for source which will be stored in TM.
      java.lang.String getHint()
      Returns the hint displayed while the user edits the filter, and when she adds/edits the instance of this filter.
      java.lang.String getInEncodingLastParsedFile()
      Returns the encoding of the last parsed source file.
      boolean hasOptions()  
      default boolean isBilingual()
      Indicates whether the filter is bilingual, and thus can be used as external TM (i.e.
      default boolean isEnabledInDefault()
      Is the filter enabled in default.
      boolean isFileSupported​(java.io.File inFile, java.util.Map<java.lang.String,​java.lang.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).
      boolean isSourceEncodingVariable()
      Whether source encoding can be varied by the user.
      boolean isTargetEncodingVariable()
      Whether target encoding can be varied by the user.
      void parseFile​(java.io.File inFile, java.util.Map<java.lang.String,​java.lang.String> config, FilterContext context, IParseCallback callback)
      Parse single file.
      void translateFile​(java.io.File inFile, java.io.File outFile, java.util.Map<java.lang.String,​java.lang.String> config, FilterContext context, ITranslateCallback callback)
      Create translated file.
    • Method Detail

      • getFileFormatName

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

        java.lang.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 autodetects 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

        java.lang.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​(java.io.File inFile,
                                java.util.Map<java.lang.String,​java.lang.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​(java.io.File inFile,
                       java.util.Map<java.lang.String,​java.lang.String> config,
                       FilterContext context,
                       IParseCallback callback)
                throws java.lang.Exception
        Parse single file.
        Parameters:
        inFile - file to parse
        config - filter's configuration options
        context - processing context
        callback - callback for parsed data
        Throws:
        java.lang.Exception
      • translateFile

        void translateFile​(java.io.File inFile,
                           java.io.File outFile,
                           java.util.Map<java.lang.String,​java.lang.String> config,
                           FilterContext context,
                           ITranslateCallback callback)
                    throws java.lang.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:
        java.lang.Exception
      • alignFile

        void alignFile​(java.io.File inFile,
                       java.io.File outFile,
                       java.util.Map<java.lang.String,​java.lang.String> config,
                       FilterContext context,
                       IAlignCallback callback)
                throws java.lang.Exception
        Align 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:
        java.lang.Exception
      • hasOptions

        boolean hasOptions()
      • changeOptions

        @Deprecated
        java.util.Map<java.lang.String,​java.lang.String> changeOptions​(java.awt.Dialog parent,
                                                                             java.util.Map<java.lang.String,​java.lang.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

        default java.util.Map<java.lang.String,​java.lang.String> changeOptions​(java.awt.Window parent,
                                                                                     java.util.Map<java.lang.String,​java.lang.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

        java.lang.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