net.sf.okapi.common.resource

## Class TextFragmentUtil

- java.lang.Object
- - net.sf.okapi.common.resource.TextFragmentUtil

-     public final class TextFragmentUtil
      extends java.lang.Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `MAX_INLINE_CODES`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TextFragmentUtil()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static CodeAnomalies` | `catalogCodeAnomalies(TextFragment source, TextFragment target)` Store the missing, added or modified codes in the target as compared to the source.
    `static CodeAnomalies` | `catalogCodeAnomalies(TextFragment source, TextFragment target, boolean includeDeletable)` Store the missing oradded codes in the target as compared to the source.
    `static void` | `copyCodes(TextFragment source, TextFragment target, boolean simplified)` Update the `Code`'s in "target" to match those of "source".
    `static boolean` | `moreThanMaxCodes(TextFragment tf)`
    `static TextFragment` | `removeMoreThanMaxCodes(TextFragment tf)`
    `static java.lang.String` | `toText(TextFragment tf)` Render the `TextFragment` including all `Code`s.

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

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

- - ### Field Detail

    - #### MAX_INLINE_CODES

          public static final int MAX_INLINE_CODES

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### TextFragmentUtil

          public TextFragmentUtil()

  - ### Method Detail

    - #### catalogCodeAnomalies

          public static CodeAnomalies catalogCodeAnomalies(TextFragment source,
                                           TextFragment target)

      Store the missing, added or modified codes in the target as compared to the source.

      To assure consistent ids and code data run `TextFragment.alignCodeIds(TextFragment)` first.

      Parameters:
        `source` - - source `TextFragment`, use as the standard to compare against.
        `target` - - target `TextFragment` to compare codes with source.
      Returns:
        `CodeAnomalies` or null if no anomalies.

    - #### catalogCodeAnomalies

          public static CodeAnomalies catalogCodeAnomalies(TextFragment source,
                                           TextFragment target,
                                           boolean includeDeletable)

      Store the missing oradded codes in the target as compared to the source.

      To assure consistent ids and code data run `TextFragment.alignCodeIds(TextFragment)` first.

      Parameters:
        `source` - - source `TextFragment`, use as the standard to compare against.
        `target` - - target `TextFragment` to compare codes with source.
        `includeDeletable` - - do we count deletable codes as missing? True by default.
      Returns:
        `CodeAnomalies` or null if no anomalies.

    - #### moreThanMaxCodes

          public static boolean moreThanMaxCodes(TextFragment tf)

    - #### removeMoreThanMaxCodes

          public static TextFragment removeMoreThanMaxCodes(TextFragment tf)

    - #### toText

          public static java.lang.String toText(TextFragment tf)

      Render the `TextFragment` including all `Code`s. differs from TextFragment.toText() by also using outerData.
      Parameters:
        `tf` - The TextFragment to render
      Returns:
        the rendered string

    - #### copyCodes

          public static void copyCodes(TextFragment source,
                       TextFragment target,
                       boolean simplified)

      Update the `Code`'s in "target" to match those of "source". But only if the "target" code has empty data. Otherwise keep the target code data as-is. Codes match if both data and `TextFragment.TagType` are the same.
      Parameters:
        `source` - `TextFragment` codes are used to match codes in "to"
        `target` - `TextFragment` that has its code id's updated to match "from"
        `simplified` - not used(?)