Class SegmentsImpl
- All Implemented Interfaces:
Segments
-
Nested Class Summary
Nested classes/interfaces inherited from interface Segments
Segments.IterationDirection -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboundariesAfter(int i) Returns all segmentation boundaries after the provided index.boundariesBackFrom(int i) Returns all segmentation boundaries on or before the provided index.booleanisBoundary(int i) Returns whether offsetiis a segmentation boundary.segmentAt(int i) Returns the segment that contains indexi.segmentsBefore(int i) Returns aStreamof allSegments in the source sequence where all segment limitslsatisfyl ≤ i.segmentsFrom(int i) Returns aStreamof allSegments in the source sequence where all segment limitslsatisfyi < l.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Segments
boundaries, segments, subSequences
-
Field Details
-
source
-
breakIterPrototype
-
-
Constructor Details
-
SegmentsImpl
SegmentsImpl(BreakIterator breakIter, CharSequence source)
-
-
Method Details
-
segmentAt
Description copied from interface:SegmentsReturns the segment that contains indexi. Containment is inclusive of the start index and exclusive of the limit index.Specifically, the containing segment is defined as the segment with start
sand limitlsuch thats ≤ i < l. -
isBoundary
public boolean isBoundary(int i) Description copied from interface:SegmentsReturns whether offsetiis a segmentation boundary. Throws an exception wheniis not a valid index position for the source sequence.- Specified by:
isBoundaryin interfaceSegments- Parameters:
i- index in the inputCharSequenceto theSegmenter- Returns:
- Returns whether offset
iis a segmentation boundary.
-
segmentsFrom
Description copied from interface:SegmentsReturns aStreamof allSegments in the source sequence where all segment limitslsatisfyi < 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
Segmentdefined bySegments.segmentAt(int)}. We cannot describe the segments all as being "after" since the first segment might containiin the middle, meaning that in the forward direction, its start position precedesi.segmentsFromandSegments.segmentsBefore(int)create a partitioning of the space of allSegments.- Specified by:
segmentsFromin interfaceSegments- Parameters:
i- index in the inputCharSequenceto theSegmenter- Returns:
- a
Streamof allSegments at or afteri
-
segmentsBefore
Description copied from interface:SegmentsReturns aStreamof allSegments in the source sequence where all segment limitslsatisfyl ≤ 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 indexiif {code i} is equal to limitl. Thus, "before" encapsulates the invariantl ≤ i.- Specified by:
segmentsBeforein interfaceSegments- Parameters:
i- index in the inputCharSequenceto theSegmenter- Returns:
- a
Streamof allSegments beforei
-
boundariesAfter
Description copied from interface:SegmentsReturns all segmentation boundaries after the provided index. Iteration moves forwards.- Specified by:
boundariesAfterin interfaceSegments- Parameters:
i- index in the inputCharSequenceto theSegmenter- Returns:
- An
IntStreamof all boundariesbsuch thatb > i
-
boundariesBackFrom
Description copied from interface:SegmentsReturns 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
bwhereb ≤ i, which is a weak inequality, while "before" might suggest the strict inequalityb < i.boundariesBackFromandSegments.boundariesAfter(int)create a partitioning of the space of all boundaries.- Specified by:
boundariesBackFromin interfaceSegments- Parameters:
i- index in the inputCharSequenceto theSegmenter- Returns:
- An
IntStreamof all boundariesbsuch thatb ≤ i
-