Package net.sf.okapi.common.filterwriter
Class XLIFFContent
- java.lang.Object
-
- net.sf.okapi.common.filterwriter.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'.
-
-
Field Summary
Fields Modifier and Type Field Description static StringITS_PREFIXstatic StringREF_PREFIX
-
Constructor Summary
Constructors Constructor Description XLIFFContent()Creates a new XLIFFContent object without any content.XLIFFContent(String codedText, List<Code> codes, XLIFFContent innerContent, CharsetEncoder chsEnc, List<GenericAnnotations> standoff, ITSContent itsCont)XLIFFContent(TextFragment content)Creates a new XLIFFContent object and set its content to the given fragment.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearStandoff()CharsetEncodergetCharsetEncoder()Gets the current character set encoder.StringgetCodedText()List<Code>getCodes()XLIFFContentgetInnerContent()ITSContentgetItsCont()List<GenericAnnotations>getStandoff()Gets the standoff information for a possible list of annotations.voidsetCharsetEncoder(CharsetEncoder chsEnc)Sets the character set encoder to use.XLIFFContentsetContent(TextFragment content)Sets the fragment to format.XLIFFContentsetContent(TextFragment content, boolean resetStandoff)Sets the fragment to format.StringtoSegmentedString(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.StringtoString()Generates an XLIFF string from the content.StringtoString(boolean gMode)Generates an XLIFF string from the content.StringtoString(int quoteMode, boolean escapeGT, boolean codeOnlyMode, boolean gMode, boolean codeAttrs, boolean includeIts, LocaleId trgLocId)Generates an XLIFF string from the content.
-
-
-
Field Detail
-
ITS_PREFIX
public static final String ITS_PREFIX
- See Also:
- Constant Field Values
-
REF_PREFIX
public static final 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(String codedText, List<Code> codes, XLIFFContent innerContent, CharsetEncoder chsEnc, List<GenericAnnotations> standoff, ITSContent itsCont)
-
-
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).
-
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 bygetStandoff().- Parameters:
quoteMode- 0=no quote escaped, 1=apos and quot, 2=#39 and quot, and 3=quot only.escapeGT- True to always escape '>' to gtcodeOnlyMode- 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/phcodeAttrs- 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
GenericAnnotationsobjects. 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()
-
getInnerContent
public final XLIFFContent getInnerContent()
-
getItsCont
public final ITSContent getItsCont()
-
-