public class FilterMaster
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CURRENT_VERSION
Currently file filters support version.
|
static java.lang.String |
FILE_FILTERS
name of the filter configuration file
|
static java.lang.String |
INITIAL_VERSION
There was no version of file filters support (1.4.5 Beta 1 -- 1.6.0 RC12).
|
static java.lang.String |
OT160FINAL_VERSION |
static java.lang.String |
OT160RC12A_VERSION
File filters support of 1.6.0 RC12a: now upgrading the configuration.
|
static java.lang.String |
OT161_VERSION |
static java.lang.String |
OT170_VERSION |
Constructor and Description |
---|
FilterMaster(Filters config)
Create a new FilterMaster.
|
Modifier and Type | Method and Description |
---|---|
void |
alignFile(java.lang.String sourceDir,
java.lang.String fileName,
java.lang.String targetdir,
FilterContext fc,
IAlignCallback alignCallback) |
static Filters |
cloneConfig(Filters orig)
Clone config for editing
|
static Filter |
cloneFilter(Filter filter)
Clone one filter's config for editing.
|
static Filters |
createDefaultFiltersConfig()
Reverts Filter Configuration to Default values.
|
static java.util.Map<java.lang.String,java.lang.String> |
forFilter(java.util.List<Filter.Option> options)
Convert options from xml for filter usage.
|
Filters |
getConfig() |
static Filter |
getDefaultSettingsFromFilter(java.lang.String filterClassname)
Create default filter's config.
|
static IFilter |
getFilterInstance(java.lang.String classname)
Get filter's instance by filter class name.
|
static java.util.List<java.lang.String> |
getSupportedEncodings()
Queries JRE for the list of supported encodings.
|
java.lang.String |
getTargetForSource(java.lang.String sourceDir,
java.lang.String srcRelPath,
FilterContext fc)
Calculate the target path corresponding to the given source file.
|
boolean |
isBilingualFile(java.io.File file) |
boolean |
isFileSupported(java.io.File file,
boolean quick)
Check to see if a file is supported by any filter.
|
static Filters |
loadConfig(java.io.File configFile)
Loads information about the filters from an XML file.
|
IFilter |
loadFile(java.lang.String filename,
FilterContext fc,
IParseCallback parseCallback)
OmegaT core calls this method to load a source file.
|
static java.lang.String |
now(java.lang.String dateFormat)
Return current system time in the specified date format.
|
static void |
saveConfig(Filters config,
java.io.File configFile)
Saves information about the filters to an XML file.
|
static void |
setFilterClasses(java.util.List<java.lang.Class<?>> classes) |
static void |
setOptions(Filter f,
java.util.Map<java.lang.String,java.lang.String> newOptions)
Convert options to xml from map.
|
void |
translateFile(java.lang.String sourcedir,
java.lang.String filename,
java.lang.String targetdir,
FilterContext fc,
ITranslateCallback translateCallback)
OmegaT core calls this method to translate a source file.
|
public static final java.lang.String FILE_FILTERS
public static final java.lang.String INITIAL_VERSION
public static final java.lang.String OT160RC12A_VERSION
public static final java.lang.String OT160FINAL_VERSION
public static final java.lang.String OT161_VERSION
public static final java.lang.String OT170_VERSION
public static final java.lang.String CURRENT_VERSION
public FilterMaster(Filters config)
public static void setFilterClasses(java.util.List<java.lang.Class<?>> classes)
public Filters getConfig()
public static IFilter getFilterInstance(java.lang.String classname)
classname
- filter's class namepublic IFilter loadFile(java.lang.String filename, FilterContext fc, IParseCallback parseCallback) throws java.io.IOException, TranslationException
filename
- The name of the source file to load.java.io.IOException
TranslationException
translateFile(String, String, String, FilterContext,
ITranslateCallback)
public void translateFile(java.lang.String sourcedir, java.lang.String filename, java.lang.String targetdir, FilterContext fc, ITranslateCallback translateCallback) throws java.io.IOException, TranslationException
sourcedir
- The folder of the source inFile.filename
- The name of the source inFile to process (only the part, relative to source folder).targetdir
- The folder to place the translated inFile to.fc
- Filter context.java.io.IOException
TranslationException
public void alignFile(java.lang.String sourceDir, java.lang.String fileName, java.lang.String targetdir, FilterContext fc, IAlignCallback alignCallback) throws java.lang.Exception
java.lang.Exception
public boolean isFileSupported(java.io.File file, boolean quick)
quick
is true, only the filename will be checked to see if
it matches known supported patterns. When false, the filter may have to
actually load some or all of the file in order to determine whether or
not it is supported.file
- The file to checkquick
- When true, check only the file namepublic boolean isBilingualFile(java.io.File file) throws java.lang.Exception
java.lang.Exception
public static java.util.List<java.lang.String> getSupportedEncodings()
public static Filters createDefaultFiltersConfig()
public static Filters loadConfig(java.io.File configFile) throws java.io.IOException
setupDefaultFilters
.java.io.IOException
public static void saveConfig(Filters config, java.io.File configFile) throws java.io.IOException
java.io.IOException
public static java.lang.String now(java.lang.String dateFormat)
dateFormat
- Date format for java.text.SimpleDateFormat.public java.lang.String getTargetForSource(java.lang.String sourceDir, java.lang.String srcRelPath, FilterContext fc) throws java.io.IOException, TranslationException
sourceDir
- Path to the project's source
dirsrcRelPath
- Relative path under sourceDir
of the source filefc
- Filter contexttarget
of the corresponding target filejava.io.IOException
TranslationException
public static Filters cloneConfig(Filters orig)
public static Filter cloneFilter(Filter filter)
f
- one filter's configpublic static Filter getDefaultSettingsFromFilter(java.lang.String filterClassname)
filterClassname
- filter's classnamepublic static java.util.Map<java.lang.String,java.lang.String> forFilter(java.util.List<Filter.Option> options)
options
- xml optionspublic static void setOptions(Filter f, java.util.Map<java.lang.String,java.lang.String> newOptions)
f
- filternewOptions
- options