net.sf.okapi.common.filterwriter.ext
Class TMXContent

java.lang.Object
  extended by net.sf.okapi.common.filterwriter.ext.TMXContent

public class TMXContent
extends java.lang.Object

Handles the conversion between a coded text object and TMX.


Field Summary
static int CODEMODE_EMPTY
          Indicates that the inline codes should contain nothing.
static int CODEMODE_GENERIC
          Indicates that the inline codes should contain generic codes (e.g. <1>,,<2/>)
static int CODEMODE_LETTERCODED
          Indicates that the inline codes should contain letter-codes generic inline code (like OmegaT (e.g.
static int CODEMODE_ORIGINAL
          Indicates that the inline codes should contain the original code.
 
Constructor Summary
TMXContent()
          Creates a new TMXContent object without any content.
TMXContent(net.sf.okapi.common.resource.TextFragment content)
          Creates a new TMXContent object and set its content to the given fragment.
 
Method Summary
 int getCodeMode()
          Gets the flag for the code mode currently set.
 boolean getLetterCodedMode()
          Indicates if this formatter is set to output letter-coded content.
 void setCodeMode(int codeMode)
          Sets the type of content the inline codes should be output.
 TMXContent setContent(net.sf.okapi.common.resource.TextFragment content)
          Sets the fragment to format.
 void setLetterCodedMode(boolean value, boolean zeroBased)
          Sets the flag that indicates if the TMX generated should use letter-coded inline content.
 void setQuoteMode(int quoteMode)
          Sets the default quote mode.
 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.
 java.lang.String toString()
          Generates a TMX string from the content.
 java.lang.String toString(int quoteMode, boolean escapeGT)
          Generates a TMX string from the content.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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>,,<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. ,,)

See Also:
Constant Field Values
Constructor Detail

TMXContent

public TMXContent()
Creates a new TMXContent object without any content.


TMXContent

public TMXContent(net.sf.okapi.common.resource.TextFragment content)
Creates a new TMXContent object and set its content to the given fragment.

Parameters:
content - The TextFragment object to format.
Method Detail

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 attribute creationtool must 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 using toString() instead of toString(int, boolean).

Parameters:
quoteMode - 0=no quote escaped, 1=apos and quot, 2=#39 and quot, and 3=quot only.

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 the CODEMODE_... codes.

getCodeMode

public int getCodeMode()
Gets the flag for the code mode currently set.

Returns:
the code mode currently set: one of the CODEMODE_... codes.

setContent

public TMXContent setContent(net.sf.okapi.common.resource.TextFragment content)
Sets the fragment to format.

Parameters:
content - The TextFragment object to format.
Returns:
Itself

toString

public java.lang.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 by setQuoteMode(int) or 1 by default.

Overrides:
toString in class java.lang.Object
Returns:
The string formatted in TMX.

toString

public java.lang.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.