file2xliff4j
Class ConverterFactory

java.lang.Object
  extended by file2xliff4j.ConverterFactory

public class ConverterFactory
extends java.lang.Object

Author:
Weldon Whipple <weldon@lingotek.com>

Field Summary
static int SIG_LENGTH
          A default number of bytes to attempt to read
 
Constructor Summary
ConverterFactory()
           
 
Method Summary
static Converter createConverter(FileType fromType, FileType toType)
          Passed the "from" and "to" types of a conversion request, return an appropriate converter that knows how to perform the conversion.
static Converter createConverter(FileType fromType, FileType toType, FileType originalType)
          Passed the "from" and "to" types of a conversion request, return an appropriate converter that knows how to perform the conversion.
static Converter createConverter(FileType fromType, FileType toType, java.lang.String fromFileName)
          Passed the "from" and "to" types of a conversion request, as well as the file name of the "from" file (with the full path specified) return an appropriate converter that knows how to perform the conversion.
static FileType identifyFormat(java.lang.String fileName)
          Passed the name of a file, read its initial bytes and identify its format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SIG_LENGTH

public static final int SIG_LENGTH
A default number of bytes to attempt to read

See Also:
Constant Field Values
Constructor Detail

ConverterFactory

public ConverterFactory()
Method Detail

createConverter

public static Converter createConverter(FileType fromType,
                                        FileType toType)
                                 throws ConversionException
Passed the "from" and "to" types of a conversion request, return an appropriate converter that knows how to perform the conversion.

Parameters:
fromType - The type that will be converted from
toType - Type of file that will be converted to
Returns:
An instance of the requested converter
Throws:
ConversionException - if unable to create the requested Converter

createConverter

public static Converter createConverter(FileType fromType,
                                        FileType toType,
                                        FileType originalType)
                                 throws ConversionException
Passed the "from" and "to" types of a conversion request, return an appropriate converter that knows how to perform the conversion.

New functionality: A new third parameter--originalType--is now used for converters that convert from XLIFF to a format that is different from the original format. This occurs, for example, with PDF, where the export of target documents is currently to Word, ODT or plaintext. (Some future release of the PDF Exporters might actually be smart enough to export back to PDF format and have it look reasonable [sigh].)

Parameters:
fromType - The type that will be converted from
toType - Type of file that will be converted to
Returns:
An instance of the requested converter
Throws:
ConversionException - if unable to create the requested Converter

createConverter

public static Converter createConverter(FileType fromType,
                                        FileType toType,
                                        java.lang.String fromFileName)
                                 throws ConversionException
Passed the "from" and "to" types of a conversion request, as well as the file name of the "from" file (with the full path specified) return an appropriate converter that knows how to perform the conversion.

Parameters:
fromType - The type that will be converted from
toType - Type of file that will be converted to
fromFileName - The full path/file name of the file converting from
Returns:
An instance of the requested converter
Throws:
ConversionException - if unable to create the requested Converter

identifyFormat

public static FileType identifyFormat(java.lang.String fileName)
Passed the name of a file, read its initial bytes and identify its format.

Parameters:
fileName - The name of the file (including full path name) whose format will be confirmed.
Returns:
Its FileType or null if unknown.