Package net.sf.okapi.common.filterwriter
Class TMXContent
- java.lang.Object
-
- net.sf.okapi.common.filterwriter.TMXContent
-
public class TMXContent extends Object
Handles the conversion between a coded text object and TMX.
-
-
Field Summary
Fields Modifier and Type Field Description static intCODEMODE_EMPTYIndicates that the inline codes should contain nothing.static intCODEMODE_GENERICIndicates that the inline codes should contain generic codes (e.g.static intCODEMODE_LETTERCODEDIndicates that the inline codes should contain letter-codes generic inline code (like OmegaT (e.g.static intCODEMODE_ORIGINALIndicates that the inline codes should contain the original code.
-
Constructor Summary
Constructors Constructor Description TMXContent()Creates a new TMXContent object without any content.TMXContent(TextFragment content)Creates a new TMXContent object and set its content to the given fragment.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CharsetEncodergetCharsetEncoder()Gets the current character set encoder.intgetCodeMode()Gets the flag for the code mode currently set.booleangetLetterCodedMode()Indicates if this formatter is set to output letter-coded content.voidsetCharsetEncoder(CharsetEncoder chsEnc)Sets the character set encoder to use.voidsetCodeMode(int codeMode)Sets the type of content the inline codes should be output.TMXContentsetContent(TextFragment content)Sets the fragment to format.voidsetLetterCodedMode(boolean value, boolean zeroBased)Sets the flag that indicates if the TMX generated should use letter-coded inline content.voidsetQuoteMode(int quoteMode)Sets the default quote mode.voidsetTradosWorkarounds(boolean value)Sets the flag that indicates if the TMX generated should use workarounds so the output can be read in some versions of Trados Translators' Workbench that have bugs leading to the lose of data.StringtoString()Generates a TMX string from the content.StringtoString(int quoteMode, boolean escapeGT)Generates a TMX string from the content.
-
-
-
Field Detail
-
CODEMODE_ORIGINAL
public static final int CODEMODE_ORIGINAL
Indicates that the inline codes should contain the original code.- See Also:
- Constant Field Values
-
CODEMODE_EMPTY
public static final int CODEMODE_EMPTY
Indicates that the inline codes should contain nothing.- See Also:
- Constant Field Values
-
CODEMODE_GENERIC
public static final int CODEMODE_GENERIC
Indicates that the inline codes should contain generic codes (e.g. <1>,</1>,<2/>)- See Also:
- Constant Field Values
-
CODEMODE_LETTERCODED
public static final int CODEMODE_LETTERCODED
Indicates that the inline codes should contain letter-codes generic inline code (like OmegaT (e.g. <g0>,</g0>,<x1/>)- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TMXContent
public TMXContent()
Creates a new TMXContent object without any content.
-
TMXContent
public TMXContent(TextFragment content)
Creates a new TMXContent object and set its content to the given fragment.- Parameters:
content- The TextFragment object to format.
-
-
Method Detail
-
setCharsetEncoder
public void setCharsetEncoder(CharsetEncoder chsEnc)
Sets the character set encoder to use.- Parameters:
chsEnc- the character set encoder to use.
-
getCharsetEncoder
public CharsetEncoder getCharsetEncoder()
Gets the current character set encoder.- Returns:
- the current character set encoder.
-
setTradosWorkarounds
public void setTradosWorkarounds(boolean value)
Sets the flag that indicates if the TMX generated should use workarounds so the output can be read in some versions of Trados Translators' Workbench that have bugs leading to the lose of data.- Parameters:
value- true to use workarounds, false to not use workarounds.
-
setLetterCodedMode
public void setLetterCodedMode(boolean value, boolean zeroBased)Sets the flag that indicates if the TMX generated should use letter-coded inline content. Note that for OmegaT to take the work-around into account, the attributecreationtoolmust be set to "OmegaT".- Parameters:
value- true to use workarounds, false to not use workarounds.zeroBased- true to have 0-based code, false for unaltered IDs.
-
getLetterCodedMode
public boolean getLetterCodedMode()
Indicates if this formatter is set to output letter-coded content.- Returns:
- true if the formatter is set for OmegaT.
-
setQuoteMode
public void setQuoteMode(int quoteMode)
Sets the default quote mode. This value is used when usingtoString()instead oftoString(int, boolean).- Parameters:
quoteMode- 0=no quote escaped, 1=apos and quot, 2=#39 and quot, and 3=quot only.
-
getCodeMode
public int getCodeMode()
Gets the flag for the code mode currently set.- Returns:
- the code mode currently set: one of the
CODEMODE_...codes.
-
setCodeMode
public void setCodeMode(int codeMode)
Sets the type of content the inline codes should be output.- Parameters:
codeMode- the code for the inline code mode: one of theCODEMODE_...codes.
-
setContent
public TMXContent setContent(TextFragment content)
Sets the fragment to format.- Parameters:
content- The TextFragment object to format.- Returns:
- Itself
-
toString
public String toString()
Generates a TMX string from the content. This is the same as calling this.toString(quoteMode, true), where quoteMode is the value set bysetQuoteMode(int)or 1 by default.
-
toString
public String toString(int quoteMode, boolean escapeGT)
Generates a TMX string from the content.- Parameters:
quoteMode- 0=no quote escaped, 1=apos and quot, 2=#39 and quot, and 3=quot only.escapeGT- True to always escape '>' to gt.- Returns:
- The string formatted in TMX.
-
-