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

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

public class ITSContent
extends java.lang.Object

Utilities for writing out ITS markup.


Field Summary
static java.lang.String REF_PREFIX
           
static java.lang.String STANDOFFMARKER
          Marker used in a skeleton part to indicate where standoff markup can be inserted when merging.
 
Constructor Summary
ITSContent(java.nio.charset.CharsetEncoder encoder, boolean isHTML5, boolean isXLIFF)
          Creates an ITSContent object with a given character set encoder.
 
Method Summary
 void clearStandoff()
          Clears the standoff markup.
 java.util.List<net.sf.okapi.common.annotation.GenericAnnotations> getStandoff()
          Gets the current standoff markup.
 boolean hasStandoff()
          Indicates if this object has at least standoff item.
static boolean isExtendedMatch(java.lang.String langRanges, java.lang.String langTag)
          Indicates if a given language tag matches at least one item of a list of extended language ranges.
 void outputAnnotations(net.sf.okapi.common.annotation.GenericAnnotations anns, java.lang.StringBuilder output, boolean inline, boolean mrk, net.sf.okapi.common.LocaleId trgLocId)
          Generates the markup for the ITS attributes for a given annotation set.
 java.lang.String writeAttributeProvenance(net.sf.okapi.common.annotation.GenericAnnotation ann)
           
 java.lang.String writeAttributesLQI(net.sf.okapi.common.annotation.GenericAnnotation ann)
          Writes the data attributes for a given LQI annotation (not locQualityIssuesRef).
 java.lang.String writeStandoffLQI()
          Output the standoff markup for this object and clear it afterward.
 java.lang.String writeStandoffLQI(java.util.List<net.sf.okapi.common.annotation.GenericAnnotations> annotations)
          Output all the Localization Quality issue annotation groups in a given list.
 java.lang.String writeStandoffProvenance(java.util.List<net.sf.okapi.common.annotation.GenericAnnotations> annotations)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STANDOFFMARKER

public static final java.lang.String STANDOFFMARKER
Marker used in a skeleton part to indicate where standoff markup can be inserted when merging.

See Also:
Constant Field Values

REF_PREFIX

public static final java.lang.String REF_PREFIX
See Also:
Constant Field Values
Constructor Detail

ITSContent

public ITSContent(java.nio.charset.CharsetEncoder encoder,
                  boolean isHTML5,
                  boolean isXLIFF)
Creates an ITSContent object with a given character set encoder.

Parameters:
encoder - the character set encoder to use (can be null for UTF-8)
isHTML5 - true to generate markup for HTML5, false for XML.
isXLIFF - true if the XML output is XLIFF, false for generic ITS. This parameter is ignored if isHTML5
Method Detail

isExtendedMatch

public static boolean isExtendedMatch(java.lang.String langRanges,
                                      java.lang.String langTag)
Indicates if a given language tag matches at least one item of a list of extended language ranges.

Based on the algorithm described at: http://tools.ietf.org/html/rfc4647#section-3.3.2

Parameters:
langRanges - the list of extended language ranges (with optional '!' prefix for 'exclude')
langTag - the language tag.
Returns:
true if the language tag results in inclusion, false if it results in exclusion.

writeStandoffLQI

public java.lang.String writeStandoffLQI()
Output the standoff markup for this object and clear it afterward. This is the same as calling this.writeStandoffLQI(this.getStandoff()); then this.clearStandoff()

Returns:
the generated output.

writeStandoffLQI

public java.lang.String writeStandoffLQI(java.util.List<net.sf.okapi.common.annotation.GenericAnnotations> annotations)
Output all the Localization Quality issue annotation groups in a given list. The given standoff items are not cleared automatically.

Parameters:
annotations - the list of annotation set to process.
Returns:
the generated output.

writeAttributesLQI

public java.lang.String writeAttributesLQI(net.sf.okapi.common.annotation.GenericAnnotation ann)
Writes the data attributes for a given LQI annotation (not locQualityIssuesRef).

Parameters:
ann - the annotation to output.
Returns:
a string with the written attributes.

writeStandoffProvenance

public java.lang.String writeStandoffProvenance(java.util.List<net.sf.okapi.common.annotation.GenericAnnotations> annotations)

writeAttributeProvenance

public java.lang.String writeAttributeProvenance(net.sf.okapi.common.annotation.GenericAnnotation ann)

outputAnnotations

public void outputAnnotations(net.sf.okapi.common.annotation.GenericAnnotations anns,
                              java.lang.StringBuilder output,
                              boolean inline,
                              boolean mrk,
                              net.sf.okapi.common.LocaleId trgLocId)
Generates the markup for the ITS attributes for a given annotation set.

Parameters:
anns - the annotations set (can be null).
output - the buffer where to append the output.
inline - true if the element is an inline element.
mrk - true if the element is an XLIFF mrk element.
trgLocId - target locale (can be null). This is use with mrk and Locale Filter.

getStandoff

public java.util.List<net.sf.okapi.common.annotation.GenericAnnotations> getStandoff()
Gets the current standoff markup.

Returns:
the current standoff markup (can be null)

hasStandoff

public boolean hasStandoff()
Indicates if this object has at least standoff item.

Returns:
true if this object has at least standoff item, false otherwise.

clearStandoff

public void clearStandoff()
Clears the standoff markup.