114 |
*/ |
*/ |
115 |
public int getOffset() |
public int getOffset() |
116 |
{ |
{ |
117 |
if (mark <= gapStart) |
if (mark <= gapEnd) |
118 |
return mark; |
return mark; |
119 |
else |
else |
120 |
return mark - (gapEnd - gapStart); |
return mark - (gapEnd - gapStart); |
274 |
public String getString(int where, int len) throws BadLocationException |
public String getString(int where, int len) throws BadLocationException |
275 |
{ |
{ |
276 |
Segment seg = new Segment(); |
Segment seg = new Segment(); |
277 |
getChars(where, len, seg); |
try |
278 |
return new String(seg.array, seg.offset, seg.count); |
{ |
279 |
|
getChars(where, len, seg); |
280 |
|
return new String(seg.array, seg.offset, seg.count); |
281 |
|
} |
282 |
|
catch (StringIndexOutOfBoundsException ex) |
283 |
|
{ |
284 |
|
int invalid = 0; |
285 |
|
if (seg.offset < 0 || seg.offset >= seg.array.length) |
286 |
|
invalid = seg.offset; |
287 |
|
else |
288 |
|
invalid = seg.offset + seg.count; |
289 |
|
throw new BadLocationException("Illegal location: array.length = " |
290 |
|
+ seg.array.length + ", offset = " |
291 |
|
+ seg.offset + ", count = " |
292 |
|
+ seg.count, invalid); |
293 |
|
} |
294 |
} |
} |
295 |
|
|
296 |
/** |
/** |
372 |
if (index < 0) |
if (index < 0) |
373 |
index = -(index + 1); |
index = -(index + 1); |
374 |
positions.add(index, pos); |
positions.add(index, pos); |
375 |
|
|
376 |
return pos; |
return pos; |
377 |
} |
} |
378 |
|
|