Package net.htmlparser.jericho
Interface OutputSegment
-
- All Superinterfaces:
CharStreamSource
public interface OutputSegment extends CharStreamSource
Defines the interface for an output segment, which is used in anOutputDocument
to replace segments of the source document with other text.All text in the
OutputDocument
between the character positions defined bygetBegin()
andgetEnd()
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:
OutputDocument.register(OutputSegment)
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.Comparator<OutputSegment>
COMPARATOR
The comparator used to sort output segments in theOutputDocument
before output.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
appendTo(java.lang.Appendable appendable)
Appends the content of this output segment to the specifiedAppendable
object.int
getBegin()
Returns the character position in the source text of the output document where this segment begins.java.lang.String
getDebugInfo()
Returns a string representation of this object useful for debugging purposes.int
getEnd()
Returns the character position in the source text of the output document where this segment ends.java.lang.String
toString()
Returns the content of this output segment as aString
.void
writeTo(java.io.Writer writer)
Writes the content of this output segment to the specifiedWriter
.-
Methods inherited from interface net.htmlparser.jericho.CharStreamSource
getEstimatedMaximumOutputLength
-
-
-
-
Field Detail
-
COMPARATOR
static final java.util.Comparator<OutputSegment> COMPARATOR
The comparator used to sort output segments in theOutputDocument
before 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
equals
method 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 Detail
-
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
void writeTo(java.io.Writer writer) throws java.io.IOException
Writes the content of this output segment to the specifiedWriter
.- Specified by:
writeTo
in interfaceCharStreamSource
- Parameters:
writer
- the destinationjava.io.Writer
for the output.- Throws:
java.io.IOException
- if an I/O exception occurs.
-
appendTo
void appendTo(java.lang.Appendable appendable) throws java.io.IOException
Appends the content of this output segment to the specifiedAppendable
object.- Specified by:
appendTo
in interfaceCharStreamSource
- Parameters:
appendable
- the destinationjava.lang.Appendable
object for the output.- Throws:
java.io.IOException
- if an I/O exception occurs.
-
toString
java.lang.String toString()
Returns the content of this output segment as aString
.- Specified by:
toString
in interfaceCharStreamSource
- Overrides:
toString
in classjava.lang.Object
- Returns:
- the content of this output segment as a
String
, guaranteed notnull
. - See Also:
writeTo(Writer)
-
getDebugInfo
java.lang.String getDebugInfo()
Returns a string representation of this object useful for debugging purposes.- Returns:
- a string representation of this object useful for debugging purposes.
-
-