Interface OutputSegment
- All Superinterfaces:
CharStreamSource
Defines the interface for an output segment, which is used in an
OutputDocument to
replace segments of the source document with other text.
All text in the OutputDocument between the character positions defined by getBegin() and getEnd()
is replaced by the content of this output segment.
If the begin and end character positions are the same, the content is simply
inserted at this position without replacing any text.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Comparator<OutputSegment> The comparator used to sort output segments in theOutputDocumentbefore output. -
Method Summary
Modifier and TypeMethodDescriptionvoidappendTo(Appendable appendable) Appends the content of this output segment to the specifiedAppendableobject.intgetBegin()Returns the character position in the source text of the output document where this segment begins.Returns a string representation of this object useful for debugging purposes.intgetEnd()Returns the character position in the source text of the output document where this segment ends.toString()Returns the content of this output segment as aString.voidWrites the content of this output segment to the specifiedWriter.Methods inherited from interface CharStreamSource
getEstimatedMaximumOutputLength
-
Field Details
-
COMPARATOR
The comparator used to sort output segments in theOutputDocumentbefore output.The following rules are applied in order compare two output segments:
- The output segment that begins earlier in the document comes first.
- If both output segments begin at the same position, the one that has zero length comes first. If neither or both have zero length then neither is guaranteed to come before the other.
Note: this comparator has a natural ordering that may be inconsistent with the
equalsmethod of classes implementing this interface. This means that the comparator may treat two output segments as equal where calling theequals(Object)method with the same two output segments returnsfalse.
-
-
Method Details
-
getBegin
int getBegin()Returns the character position in the source text of the output document where this segment begins.- Returns:
- the character position in the source text of the output document where this segment begins.
-
getEnd
int getEnd()Returns the character position in the source text of the output document where this segment ends.- Returns:
- the character position in the source text of the output document where this segment ends.
-
writeTo
Writes the content of this output segment to the specifiedWriter.- Specified by:
writeToin interfaceCharStreamSource- Parameters:
writer- the destinationjava.io.Writerfor the output.- Throws:
IOException- if an I/O exception occurs.
-
appendTo
Appends the content of this output segment to the specifiedAppendableobject.- Specified by:
appendToin interfaceCharStreamSource- Parameters:
appendable- the destinationjava.lang.Appendableobject for the output.- Throws:
IOException- if an I/O exception occurs.
-
toString
String toString()Returns the content of this output segment as aString.- Specified by:
toStringin interfaceCharStreamSource- Overrides:
toStringin classObject- Returns:
- the content of this output segment as a
String, guaranteed notnull. - See Also:
-
getDebugInfo
String getDebugInfo()Returns a string representation of this object useful for debugging purposes.- Returns:
- a string representation of this object useful for debugging purposes.
-