org.apache.fop.complexscripts.util

## Class CharAssociation

- java.lang.Object
- - org.apache.fop.complexscripts.util.CharAssociation

- All Implemented Interfaces:
    java.lang.Cloneable

      public class CharAssociation
      extends java.lang.Object
      implements java.lang.Cloneable

  A structure class encapsulating an interval of characters expressed as an offset and count of Unicode scalar values (in an IntBuffer). A `CharAssociation` is used to maintain a backpointer from a glyph to one or more character intervals from which the glyph was derived. Each glyph in a glyph sequence is associated with a single `CharAssociation` instance. A `CharAssociation` instance is additionally (and optionally) used to record predication information about the glyph, such as whether the glyph was produced by the application of a specific substitution table or whether its position was adjusted by a specific poisitioning table.

  This work was originally authored by Glenn Adams (gadams@apache.org).

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CharAssociation(int[] subIntervals)` Instantiate a non-disjoint character association.
    `CharAssociation(int offset, int count)` Instantiate a non-disjoint character association.
    `CharAssociation(int offset, int count, int[] subIntervals)` Instantiate a character association.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Object` | `clone()`
    `boolean` | `contained(int offset, int count)`
    `int` | `getCount()`
    `int` | `getEnd()`
    `int` | `getOffset()`
    `java.lang.Object` | `getPredication(java.lang.String key)` Get predication KEY.
    `static org.apache.fop.complexscripts.util.CharAssociation.PredicationMerger` | `getPredicationMerger(java.lang.String key)` Obtain predication merger for KEY.
    `int` | `getStart()`
    `int` | `getSubIntervalCount()`
    `int[]` | `getSubIntervals()`
    `boolean` | `isDisjoint()`
    `static CharAssociation` | `join(CharAssociation[] aa)` Join (merge) multiple associations into a single, potentially disjoint association.
    `void` | `mergePredication(java.lang.String key, java.lang.Object value)` Merge predication <KEY,VALUE>.
    `void` | `mergePredications(CharAssociation ca)` Merge predications from another CA.
    `static java.lang.Object` | `mergePredicationValues(java.lang.String key, java.lang.Object v1, java.lang.Object v2)` Merge predication values V1 and V2 on KEY.
    `static CharAssociation[]` | `replicate(CharAssociation a, int repeat)` Replicate association to form `repeat` new associations.
    `void` | `setPredication(java.lang.String key, java.lang.Object value)` Set predication <KEY,VALUE>.
    `static void` | `setPredicationMerger(java.lang.String key, org.apache.fop.complexscripts.util.CharAssociation.PredicationMerger pm)` Register predication merger PM for KEY.
    `java.lang.String` | `toString()`

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

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

- - ### Constructor Detail

    - #### CharAssociation

          public CharAssociation(int offset,
                                 int count,
                                 int[] subIntervals)

      Instantiate a character association.
      Parameters:
        `offset` - into array of Unicode scalar values (in associated IntBuffer)
        `count` - of Unicode scalar values (in associated IntBuffer)
        `subIntervals` - if disjoint, then array of sub-intervals, otherwise null; even members of array are sub-interval starts, and odd members are sub-interval ends (exclusive)

    - #### CharAssociation

          public CharAssociation(int offset,
                                 int count)

      Instantiate a non-disjoint character association.
      Parameters:
        `offset` - into array of UTF-16 code elements (in associated CharSequence)
        `count` - of UTF-16 character code elements (in associated CharSequence)

    - #### CharAssociation

          public CharAssociation(int[] subIntervals)

      Instantiate a non-disjoint character association.
      Parameters:
        `subIntervals` - if disjoint, then array of sub-intervals, otherwise null; even members of array are sub-interval starts, and odd members are sub-interval ends (exclusive)

  - ### Method Detail

    - #### getOffset

          public int getOffset()

      Returns:
        offset (start of association interval)

    - #### getCount

          public int getCount()

      Returns:
        count (number of characer codes in association)

    - #### getStart

          public int getStart()

      Returns:
        start of association interval

    - #### getEnd

          public int getEnd()

      Returns:
        end of association interval

    - #### isDisjoint

          public boolean isDisjoint()

      Returns:
        true if association is disjoint

    - #### getSubIntervals

          public int[] getSubIntervals()

      Returns:
        subintervals of disjoint association

    - #### getSubIntervalCount

          public int getSubIntervalCount()

      Returns:
        count of subintervals of disjoint association

    - #### contained

          public boolean contained(int offset,
                                   int count)

      Parameters:
        `offset` - of interval in sequence
        `count` - length of interval
      Returns:
        true if this association is contained within [offset,offset+count)

    - #### setPredication

          public void setPredication(java.lang.String key,
                                     java.lang.Object value)

      Set predication <KEY,VALUE>.
      Parameters:
        `key` - predication key
        `value` - predication value

    - #### getPredication

          public java.lang.Object getPredication(java.lang.String key)

      Get predication KEY.
      Parameters:
        `key` - predication key
      Returns:
        predication KEY at OFFSET or null if none exists

    - #### mergePredication

          public void mergePredication(java.lang.String key,
                                       java.lang.Object value)

      Merge predication <KEY,VALUE>.
      Parameters:
        `key` - predication key
        `value` - predication value

    - #### mergePredicationValues

          public static java.lang.Object mergePredicationValues(java.lang.String key,
                                                                java.lang.Object v1,
                                                                java.lang.Object v2)

      Merge predication values V1 and V2 on KEY. Uses registered `PredicationMerger` if one exists, otherwise uses V2 if non-null, otherwise uses V1.
      Parameters:
        `key` - predication key
        `v1` - first (original) predication value
        `v2` - second (to be merged) predication value
      Returns:
        merged value

    - #### mergePredications

          public void mergePredications(CharAssociation ca)

      Merge predications from another CA.
      Parameters:
        `ca` - from which to merge

    - #### clone

          public java.lang.Object clone()

      Overrides:
        `clone` in class `java.lang.Object`

    - #### setPredicationMerger

          public static void setPredicationMerger(java.lang.String key,
                                                  org.apache.fop.complexscripts.util.CharAssociation.PredicationMerger pm)

      Register predication merger PM for KEY.
      Parameters:
        `key` - for predication merger
        `pm` - predication merger

    - #### getPredicationMerger

          public static org.apache.fop.complexscripts.util.CharAssociation.PredicationMerger getPredicationMerger(java.lang.String key)

      Obtain predication merger for KEY.
      Parameters:
        `key` - for predication merger
      Returns:
        predication merger or null if none exists

    - #### replicate

          public static CharAssociation[] replicate(CharAssociation a,
                                                    int repeat)

      Replicate association to form `repeat` new associations.
      Parameters:
        `a` - association to replicate
        `repeat` - count
      Returns:
        array of replicated associations

    - #### join

          public static CharAssociation join(CharAssociation[] aa)

      Join (merge) multiple associations into a single, potentially disjoint association.
      Parameters:
        `aa` - array of associations to join
      Returns:
        (possibly disjoint) association containing joined associations

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

Copyright 1999-2022 The Apache Software Foundation. All Rights Reserved.