Package org.fxmisc.richtext.model
Class SegmentOpsBase<SEG,S>
- java.lang.Object
-
- org.fxmisc.richtext.model.SegmentOpsBase<SEG,S>
-
- Type Parameters:
SEG- the type of segmentS- the type of style
- All Implemented Interfaces:
SegmentOps<SEG,S>
- Direct Known Subclasses:
NodeSegmentOpsBase,TextOpsBase
public abstract class SegmentOpsBase<SEG,S> extends Object implements SegmentOps<SEG,S>
Provides a base for properly implementing theSegmentOpsinterface and reduces boilerplate, so that a developer only needs to implement methods for real segments, not empty ones. Optionally,SegmentOps.joinSeg(Object, Object)andjoinStyle(Object, Object)can be overridden as well.
-
-
Constructor Summary
Constructors Constructor Description SegmentOpsBase(SEG emptySeg)Creates aSegmentOpsBasethat returnsemptySegevery time an empty segment should be returned
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description charcharAt(SEG seg, int index)SEGcreateEmptySeg()Creates an empty segment.StringgetText(SEG seg)Optional<S>joinStyle(S currentStyle, S nextStyle)Joins two consecutive styles together into one orOptional.empty()if they cannot be joined.abstract charrealCharAt(SEG seg, int index)abstract StringrealGetText(SEG seg)SEGrealSubSequence(SEG seg, int start)abstract SEGrealSubSequence(SEG seg, int start, int end)SEGsubSequence(SEG seg, int start)SEGsubSequence(SEG seg, int start, int end)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.fxmisc.richtext.model.SegmentOps
joinSeg, length, or, orStyled
-
-
-
-
Constructor Detail
-
SegmentOpsBase
public SegmentOpsBase(SEG emptySeg)
Creates aSegmentOpsBasethat returnsemptySegevery time an empty segment should be returned
-
-
Method Detail
-
charAt
public final char charAt(SEG seg, int index)
- Specified by:
charAtin interfaceSegmentOps<SEG,S>
-
realCharAt
public abstract char realCharAt(SEG seg, int index)
-
subSequence
public final SEG subSequence(SEG seg, int start, int end)
- Specified by:
subSequencein interfaceSegmentOps<SEG,S>
-
subSequence
public final SEG subSequence(SEG seg, int start)
- Specified by:
subSequencein interfaceSegmentOps<SEG,S>
-
createEmptySeg
public final SEG createEmptySeg()
Description copied from interface:SegmentOpsCreates an empty segment. This method should return the same object for better performance and memory usage.- Specified by:
createEmptySegin interfaceSegmentOps<SEG,S>
-
joinStyle
public Optional<S> joinStyle(S currentStyle, S nextStyle)
Description copied from interface:SegmentOpsJoins two consecutive styles together into one orOptional.empty()if they cannot be joined. By default, returnsOptional.empty().- Specified by:
joinStylein interfaceSegmentOps<SEG,S>
-
-