Class CharAssociation

java.lang.Object
org.apache.fop.complexscripts.util.CharAssociation
All Implemented Interfaces:
Cloneable

public class CharAssociation extends Object implements 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 Details

    • 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 Details

    • 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(String key, Object value)
      Set predication <KEY,VALUE>.
      Parameters:
      key - predication key
      value - predication value
    • getPredication

      public Object getPredication(String key)
      Get predication KEY.
      Parameters:
      key - predication key
      Returns:
      predication KEY at OFFSET or null if none exists
    • mergePredication

      public void mergePredication(String key, Object value)
      Merge predication <KEY,VALUE>.
      Parameters:
      key - predication key
      value - predication value
    • mergePredicationValues

      public static Object mergePredicationValues(String key, Object v1, 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 Object clone()
      Overrides:
      clone in class Object
    • setPredicationMerger

      public static void setPredicationMerger(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(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 String toString()
      Overrides:
      toString in class Object