Class XLIFFContent


  • public class XLIFFContent
    extends 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'.
    • 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.
    • 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.
      • 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 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 Object
        Returns:
        The string formatted in XLIFF.
      • toString

        public 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 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 String toSegmentedString​(TextContainer container,
                                        int quoteMode,
                                        boolean escapeGT,
                                        boolean withMarkers,
                                        boolean gMode,
                                        boolean codeAttrs,
                                        boolean includeIts,
                                        boolean isTarget,
                                        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 >
        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 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 String getCodedText()
      • getCodes

        public final List<Code> getCodes()
      • getInnerContent

        public final XLIFFContent getInnerContent()
      • getItsCont

        public final ITSContent getItsCont()