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 theSegmentOps
interface 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 aSegmentOpsBase
that returnsemptySeg
every time an empty segment should be returned
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description char
charAt(SEG seg, int index)
SEG
createEmptySeg()
Creates an empty segment.String
getText(SEG seg)
Optional<S>
joinStyle(S currentStyle, S nextStyle)
Joins two consecutive styles together into one orOptional.empty()
if they cannot be joined.abstract char
realCharAt(SEG seg, int index)
abstract String
realGetText(SEG seg)
SEG
realSubSequence(SEG seg, int start)
abstract SEG
realSubSequence(SEG seg, int start, int end)
SEG
subSequence(SEG seg, int start)
SEG
subSequence(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 aSegmentOpsBase
that returnsemptySeg
every time an empty segment should be returned
-
-
Method Detail
-
charAt
public final char charAt(SEG seg, int index)
- Specified by:
charAt
in 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:
subSequence
in interfaceSegmentOps<SEG,S>
-
subSequence
public final SEG subSequence(SEG seg, int start)
- Specified by:
subSequence
in interfaceSegmentOps<SEG,S>
-
createEmptySeg
public final SEG createEmptySeg()
Description copied from interface:SegmentOps
Creates an empty segment. This method should return the same object for better performance and memory usage.- Specified by:
createEmptySeg
in interfaceSegmentOps<SEG,S>
-
joinStyle
public Optional<S> joinStyle(S currentStyle, S nextStyle)
Description copied from interface:SegmentOps
Joins two consecutive styles together into one orOptional.empty()
if they cannot be joined. By default, returnsOptional.empty()
.- Specified by:
joinStyle
in interfaceSegmentOps<SEG,S>
-
-