01: /*
02: * LineSegment.java
03: *
04: * Copyright (C) 1998-2004 Peter Graves
05: * $Id: LineSegment.java,v 1.4 2004/04/02 03:31:05 piso Exp $
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License
09: * as published by the Free Software Foundation; either version 2
10: * of the License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with this program; if not, write to the Free Software
19: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20: */
21:
22: package org.armedbear.j;
23:
24: public class LineSegment {
25: private String text;
26: private int begin;
27: private int end;
28: private int format;
29:
30: public LineSegment(String text, int format) {
31: this .text = text;
32: begin = 0;
33: end = text.length();
34: this .format = format;
35: }
36:
37: public LineSegment(String text, int begin, int end, int format) {
38: this .text = text;
39: this .begin = begin;
40: this .end = end;
41: this .format = format;
42: }
43:
44: public final String getText() {
45: return text.substring(begin, end);
46: }
47:
48: public final int getFormat() {
49: return format;
50: }
51:
52: public final void setFormat(int format) {
53: this .format = format;
54: }
55:
56: public final int length() {
57: return end - begin;
58: }
59:
60: public final void getChars(int srcBegin, int srcEnd, char[] dst,
61: int dstBegin) {
62: text.getChars(begin + srcBegin, begin + srcEnd, dst, dstBegin);
63: }
64:
65: public final String substring(int beginIndex) {
66: return text.substring(begin + beginIndex, end);
67: }
68: }
|