net.sf.okapi.lib.xliff2.its

## Class ITSWriter

- java.lang.Object
- - net.sf.okapi.lib.xliff2.its.ITSWriter

-     public class ITSWriter
      extends java.lang.Object

  Provides utility methods to output ITS attributes and stand-off elements. This assumes the ITS namespace uses "its" as its prefix.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ITSWriter()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `addDeclaration(StartXliffData sxd)` Adds the namespaces and version information for supporting ITS mapping in an XLIFF 2 document.
    `static IITSItem` | `annotate(Fragment fragment, int start, int end, IITSItem item)` Annotates a given fragment with an ITS item.
    `static MTag` | `annotate(Fragment fragment, int start, int end, IITSItem item, java.lang.String matchingType)` Tries to reuse an existing annotation to add an ITS item.
    `AnnotatorsRef` | `createAnnotatorsRef(IWithITSAttributes object)`
    `java.util.List<java.util.AbstractMap.SimpleEntry<java.lang.String,AnnotatorsRef>>` | `createAnnotatorsRefList(java.util.Stack<InheritedData> context)`
    `java.lang.String` | `outputAttributes(IWithITSAttributes object, AnnotatorsRef objectAR, AnnotatorsRef parentAR)`
    `java.lang.String` | `outputStandOffElements(java.lang.String indent, java.lang.String lb, Unit unit)` Outputs any stand-off elements used in the markers for the given unit.

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

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

- - ### Constructor Detail

    - #### ITSWriter

          public ITSWriter()

  - ### Method Detail

    - #### annotate

          public static IITSItem annotate(Fragment fragment,
                          int start,
                          int end,
                          IITSItem item)

      Annotates a given fragment with an ITS item.
      Parameters:
        `fragment` - the fragment to annotate.
        `start` - the start position (in the coded text)
        `end` - the position just after the last character of the span (in the coded text). You can use -1 to indicate the end of the fragment.
        `item` - the ITS item to set (it can be a single instance or a group).
      Returns:
        the ITS item set.

    - #### annotate

          public static MTag annotate(Fragment fragment,
                      int start,
                      int end,
                      IITSItem item,
                      java.lang.String matchingType)

      Tries to reuse an existing annotation to add an ITS item. If no existing annotation is found for the given span and type, one is created.
      Parameters:
        `fragment` - the fragment to annotate.
        `start` - the start position (in the coded text)
        `end` - the position just after the last character of the span (in the coded text). You can use -1 to indicate the end of the fragment.
        `item` - the ITS item to set (it can be a single instance or a group).
        `matchingType` - the type of the existing annotation that can be reused. Use null to reuse any type.
      Returns:
        the opening marker for the annotation.

    - #### addDeclaration

          public static void addDeclaration(StartXliffData sxd)

      Adds the namespaces and version information for supporting ITS mapping in an XLIFF 2 document.
      Parameters:
        `sxd` - the `StartXliffData` object where to add the mapping.

    - #### outputStandOffElements

          public java.lang.String outputStandOffElements(java.lang.String indent,
                                                java.lang.String lb,
                                                Unit unit)

      Outputs any stand-off elements used in the markers for the given unit.
      Parameters:
        `indent` - the base indentation to use.
        `lb` - the line-break to use.
        `unit` - the unit to process.
      Returns:
        the formatted output of the stand-off elements or an empty string if there is no element to output.

    - #### createAnnotatorsRefList

          public java.util.List<java.util.AbstractMap.SimpleEntry<java.lang.String,AnnotatorsRef>> createAnnotatorsRefList(java.util.Stack<InheritedData> context)

    - #### createAnnotatorsRef

          public AnnotatorsRef createAnnotatorsRef(IWithITSAttributes object)

    - #### outputAttributes

          public java.lang.String outputAttributes(IWithITSAttributes object,
                                          AnnotatorsRef objectAR,
                                          AnnotatorsRef parentAR)