Class ITSContent


  • public class ITSContent
    extends Object
    Utilities for writing out ITS markup.
    • Constructor Detail

      • ITSContent

        public ITSContent​(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​(String langRanges,
                                              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 Map<String,​String> annotatorsRefToMap​(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 String mapToAnnotatorsRef​(Map<String,​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 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 String getAnnotatorRef​(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 String getAnnotatorRef​(String dataCategory,
                                             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 String updateAnnotatorsRef​(String oldValues,
                                                 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 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 String writeStandoffLQI​(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 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.
      • outputAnnotations

        public void outputAnnotations​(GenericAnnotations anns,
                                      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 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.
      • isHTML5

        public boolean isHTML5()
      • isXLIFF

        public boolean isXLIFF()