Class TMXContent


  • public class TMXContent
    extends Object
    Handles the conversion between a coded text object and TMX.
    • 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 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.
      • 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 the CODEMODE_... 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 by setQuoteMode(int) or 1 by default.
        Overrides:
        toString in class Object
        Returns:
        The string formatted in TMX.
      • 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.