file2xliff4j
Class RTFExporter

java.lang.Object
  extended by file2xliff4j.OdfExporter
      extended by file2xliff4j.OOoTextExporter
          extended by file2xliff4j.RTFExporter
All Implemented Interfaces:
Converter

public class RTFExporter
extends OOoTextExporter
implements Converter

Class to export XLIFF to an RTF format.

Author:
Shane Perry <shane@lingotek.com>

Field Summary
 
Fields inherited from class file2xliff4j.OOoTextExporter
BLKSIZE
 
Fields inherited from interface file2xliff4j.Converter
BLKSIZE, formatSuffix, skeletonSuffix, startXliff, stylesTSkeletonSuffix, tSkeletonSuffix, xliffSuffix, xmlDeclaration
 
Constructor Summary
RTFExporter()
          Creates a new instance of OdfExporter
 
Method Summary
 ConversionStatus convert(ConversionMode mode, java.util.Locale language, java.lang.String phaseName, int maxPhase, java.nio.charset.Charset nativeEncoding, FileType nativeFileType, java.lang.String nativeFileName, java.lang.String baseDir, Notifier notifier)
          Deprecated. 
 ConversionStatus convert(ConversionMode mode, java.util.Locale language, java.lang.String phaseName, int maxPhase, java.nio.charset.Charset nativeEncoding, FileType nativeFileType, java.lang.String nativeFileName, java.lang.String baseDir, Notifier notifier, SegmentBoundary boundary, java.io.StringWriter generatedFileName)
          Convert one set of targets (in the translation units of an XLIFF file) back to a document in the original RTF format.
 ConversionStatus convert(ConversionMode mode, java.util.Locale language, java.lang.String phaseName, int maxPhase, java.nio.charset.Charset nativeEncoding, FileType nativeFileType, java.lang.String nativeFileName, java.lang.String baseDir, Notifier notifier, SegmentBoundary boundary, java.io.StringWriter generatedFileName, java.util.Set<f2xutils.XMLTuXPath> skipList)
          Convert one set of targets (in the translation units of an XLIFF file) back to a document in the original RTF format.
 java.lang.Object getConversionProperty(java.lang.String property)
          Return an object representing a format-specific (and converter-specific) property.
 FileType getFileType()
          Return the file type that this converter handles.
 void setConversionProperty(java.lang.String property, java.lang.Object value)
          Set a format-specific property that might affect the way that the conversion occurs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RTFExporter

public RTFExporter()
Creates a new instance of OdfExporter

Method Detail

convert

public ConversionStatus convert(ConversionMode mode,
                                java.util.Locale language,
                                java.lang.String phaseName,
                                int maxPhase,
                                java.nio.charset.Charset nativeEncoding,
                                FileType nativeFileType,
                                java.lang.String nativeFileName,
                                java.lang.String baseDir,
                                Notifier notifier,
                                SegmentBoundary boundary,
                                java.io.StringWriter generatedFileName)
                         throws ConversionException
Convert one set of targets (in the translation units of an XLIFF file) back to a document in the original RTF format. Use (besides the XLIFF file) the skeleton and format files that were generated when the XLIFF file was created.

This implementation first calls its superclass (OOoTextExporter), which exports the XLIFF to OpenDocument.org Text format. After that call returns, this method uses OpenOffice.org to convert the OpenOffice.org OpenDocument Text (odt) file to RTF format.

