net.sf.okapi.common.filterwriter

## Class ITSContent

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

-     public class ITSContent
      extends java.lang.Object

  Utilities for writing out ITS markup.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `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

    Constructors
    Constructor and Description
    `ITSContent(java.nio.charset.CharsetEncoder encoder, boolean isHTML5, boolean isXLIFF)` Creates an ITSContent object with a given character set encoder.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.util.Map<java.lang.String,java.lang.String>` | `annotatorsRefToMap(java.lang.String data)` Extract a map of the ITS annotatorsRef value in its string format.
    `void` | `clearStandoff()` Clears the standoff markup.
    `static java.lang.String` | `getAnnotatorRef(java.lang.String dataCategory, INameable nameable)` Gets the ITS annotator reference for a given data category on a given object.
    `static java.lang.String` | `getAnnotatorRef(java.lang.String dataCategory, java.lang.String pairs)` Gets the ITS annotator reference for a given data category from a given annotators list.
    `static java.lang.String` | `getAnnotatorsRef(IWithAnnotations nameable)` Gets the value of the ITS AnnotatorsRef information if it is present.
    `java.nio.charset.CharsetEncoder` | `getEncoder()`
    `java.util.List<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.
    `boolean` | `isHTML5()`
    `boolean` | `isXLIFF()`
    `static java.lang.String` | `mapToAnnotatorsRef(java.util.Map<java.lang.String,java.lang.String> map)` Creates an ITS annotatorsRef value in a string form from a map.
    `void` | `outputAnnotations(GenericAnnotations anns, java.lang.StringBuilder output, boolean inline, boolean mrk, boolean mtypeNeeded, LocaleId trgLocId)` Generates the markup for the ITS attributes for a given annotation set.
    `static java.lang.String` | `updateAnnotatorsRef(java.lang.String oldValues, java.lang.String newValues)` Updates a set of annotator references with new values.
    `java.lang.String` | `writeAttributeProvenance(GenericAnnotation ann)`
    `java.lang.String` | `writeAttributesLQI(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<GenericAnnotations> annotations)` Output all the Localization Quality issue annotation groups in a given list.
    `java.lang.String` | `writeStandoffProvenance(java.util.List<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` is true.

  - ### 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.

    - #### annotatorsRefToMap

          public static java.util.Map<java.lang.String,java.lang.String> annotatorsRefToMap(java.lang.String data)

      Extract a map of the ITS annotatorsRef value in its string format.
      Parameters:
        `data` - the string with the annotatorsRef value to process (can be null).
      Returns:
        a map with the keys being the data category names and the values each corresponding annotator's URI. (Can be empty but never returns null).
      See Also:
        `mapToAnnotatorsRef(Map)`

    - #### mapToAnnotatorsRef

          public static java.lang.String mapToAnnotatorsRef(java.util.Map<java.lang.String,java.lang.String> map)

      Creates an ITS annotatorsRef value in a string form from a map.
      Parameters:
        `map` - the map holding the key/values pairs.
      Returns:
        A string in the ITS annotatorsRef format.
      See Also:
        `annotatorsRefToMap(String)`

    - #### getAnnotatorsRef

          public static java.lang.String getAnnotatorsRef(IWithAnnotations nameable)

      Gets the value of the ITS AnnotatorsRef information if it is present. That value is a list of annotators references.
      Parameters:
        `nameable` - the object to query.
      Returns:
        the annotatorsRef value for the given object or null if it's not present.
      See Also:
        `getAnnotatorRef(String, INameable)`

    - #### getAnnotatorRef

          public static java.lang.String getAnnotatorRef(java.lang.String dataCategory,
                                                         INameable nameable)

      Gets the ITS annotator reference for a given data category on a given object.
      Parameters:
        `dataCategory` - the data category identifier.
        `nameable` - the nameable object where to look for the annotator.
      Returns:
        the value of the annotator reference for the given data category, or null if there is none declared.
      See Also:
        `getAnnotatorsRef(IWithAnnotations)`, `getAnnotatorRef(String, String)`

    - #### getAnnotatorRef

          public static java.lang.String getAnnotatorRef(java.lang.String dataCategory,
                                                         java.lang.String pairs)

      Gets the ITS annotator reference for a given data category from a given annotators list.
      Parameters:
        `dataCategory` - the data category identifier.
        `pairs` - the list of annotator reference pairs to look up.
      Returns:
        the value of the annotator reference for the given data category, or null if there is none declared.
      See Also:
        `getAnnotatorRef(String, INameable)`

    - #### updateAnnotatorsRef

          public static java.lang.String updateAnnotatorsRef(java.lang.String oldValues,
                                                             java.lang.String newValues)

      Updates a set of annotator references with new values.
      Parameters:
        `oldValues` - the set of old values (can be null).
        `newValues` - the set of new values (can be null).
      Returns:
        the updated new set of values. If the given set of new values is null, the values returned are the old ones.

    - #### 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<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(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<GenericAnnotations> annotations)

    - #### writeAttributeProvenance

          public java.lang.String writeAttributeProvenance(GenericAnnotation ann)

    - #### outputAnnotations

          public void outputAnnotations(GenericAnnotations anns,
                                        java.lang.StringBuilder output,
                                        boolean inline,
                                        boolean mrk,
                                        boolean mtypeNeeded,
                                        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.
        `mtypeNeeded` - true if the mtype attribute should be output (if needed), false to not output it.
        `trgLocId` - target locale (can be null). This is use with mrk and Locale Filter.

    - #### getStandoff

          public java.util.List<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.

    - #### getEncoder

          public java.nio.charset.CharsetEncoder getEncoder()

    - #### isHTML5

          public boolean isHTML5()

    - #### isXLIFF

          public boolean isXLIFF()