Class SegmentsImpl

java.lang.Object
com.ibm.icu.segmenter.SegmentsImpl
All Implemented Interfaces:
Segments

class SegmentsImpl extends Object implements Segments
  • Field Details

  • Constructor Details

  • Method Details

    • segmentAt

      public Segment segmentAt(int i)
      Description copied from interface: Segments
      Returns the segment that contains index i. Containment is inclusive of the start index and exclusive of the limit index.

      Specifically, the containing segment is defined as the segment with start s and limit l such that s ≤ i < l.

      Specified by:
      segmentAt in interface Segments
      Parameters:
      i - index in the input CharSequence to the Segmenter
      Returns:
      A segment that either starts at or contains index i
    • isBoundary

      public boolean isBoundary(int i)
      Description copied from interface: Segments
      Returns whether offset i is a segmentation boundary. Throws an exception when i is not a valid index position for the source sequence.
      Specified by:
      isBoundary in interface Segments
      Parameters:
      i - index in the input CharSequence to the Segmenter
      Returns:
      Returns whether offset i is a segmentation boundary.
    • segmentsFrom

      public Stream<Segment> segmentsFrom(int i)
      Description copied from interface: Segments
      Returns a Stream of all Segments in the source sequence where all segment limits l satisfy i < l. Iteration moves forwards.

      This means that the first segment in the stream is the same as what is returned by segmentAt(i).

      The word "from" is used here to mean "at or after", with the semantics of "at" for a Segment defined by Segments.segmentAt(int)}. We cannot describe the segments all as being "after" since the first segment might contain i in the middle, meaning that in the forward direction, its start position precedes i.

      segmentsFrom and Segments.segmentsBefore(int) create a partitioning of the space of all Segments.

      Specified by:
      segmentsFrom in interface Segments
      Parameters:
      i - index in the input CharSequence to the Segmenter
      Returns:
      a Stream of all Segments at or after i
    • segmentsBefore

      public Stream<Segment> segmentsBefore(int i)
      Description copied from interface: Segments
      Returns a Stream of all Segments in the source sequence where all segment limits l satisfy l ≤ i. Iteration moves backwards.

      This means that the all segments in the stream come before the one that is returned by segmentAt(i). A segment is not considered to contain index i if {code i} is equal to limit l. Thus, "before" encapsulates the invariant l ≤ i.

      Specified by:
      segmentsBefore in interface Segments
      Parameters:
      i - index in the input CharSequence to the Segmenter
      Returns:
      a Stream of all Segments before i
    • boundariesAfter

      public IntStream boundariesAfter(int i)
      Description copied from interface: Segments
      Returns all segmentation boundaries after the provided index. Iteration moves forwards.
      Specified by:
      boundariesAfter in interface Segments
      Parameters:
      i - index in the input CharSequence to the Segmenter
      Returns:
      An IntStream of all boundaries b such that b > i
    • boundariesBackFrom

      public IntStream boundariesBackFrom(int i)
      Description copied from interface: Segments
      Returns all segmentation boundaries on or before the provided index. Iteration moves backwards.

      The phrase "back from" is used to indicate both that: 1) boundaries are "on or before" the input index; 2) the direction of iteration is backwards (towards the beginning). "on or before" indicates that the result set is b where b ≤ i, which is a weak inequality, while "before" might suggest the strict inequality b < i.

      boundariesBackFrom and Segments.boundariesAfter(int) create a partitioning of the space of all boundaries.

      Specified by:
      boundariesBackFrom in interface Segments
      Parameters:
      i - index in the input CharSequence to the Segmenter
      Returns:
      An IntStream of all boundaries b such that b ≤ i