1 21 22 package org.armedbear.j; 23 24 public class LineSegment 25 { 26 private String text; 27 private int begin; 28 private int end; 29 private int format; 30 31 public LineSegment(String text, int format) 32 { 33 this.text = text; 34 begin = 0; 35 end = text.length(); 36 this.format = format; 37 } 38 39 public LineSegment(String text, int begin, int end, int format) 40 { 41 this.text = text; 42 this.begin = begin; 43 this.end = end; 44 this.format = format; 45 } 46 47 public final String getText() 48 { 49 return text.substring(begin, end); 50 } 51 52 public final int getFormat() 53 { 54 return format; 55 } 56 57 public final void setFormat(int format) 58 { 59 this.format = format; 60 } 61 62 public final int length() 63 { 64 return end - begin; 65 } 66 67 public final void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) 68 { 69 text.getChars(begin + srcBegin, begin + srcEnd, dst, dstBegin); 70 } 71 72 public final String substring(int beginIndex) 73 { 74 return text.substring(begin + beginIndex, end); 75 } 76 } 77 | Popular Tags |