net.sf.okapi.common

## Class RenumberingUtil

- java.lang.Object
- - net.sf.okapi.common.RenumberingUtil

-     public class RenumberingUtil
      extends java.lang.Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RenumberingUtil()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `calculateCodeOffset(TextFragment tf)` Find the minimum ID of any code in the TextFragment, then use that to calculate the offset/delta by which all code IDs in the TextFragment need to be adjusted.
    `static boolean` | `containsOnlyMatchingCodes(TextFragment tf)` Check to see if this text fragment contains either open or closed tags that do not have a corresponding paired tag within the same TextFragment.
    `static void` | `renumberCodesForDesegmentation(TextContainer tc)` Reverse the renumbering process that was performed during segmetnation.
    `static void` | `renumberCodesForSegmentation(TextContainer tc)` Renumber the codes in a TextContainer for segmentation.
    `static void` | `renumberTextUnitCodes(ITextUnit tu, LocaleId trgLocale)` Renumber the codes in the TextUnit's source and target containers, this will renumber the code IDs in each TextFragment to begin at 1.

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

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

- - ### Constructor Detail

    - #### RenumberingUtil

          public RenumberingUtil()

  - ### Method Detail

    - #### renumberCodesForSegmentation

          public static void renumberCodesForSegmentation(TextContainer tc)

      Renumber the codes in a TextContainer for segmentation. As much as possible, this will renumber the code IDs in each TextFragment to begin at 1. In cases where a tag pair is split across one or more TextFragments, this is not possible. In this case, these "runs" of connected TextFragments will be treated as a single logical ID-space and collectively renumbered to start at 1.
      Note that this can cause problems when code IDs are not consecutive or non-numeric.
      Parameters:
        `tc` - TextContainer to renumber

    - #### renumberTextUnitCodes

          public static void renumberTextUnitCodes(ITextUnit tu,
                                   LocaleId trgLocale)

      Renumber the codes in the TextUnit's source and target containers, this will renumber the code IDs in each TextFragment to begin at 1.
      Parameters:
        `tu` - `ITextUnit` to renumber

    - #### calculateCodeOffset

          public static int calculateCodeOffset(TextFragment tf)

      Find the minimum ID of any code in the TextFragment, then use that to calculate the offset/delta by which all code IDs in the TextFragment need to be adjusted.
      Parameters:
        `tf` - TextFragment to examine
      Returns:
        code ID offset for the TextFragment, which is one less than the minimum code ID

    - #### containsOnlyMatchingCodes

          public static boolean containsOnlyMatchingCodes(TextFragment tf)

      Check to see if this text fragment contains either open or closed tags that do not have a corresponding paired tag within the same TextFragment.
      Parameters:
        `tc` -
      Returns:
        true if unmatched/unpaired codes are present

    - #### renumberCodesForDesegmentation

          public static void renumberCodesForDesegmentation(TextContainer tc)

      Reverse the renumbering process that was performed during segmetnation.
      Parameters:
        `tc` -