1 21 package au.id.jericho.lib.html; 22 23 import java.io.*; 24 25 33 public final class StringOutputSegment implements OutputSegment { 34 private int begin; 35 private int end; 36 private CharSequence text; 37 38 48 public StringOutputSegment(final int begin, final int end, final CharSequence text) { 49 this.begin=begin; 50 this.end=end; 51 this.text=(text==null ? "" : text); 52 } 53 54 63 public StringOutputSegment(final Segment segment, final CharSequence text) { 64 this(segment.begin,segment.end,text); 65 } 66 67 public int getBegin() { 68 return begin; 69 } 70 71 public int getEnd() { 72 return end; 73 } 74 75 public void writeTo(final Writer writer) throws IOException { 76 Util.appendTo(writer,text); 77 } 78 79 public long getEstimatedMaximumOutputLength() { 80 return text.length(); 81 } 82 83 public String toString() { 84 return text.toString(); 85 } 86 87 public String getDebugInfo() { 88 return "("+begin+','+end+"):\""+text+'"'; 89 } 90 91 public void output(final Writer writer) throws IOException { 92 writeTo(writer); 93 } 94 } 95 | Popular Tags |