Class AbstractFilter

    • Field Detail

      • ENCODING_AUTO_HUMAN

        public static final java.lang.String ENCODING_AUTO_HUMAN
        This value represents to the user that the encoding is determined by the filter itself. "In code" the null is used to represent automatic encoding selection.
      • TFP_FILENAME

        public static final java.lang.String TFP_FILENAME
        The original filename (with extension).
        See Also:
        Constant Field Values
      • TFP_NAMEONLY

        public static final java.lang.String TFP_NAMEONLY
        The original filename without extension.
        See Also:
        Constant Field Values
      • TFP_EXTENSION

        public static final java.lang.String TFP_EXTENSION
        The original file extension.
        See Also:
        Constant Field Values
      • TFP_TARGET_LOCALE

        public static final java.lang.String TFP_TARGET_LOCALE
        "xx_YY", locale code
        See Also:
        Constant Field Values
      • TFP_TARGET_LANGUAGE

        public static final java.lang.String TFP_TARGET_LANGUAGE
        "XX-YY", the TMX/XML language code
        See Also:
        Constant Field Values
      • TFP_TARGET_LANG_CODE

        public static final java.lang.String TFP_TARGET_LANG_CODE
        language "XX" only
        See Also:
        Constant Field Values
      • TFP_TARGET_COUNTRY_CODE

        public static final java.lang.String TFP_TARGET_COUNTRY_CODE
        country "YY" only
        See Also:
        Constant Field Values
      • TFP_TARGET_COUTRY_CODE

        public static final java.lang.String TFP_TARGET_COUTRY_CODE
        Old spelling of the variable for country "YY" only
        See Also:
        Constant Field Values
      • TFP_TIMESTAMP_LA

        public static final java.lang.String TFP_TIMESTAMP_LA
        System time at generation time in various patterns.
        See Also:
        Constant Field Values
      • TFP_TIMESTAMP_LD

        public static final java.lang.String TFP_TIMESTAMP_LD
        See Also:
        Constant Field Values
      • TFP_TIMESTAMP_LDD

        public static final java.lang.String TFP_TIMESTAMP_LDD
        See Also:
        Constant Field Values
      • TFP_TIMESTAMP_LH

        public static final java.lang.String TFP_TIMESTAMP_LH
        See Also:
        Constant Field Values
      • TFP_TIMESTAMP_LHH

        public static final java.lang.String TFP_TIMESTAMP_LHH
        See Also:
        Constant Field Values
      • TFP_TIMESTAMP_LM

        public static final java.lang.String TFP_TIMESTAMP_LM
        See Also:
        Constant Field Values
      • TFP_TIMESTAMP_LMM

        public static final java.lang.String TFP_TIMESTAMP_LMM
        See Also:
        Constant Field Values
      • TFP_TIMESTAMP_LS

        public static final java.lang.String TFP_TIMESTAMP_LS
        See Also:
        Constant Field Values
      • TFP_TIMESTAMP_LSS

        public static final java.lang.String TFP_TIMESTAMP_LSS
        See Also:
        Constant Field Values
      • TFP_TIMESTAMP_LYYYY

        public static final java.lang.String TFP_TIMESTAMP_LYYYY
        See Also:
        Constant Field Values
      • TFP_TIMESTAMP_UD

        public static final java.lang.String TFP_TIMESTAMP_UD
        See Also:
        Constant Field Values
      • TFP_TIMESTAMP_UEEE

        public static final java.lang.String TFP_TIMESTAMP_UEEE
        See Also:
        Constant Field Values
      • TFP_TIMESTAMP_UEEEE

        public static final java.lang.String TFP_TIMESTAMP_UEEEE
        See Also:
        Constant Field Values
      • TFP_TIMESTAMP_UH

        public static final java.lang.String TFP_TIMESTAMP_UH
        See Also:
        Constant Field Values
      • TFP_TIMESTAMP_UHH

        public static final java.lang.String TFP_TIMESTAMP_UHH
        See Also:
        Constant Field Values
      • TFP_TIMESTAMP_UM

        public static final java.lang.String TFP_TIMESTAMP_UM
        See Also:
        Constant Field Values
      • TFP_TIMESTAMP_UMM

        public static final java.lang.String TFP_TIMESTAMP_UMM
        See Also:
        Constant Field Values
      • TFP_TIMESTAMP_UMMM

        public static final java.lang.String TFP_TIMESTAMP_UMMM
        See Also:
        Constant Field Values
      • TFP_SYSTEM_OS_NAME

        public static final java.lang.String TFP_SYSTEM_OS_NAME
        Workstation properties.
        See Also:
        Constant Field Values
      • TFP_SYSTEM_OS_VERSION

        public static final java.lang.String TFP_SYSTEM_OS_VERSION
        See Also:
        Constant Field Values
      • TFP_SYSTEM_OS_ARCH

        public static final java.lang.String TFP_SYSTEM_OS_ARCH
        See Also:
        Constant Field Values
      • TFP_SYSTEM_USER_NAME

        public static final java.lang.String TFP_SYSTEM_USER_NAME
        See Also:
        Constant Field Values
      • TFP_SYSTEM_HOST_NAME

        public static final java.lang.String TFP_SYSTEM_HOST_NAME
        See Also:
        Constant Field Values
      • TFP_FILE_SOURCE_ENCODING

        public static final java.lang.String TFP_FILE_SOURCE_ENCODING
        File properties.
        See Also:
        Constant Field Values
      • TFP_FILE_TARGET_ENCODING

        public static final java.lang.String TFP_FILE_TARGET_ENCODING
        See Also:
        Constant Field Values
      • TFP_FILE_FILTER_NAME

        public static final java.lang.String TFP_FILE_FILTER_NAME
        See Also:
        Constant Field Values
      • TFP_TARGET_LOCALE_LCID

        public static final java.lang.String TFP_TARGET_LOCALE_LCID
        Microsoft.
        See Also:
        Constant Field Values
      • TARGET_DEFAULT

        public static final java.lang.String TARGET_DEFAULT
        The default output filename pattern.

        It is equal to "${filename}", which means that the name of the translated file should be the same as the name of the input file.

        See Also:
        Constant Field Values
    • Constructor Detail

      • AbstractFilter

        public AbstractFilter()
    • Method Detail

      • getTargetFilenamePatterns

        public static java.util.List<java.lang.String> getTargetFilenamePatterns()
      • getFileFormatName

        public abstract java.lang.String getFileFormatName()
        Human-readable name of the File Format this filter supports.
        Specified by:
        getFileFormatName in interface IFilter
        Returns:
        File format name
      • getDefaultInstances

        public abstract 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.

        Specified by:
        getDefaultInstances in interface IFilter
        Returns:
        Default filter instances
      • isSourceEncodingVariable

        public abstract 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).

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

        public abstract 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.

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

        public boolean isFileSupported​(java.io.File inFile,
                                       java.util.Map<java.lang.String,​java.lang.String> config,
                                       FilterContext fc)
        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 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
        Parameters:
        inFile - Source file.
        fc - Filter context.
        config - filter's configuration options
        Returns:
        Does the filter support the file.
      • getFuzzyMark

        public 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.
        Specified by:
        getFuzzyMark in interface IFilter
        Returns:
        fuzzy mark prefix
      • getHint

        public 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.
        Specified by:
        getHint in interface IFilter
        Returns:
        The hint for editing the filter in a non-geek language.
      • hasOptions

        public boolean hasOptions()
        OmegaT calls this to see whether the filter has any options. By default returns false, so filter authors should override this to tell OmegaT core that this filter has options.
        Specified by:
        hasOptions in interface IFilter
        Returns:
        True if the filter has any options, and false otherwise.
      • changeOptions

        @Deprecated
        public 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 IFilter.changeOptions(Window, Map) instead.

        Specified by:
        changeOptions in interface IFilter
        Parameters:
        parent - parent window
        config - old options
        Returns:
        new options or null if options not changed
      • parseFile

        public final void parseFile​(java.io.File inFile,
                                    java.util.Map<java.lang.String,​java.lang.String> config,
                                    FilterContext fc,
                                    IParseCallback callback)
                             throws java.lang.Exception
        Description copied from interface: IFilter
        Parse single file.
        Specified by:
        parseFile in interface IFilter
        Parameters:
        inFile - file to parse
        config - filter's configuration options
        fc - processing context
        callback - callback for parsed data
        Throws:
        java.lang.Exception
      • alignFile

        public final void alignFile​(java.io.File inFile,
                                    java.io.File outFile,
                                    java.util.Map<java.lang.String,​java.lang.String> config,
                                    FilterContext fc,
                                    IAlignCallback callback)
                             throws java.lang.Exception
        Description copied from interface: IFilter
        Align source and translated files. NB: this is not used for Tools->align files..., but for aligning in console mode
        Specified by:
        alignFile in interface IFilter
        Parameters:
        inFile - source file
        outFile - translated file
        config - filter's configuration options
        fc - processing context
        callback - callback for store aligned data
        Throws:
        java.lang.Exception
      • translateFile

        public final void translateFile​(java.io.File inFile,
                                        java.io.File outFile,
                                        java.util.Map<java.lang.String,​java.lang.String> config,
                                        FilterContext fc,
                                        ITranslateCallback callback)
                                 throws java.lang.Exception
        Description copied from interface: IFilter
        Create translated file.
        Specified by:
        translateFile in interface IFilter
        Parameters:
        inFile - source file
        outFile - output file
        config - filter's configuration options
        fc - processing context
        callback - callback for get translation
        Throws:
        java.lang.Exception
      • setCallbacks

        public void setCallbacks​(IParseCallback parseCallback,
                                 ITranslateCallback translateCallback)
        Set both callbacks. Used for child XML filters only.
        Parameters:
        parseCallback -
        translateCallback -
      • getInEncodingLastParsedFile

        public java.lang.String getInEncodingLastParsedFile()
        Description copied from interface: IFilter
        Returns the encoding of the last parsed source file.
        Specified by:
        getInEncodingLastParsedFile in interface IFilter
        Returns:
        the encoding of the last parsed source file, or null when no file has been parsed yet.