net.sf.okapi.common.filterwriter

## Class XLIFFContent

- java.lang.Object
- - net.sf.okapi.common.filterwriter.XLIFFContent

-     public class XLIFFContent
      extends java.lang.Object

  Handles the conversion between a coded text object and XLIFF. In some case this class may output ITS attributes. It assumes the namespace for ITS is declared and the corresponding prefix is 'its'.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `ITS_PREFIX`
    `static java.lang.String` | `REF_PREFIX`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XLIFFContent()` Creates a new XLIFFContent object without any content.
    `XLIFFContent(java.lang.String codedText, java.util.List<Code> codes, XLIFFContent innerContent, java.nio.charset.CharsetEncoder chsEnc, java.util.List<GenericAnnotations> standoff, ITSContent itsCont)`
    `XLIFFContent(TextFragment content)` Creates a new XLIFFContent object and set its content to the given fragment.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clearStandoff()`
    `java.nio.charset.CharsetEncoder` | `getCharsetEncoder()` Gets the current character set encoder.
    `java.lang.String` | `getCodedText()`
    `java.util.List<Code>` | `getCodes()`
    `XLIFFContent` | `getInnerContent()`
    `ITSContent` | `getItsCont()`
    `java.util.List<GenericAnnotations>` | `getStandoff()` Gets the standoff information for a possible list of annotations.
    `void` | `setCharsetEncoder(java.nio.charset.CharsetEncoder chsEnc)` Sets the character set encoder to use.
    `XLIFFContent` | `setContent(TextFragment content)` Sets the fragment to format.
    `XLIFFContent` | `setContent(TextFragment content, boolean resetStandoff)` Sets the fragment to format.
    `java.lang.String` | `toSegmentedString(TextContainer container, int quoteMode, boolean escapeGT, boolean withMarkers, boolean gMode, boolean codeAttrs, boolean includeIts, LocaleId trgLocId)` Generates an XLIFF string from a given text container.
    `java.lang.String` | `toString()` Generates an XLIFF string from the content.
    `java.lang.String` | `toString(boolean gMode)` Generates an XLIFF string from the content.
    `java.lang.String` | `toString(int quoteMode, boolean escapeGT, boolean codeOnlyMode, boolean gMode, boolean codeAttrs, boolean includeIts, LocaleId trgLocId)` Generates an XLIFF string from the content.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### ITS_PREFIX

          public static final java.lang.String ITS_PREFIX

      See Also:
        Constant Field Values

    - #### REF_PREFIX

          public static final java.lang.String REF_PREFIX

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### XLIFFContent

          public XLIFFContent()

      Creates a new XLIFFContent object without any content.

    - #### XLIFFContent

          public XLIFFContent(TextFragment content)

      Creates a new XLIFFContent object and set its content to the given fragment.
      Parameters:
        `content` - The TextFragment object to format.

    - #### XLIFFContent

          public XLIFFContent(java.lang.String codedText,
                      java.util.List<Code> codes,
                      XLIFFContent innerContent,
                      java.nio.charset.CharsetEncoder chsEnc,
                      java.util.List<GenericAnnotations> standoff,
                      ITSContent itsCont)

  - ### Method Detail

    - #### setCharsetEncoder

          public void setCharsetEncoder(java.nio.charset.CharsetEncoder chsEnc)

      Sets the character set encoder to use.
      Parameters:
        `chsEnc` - the character set encoder to use.

    - #### getCharsetEncoder

          public java.nio.charset.CharsetEncoder getCharsetEncoder()

      Gets the current character set encoder.
      Returns:
        the current character set encoder.

    - #### setContent

          public XLIFFContent setContent(TextFragment content)

      Sets the fragment to format. This method does not reset any possible standoff items.
      Parameters:
        `content` - The TextFragment object to format.
      Returns:
        Itself

    - #### setContent

          public XLIFFContent setContent(TextFragment content,
                                boolean resetStandoff)

      Sets the fragment to format.
      Parameters:
        `content` - The TextFragment object to format.
        `resetStandoff` - true to reset the ITS standoff items (e.g. when the fragment is the whole content of a text container).
      Returns:
        Itself

    - #### toString

          public java.lang.String toString()

      Generates an XLIFF string from the content. This is the same as calling this.toString(1, true, false, false, false, true).
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        The string formatted in XLIFF.

    - #### toString

          public java.lang.String toString(boolean gMode)

      Generates an XLIFF string from the content. This is the same as calling this.toString(1, true, false, gMode, false, true) and setting gMode.
      Parameters:
        `gMode` - True to use g/x markup, false to use bpt/ept/ph
      Returns:
        The string formatted in XLIFF.

    - #### toString

          public java.lang.String toString(int quoteMode,
                                  boolean escapeGT,
                                  boolean codeOnlyMode,
                                  boolean gMode,
                                  boolean codeAttrs,
                                  boolean includeIts,
                                  LocaleId trgLocId)

      Generates an XLIFF string from the content.

      In some cases, a reference to an ITS standoff element may be generated. Use `getStandoff()` to get the standoff information that needs to be output along with the inline reference. Each call to this method resets the standoff information returned by `getStandoff()`.

      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
        `codeOnlyMode` - True when the in-line codes are to be set as raw-values.
        `gMode` - True to use g/x markup, false to use bpt/ept/ph This option is to be used when the in-line code is an XLIFF-in-line code itself.
        `codeAttrs` - True to include extended code attributes in the output.
        `includeIts` - True to include ITS markup in the output.
        `trgLocId` - the id of the target locale.
      Returns:
        The string formatted in XLIFF.

    - #### toSegmentedString

          public java.lang.String toSegmentedString(TextContainer container,
                                           int quoteMode,
                                           boolean escapeGT,
                                           boolean withMarkers,
                                           boolean gMode,
                                           boolean codeAttrs,
                                           boolean includeIts,
                                           LocaleId trgLocId)

      Generates an XLIFF string from a given text container.
      Parameters:
        `container` - The container to write out.
        `quoteMode` - 0=no quote escaped, 1=apos and quot, 2=#39 and quot, and 3=quot only.
        `escapeGT` - True to always escape '>' to &gt;
        `withMarkers` - True to output mrk elements, false to output only the content of mrk element.
        `gMode` - True to use g/x markup, false to use bpt/ept/ph
        `codeAttrs` - True to include extended code attributes in the output.
        `includeIts` - True to include ITS markup in the output.
        `trgLocId` - the id of the target locale.
      Returns:
        The coded string.

    - #### getStandoff

          public java.util.List<GenericAnnotations> getStandoff()

      Gets the standoff information for a possible list of annotations.
      Returns:
        null if there are no standoff markup to generate, or a list of `GenericAnnotations` objects. The data of each annotation set is the id that is used in the local markup to point to this standoff markup.

    - #### clearStandoff

          public void clearStandoff()

    - #### getCodedText

          public final java.lang.String getCodedText()

    - #### getCodes

          public final java.util.List<Code> getCodes()

    - #### getInnerContent

          public final XLIFFContent getInnerContent()

    - #### getItsCont

          public final ITSContent getItsCont()