Specified by:
convert in interface Converter
Overrides:
convert in class OOoTextExporter
Parameters:
mode - The mode of conversion (FROM_XLIFF in this case.).
language - The language of the XLIFF targets to use in constructing the RTF document. The language is used in constructing a unique name for the output file. For example, if ja_JP is specified and the original input file was named myfile.odt, the output file name is myfile.ja_jp.odt. (Note that the Java Locale's toString method lowercases the characters of language codes.)
phaseName - The name of the phase to export. If this parameter's value is not null, it is matched against the value of the optional phase-name attribute of the target elements of the XLIFF document. If null, no check is made against a phase-name attribute.

If the phase name string consists entirely of numeric digit(s) equivalent to an integer with value greater than 1 but less than or equal to maxPhase (see next parameter) search for targets with lower numbered phase names.

maxPhase - The maximum phase number. If phaseName is specified as "0" and maxPhase is a non-negative integer, search for the highest "numbered" phase, starting at maxPhase, and searching down to phase "1".
nativeEncoding - The encoding of the input file. This parameter is ignored for RTF documents.
nativeFileType - The type of the original native file. (This value isn't really needed for export, for two reasons:
  1. Because the RTF Exporter is being called, we assume that the type is RTF.
  2. The XLIFF that will be exported includes the original native file type in the datatype attribute of its file element.
This parameter is present solely for consistency with the convert method of importers--importers need the file type to place in the XLIFF file.)
nativeFileName - The name of the original file that was previously converted to XLIFF. (It will likely be a file whose filename ends in ".doc"). This name is used for (at least) two purposes:
  1. As a "root" file name to which suffixes (like ".xliff", ".skeleton", etc.) can be appended to construct the xliff, skeleton, etc. files that will be exported to the output document.
  2. (Hmmm... When I wrote this yesterday, I had two purposes in mind. ... but someone interrupted me, and today I can't recall what the second purpose was. Feel free to edit this if you can figure it out.)
baseDir - The directory that contains the input doc file--from which we will read the input file. This is also the directory in which the output xliff, skeleton and format files (and any other intermediate or temporary files) will be written.
notifier - Instance of a class that implements the Notifier interface (to send notifications in case of conversion error).
boundary - (Ignored. The boundary on which to segment translation units (e.g., on paragraph or sentence boundaries) is meaningful only for importers--converters that generate XLIFF from documents.)
generatedFileName - If non-null, the converter will write the name of the file (without parent directories) to which the generated output file was written.
Returns:
Indicator of the status of the conversion.
Throws:
ConversionException - If a conversion exception is encountered.

convert

public ConversionStatus convert(ConversionMode mode,
                                java.util.Locale language,
                                java.lang.String phaseName,
                                int maxPhase,
                                java.nio.charset.Charset nativeEncoding,
                                FileType nativeFileType,
                                java.lang.String nativeFileName,
                                java.lang.String baseDir,
                                Notifier notifier,
                                SegmentBoundary boundary,
                                java.io.StringWriter generatedFileName,
                                java.util.Set<f2xutils.XMLTuXPath> skipList)
                         throws ConversionException
Convert one set of targets (in the translation units of an XLIFF file) back to a document in the original RTF format. Use (besides the XLIFF file) the skeleton and format files that were generated when the XLIFF file was created.

This implementation first calls its superclass (OOoTextExporter), which exports the XLIFF to OpenDocument.org Text format. After that call returns, this method uses OpenOffice.org to convert the OpenOffice.org OpenDocument Text (odt) file to RTF format.

Specified by:
convert in interface Converter
Overrides:
convert in class OOoTextExporter
Parameters:
mode - The mode of conversion (FROM_XLIFF in this case.).
language - The language of the XLIFF targets to use in constructing the RTF document. The language is used in constructing a unique name for the output file. For example, if ja_JP is specified and the original input file was named myfile.odt, the output file name is myfile.ja_jp.odt. (Note that the Java Locale's toString method lowercases the characters of language codes.)
phaseName - The name of the phase to export. If this parameter's value is not null, it is matched against the value of the optional phase-name attribute of the target elements of the XLIFF document. If null, no check is made against a phase-name attribute.

If the phase name string consists entirely of numeric digit(s) equivalent to an integer with value greater than 1 but less than or equal to maxPhase (see next parameter) search for targets with lower numbered phase names.

maxPhase - The maximum phase number. If phaseName is specified as "0" and maxPhase is a non-negative integer, search for the highest "numbered" phase, starting at maxPhase, and searching down to phase "1".
nativeEncoding - The encoding of the input file. This parameter is ignored for RTF documents.
nativeFileType - The type of the original native file. (This value isn't really needed for export, for two reasons:
  1. Because the RTF Exporter is being called, we assume that the type is RTF.
  2. The XLIFF that will be exported includes the original native file type in the datatype attribute of its file element.
This parameter is present solely for consistency with the convert method of importers--importers need the file type to place in the XLIFF file.)
nativeFileName - The name of the original file that was previously converted to XLIFF. (It will likely be a file whose filename ends in ".doc"). This name is used for (at least) two purposes:
  1. As a "root" file name to which suffixes (like ".xliff", ".skeleton", etc.) can be appended to construct the xliff, skeleton, etc. files that will be exported to the output document.
  2. (Hmmm... When I wrote this yesterday, I had two purposes in mind. ... but someone interrupted me, and today I can't recall what the second purpose was. Feel free to edit this if you can figure it out.)
baseDir - The directory that contains the input doc file--from which we will read the input file. This is also the directory in which the output xliff, skeleton and format files (and any other intermediate or temporary files) will be written.
notifier - Instance of a class that implements the Notifier interface (to send notifications in case of conversion error).
boundary - (Ignored. The boundary on which to segment translation units (e.g., on paragraph or sentence boundaries) is meaningful only for importers--converters that generate XLIFF from documents.)
generatedFileName - If non-null, the converter will write the name of the file (without parent directories) to which the generated output file was written.
skipList - (Not used by this converter.)
Returns:
Indicator of the status of the conversion.
Throws:
ConversionException - If a conversion exception is encountered.

convert

@Deprecated
public ConversionStatus convert(ConversionMode mode,
                                           java.util.Locale language,
                                           java.lang.String phaseName,
                                           int maxPhase,
                                           java.nio.charset.Charset nativeEncoding,
                                           FileType nativeFileType,
                                           java.lang.String nativeFileName,
                                           java.lang.String baseDir,
                                           Notifier notifier)
                         throws ConversionException
Deprecated. 

Convert one set of targets (in the translation units of an XLIFF file) back to a document in the original RTF format. Use (besides the XLIFF file) the skeleton and format files that were generated when the XLIFF file was created.

This implementation first calls its superclass (OOoTextExporter), which exports the XLIFF to OpenDocument.org Text format. After that call returns, this method uses OpenOffice.org to convert the OpenOffice.org OpenDocument Text (odt) file to RTF format.

Specified by:
convert in interface Converter
Overrides:
convert in class OOoTextExporter
Parameters:
mode - The mode of conversion (FROM_XLIFF in this case.).
language - The language of the XLIFF targets to use in constructing the RTF document. The language is used in constructing a unique name for the output file. For example, if ja_JP is specified and the original input file was named myfile.odt, the output file name is myfile.ja_jp.odt. (Note that the Java Locale's toString method lowercases the characters of language codes.)
phaseName - The name of the phase to export. If this parameter's value is not null, it is matched against the value of the optional phase-name attribute of the target elements of the XLIFF document. If null, no check is made against a phase-name attribute.

If the phase name string consists entirely of numeric digit(s) equivalent to an integer with value greater than 1 but less than or equal to maxPhase (see next parameter) search for targets with lower numbered phase names.

maxPhase - The maximum phase number. If phaseName is specified as "0" and maxPhase is a non-negative integer, search for the highest "numbered" phase, starting at maxPhase, and searching down to phase "1".
nativeEncoding - The encoding of the input file. This parameter is ignored for RTF documents.
nativeFileType - The type of the original native file. (This value isn't really needed for export, for two reasons:
  1. Because the RTF Exporter is being called, we assume that the type is RTF.
  2. The XLIFF that will be exported includes the original native file type in the datatype attribute of its file element.
This parameter is present solely for consistency with the convert method of importers--importers need the file type to place in the XLIFF file.)
nativeFileName - The name of the original file that was previously converted to XLIFF. (It will likely be a file whose filename ends in ".doc"). This name is used for (at least) two purposes:
  1. As a "root" file name to which suffixes (like ".xliff", ".skeleton", etc.) can be appended to construct the xliff, skeleton, etc. files that will be exported to the output document.
  2. (Hmmm... When I wrote this yesterday, I had two purposes in mind. ... but someone interrupted me, and today I can't recall what the second purpose was. Feel free to edit this if you can figure it out.)
baseDir - The directory that contains the input doc file--from which we will read the input file. This is also the directory in which the output xliff, skeleton and format files (and any other intermediate or temporary files) will be written.
notifier - Instance of a class that implements the Notifier interface (to send notifications in case of conversion error).
Returns:
Indicator of the status of the conversion.
Throws:
ConversionException - If a conversion exception is encountered.

getConversionProperty

public java.lang.Object getConversionProperty(java.lang.String property)
Return an object representing a format-specific (and converter-specific) property.

Specified by:
getConversionProperty in interface Converter
Overrides:
getConversionProperty in class OOoTextExporter
Parameters:
property - The name of the property to return.
Returns:
An Object that represents the property's value.

getFileType

public FileType getFileType()
Return the file type that this converter handles. (For importers, this means the file type that it imports to XLIFF; for exporters, it is the file type that ie exports to (from XLIFF).

Specified by:
getFileType in interface Converter
Overrides:
getFileType in class OOoTextExporter
Returns:
the RTF file type.

setConversionProperty

public void setConversionProperty(java.lang.String property,
                                  java.lang.Object value)
                           throws ConversionException
Set a format-specific property that might affect the way that the conversion occurs.

Note: This converter needs no format-specific properties. If any are passed, they will be silently ignored.

Specified by:
setConversionProperty in interface Converter
Overrides:
setConversionProperty in class OOoTextExporter
Parameters:
property - The name of the property
value - The value of the property
Throws:
ConversionException - If the property isn't recognized (and if it matters).