PS
- The type of the paragraph style.SEG
- The type of the segments in the paragraph (e.g. String
).S
- The type of the style of individual segments.public final class ReadOnlyStyledDocument<PS,SEG,S> extends java.lang.Object implements StyledDocument<PS,SEG,S>
StyledDocument
that does not allow editing. For a StyledDocument
that can be edited, see EditableStyledDocument
.TwoDimensional.Bias, TwoDimensional.Position
Modifier and Type | Method and Description |
---|---|
static <PS,SEG,S> Codec<StyledDocument<PS,SEG,S>> |
codec(Codec<PS> pCodec,
Codec<StyledSegment<SEG,S>> segCodec,
SegmentOps<SEG,S> segmentOps)
Defines a codec for serializing a
ReadOnlyStyledDocument . |
ReadOnlyStyledDocument<PS,SEG,S> |
concat(StyledDocument<PS,SEG,S> other) |
boolean |
equals(java.lang.Object other) |
static <PS,SEG,S> ReadOnlyStyledDocument<PS,SEG,S> |
from(StyledDocument<PS,SEG,S> doc)
Creates a
ReadOnlyStyledDocument from the given StyledDocument . |
static <PS,SEG,S> ReadOnlyStyledDocument<PS,SEG,S> |
fromSegment(SEG segment,
PS paragraphStyle,
S style,
SegmentOps<SEG,S> segmentOps)
Creates a
ReadOnlyStyledDocument from the given segment. |
static <PS,SEG,S> ReadOnlyStyledDocument<PS,SEG,S> |
fromString(java.lang.String str,
PS paragraphStyle,
S style,
TextOps<SEG,S> segmentOps)
Creates a
ReadOnlyStyledDocument from the given string. |
Paragraph<PS,SEG,S> |
getParagraph(int index) |
int |
getParagraphCount() |
java.util.List<Paragraph<PS,SEG,S>> |
getParagraphs() |
java.lang.String |
getText() |
int |
hashCode() |
int |
length() |
TwoDimensional.Position |
offsetToPosition(int offset,
TwoDimensional.Bias bias)
Creates a two dimensional position in some entity (e.g.
|
TwoDimensional.Position |
position(int major,
int minor)
Creates a two dimensional position in some entity (e.g.
|
Tuple3<ReadOnlyStyledDocument<PS,SEG,S>,RichTextChange<PS,SEG,S>,MaterializedListModification<Paragraph<PS,SEG,S>>> |
replace(int from,
int to,
ReadOnlyStyledDocument<PS,SEG,S> replacement)
Replaces the given portion
"from..to" with the given replacement and returns
1) the updated version of this document that includes the replacement,
2) the RichTextChange that represents the change from this document to the returned one, and
3) the modification used to update an area's list of visible paragraphs. |
Tuple2<ReadOnlyStyledDocument<PS,SEG,S>,ReadOnlyStyledDocument<PS,SEG,S>> |
split(int position)
Splits this document into two at the given position and returns both halves.
|
Tuple2<ReadOnlyStyledDocument<PS,SEG,S>,ReadOnlyStyledDocument<PS,SEG,S>> |
split(int paragraphIndex,
int columnPosition)
Splits this document into two at the given paragraph's column position and returns both halves.
|
StyledDocument<PS,SEG,S> |
subSequence(int start,
int end) |
java.lang.String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
charAt, getAbsolutePosition, getParagraphLength, getParagraphStyle, getParagraphStyleAtPosition, getStyleAtPosition, getStyleAtPosition, getStyleOfChar, getStyleOfChar, getStyleRangeAtPosition, getStyleRangeAtPosition, getStyleSpans, getStyleSpans, getStyleSpans, getText, getText, getText, subDocument, subSequence
public static <PS,SEG,S> ReadOnlyStyledDocument<PS,SEG,S> fromString(java.lang.String str, PS paragraphStyle, S style, TextOps<SEG,S> segmentOps)
ReadOnlyStyledDocument
from the given string.PS
- The type of the paragraph style.SEG
- The type of the segments in the paragraph (e.g. String
).S
- The type of the style of individual segments.str
- the text to use to create the segmentsparagraphStyle
- the paragraph style to use for each paragraph in the returned documentstyle
- the style to use for each segment in the documentsegmentOps
- the operations object that can create a segment froma given textpublic static <PS,SEG,S> ReadOnlyStyledDocument<PS,SEG,S> fromSegment(SEG segment, PS paragraphStyle, S style, SegmentOps<SEG,S> segmentOps)
ReadOnlyStyledDocument
from the given segment.PS
- The type of the paragraph style.SEG
- The type of the segments in the paragraph (e.g. String
).S
- The type of the style of individual segments.segment
- the only segment in the only paragraph in the documentparagraphStyle
- the paragraph style to use for each paragraph in the returned documentstyle
- the style to use for each segment in the documentsegmentOps
- the operations object that can create a segment froma given textpublic static <PS,SEG,S> ReadOnlyStyledDocument<PS,SEG,S> from(StyledDocument<PS,SEG,S> doc)
ReadOnlyStyledDocument
from the given StyledDocument
.PS
- The type of the paragraph style.SEG
- The type of the segments in the paragraph (e.g. String
).S
- The type of the style of individual segments.public static <PS,SEG,S> Codec<StyledDocument<PS,SEG,S>> codec(Codec<PS> pCodec, Codec<StyledSegment<SEG,S>> segCodec, SegmentOps<SEG,S> segmentOps)
ReadOnlyStyledDocument
.PS
- The type of the paragraph style.SEG
- The type of the segments in the paragraph (e.g. String
).S
- The type of the style of individual segments.pCodec
- the codec for serializing a Paragraph
segCodec
- the codec for serializing a StyledSegment
segmentOps
- the operations object for operating on segmentspublic int length()
length
in interface StyledDocument<PS,SEG,S>
public java.lang.String getText()
getText
in interface StyledDocument<PS,SEG,S>
public int getParagraphCount()
public Paragraph<PS,SEG,S> getParagraph(int index)
getParagraph
in interface StyledDocument<PS,SEG,S>
public java.util.List<Paragraph<PS,SEG,S>> getParagraphs()
getParagraphs
in interface StyledDocument<PS,SEG,S>
public TwoDimensional.Position position(int major, int minor)
TwoDimensional
major
value is the index within the outer list) and the minor
value is either the index within the inner list or some amount of length in a list of objects that have length.position
in interface TwoDimensional
public TwoDimensional.Position offsetToPosition(int offset, TwoDimensional.Bias bias)
TwoDimensional
offset
value is an absolute position in that entity.offsetToPosition
in interface TwoDimensional
public Tuple2<ReadOnlyStyledDocument<PS,SEG,S>,ReadOnlyStyledDocument<PS,SEG,S>> split(int position)
public Tuple2<ReadOnlyStyledDocument<PS,SEG,S>,ReadOnlyStyledDocument<PS,SEG,S>> split(int paragraphIndex, int columnPosition)
public ReadOnlyStyledDocument<PS,SEG,S> concat(StyledDocument<PS,SEG,S> other)
concat
in interface StyledDocument<PS,SEG,S>
public StyledDocument<PS,SEG,S> subSequence(int start, int end)
subSequence
in interface StyledDocument<PS,SEG,S>
public Tuple3<ReadOnlyStyledDocument<PS,SEG,S>,RichTextChange<PS,SEG,S>,MaterializedListModification<Paragraph<PS,SEG,S>>> replace(int from, int to, ReadOnlyStyledDocument<PS,SEG,S> replacement)
"from..to"
with the given replacement and returns
1) the updated version of this document that includes the replacement,
2) the RichTextChange
that represents the change from this document to the returned one, and
3) the modification used to update an area's list of visible paragraphs.public java.lang.String toString()
toString
in class java.lang.Object
public final boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public final int hashCode()
hashCode
in class java.lang.Object