Class ITSWriter


  • public class ITSWriter
    extends Object
    Provides utility methods to output ITS attributes and stand-off elements. This assumes the ITS namespace uses "its" as its prefix.
    • 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,
                                    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 String outputStandOffElements​(String indent,
                                             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.