summaryrefslogtreecommitdiff
path: root/javax/swing/text/GapContent.java
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2006-05-03 21:33:24 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2006-05-03 21:33:24 +0000
commit940e4db75683240c9a097b812e973e1009ab56c4 (patch)
treef8ccf9d28d0187f82242548af232ada92f68a61f /javax/swing/text/GapContent.java
parent480ccb4bfcc622c1ce320c20ce992188187f7573 (diff)
downloadclasspath-940e4db75683240c9a097b812e973e1009ab56c4.tar.gz
2006-05-03 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge of HEAD --> generics-branch for the period 2005/05/01 to 2005/05/03 (branch of 0.91 for release)
Diffstat (limited to 'javax/swing/text/GapContent.java')
-rw-r--r--javax/swing/text/GapContent.java22
1 files changed, 9 insertions, 13 deletions
diff --git a/javax/swing/text/GapContent.java b/javax/swing/text/GapContent.java
index bad7c0a01..219accb40 100644
--- a/javax/swing/text/GapContent.java
+++ b/javax/swing/text/GapContent.java
@@ -289,6 +289,7 @@ public class GapContent
*/
public GapContent(int size)
{
+ size = Math.max(size, 2);
buffer = (char[]) allocateArray(size);
gapStart = 1;
gapEnd = size;
@@ -351,7 +352,7 @@ public class GapContent
throw new BadLocationException("The where argument cannot be smaller"
+ " than the zero", where);
- if (where >= length)
+ if (where > length)
throw new BadLocationException("The where argument cannot be greater"
+ " than the content length", where);
@@ -375,14 +376,11 @@ public class GapContent
{
// check arguments
int length = length();
-
- if (where >= length)
- throw new BadLocationException("the where argument cannot be greater"
- + " than the content length", where);
- if ((where + nitems) > length)
+
+ if ((where + nitems) >= length)
throw new BadLocationException("where + nitems cannot be greater"
+ " than the content length", where + nitems);
-
+
String removedText = getString(where, nitems);
replace(where, nitems, null, 0);
@@ -439,6 +437,8 @@ public class GapContent
{
// check arguments
int length = length();
+ if (where < 0)
+ throw new BadLocationException("the where argument may not be below zero", where);
if (where >= length)
throw new BadLocationException("the where argument cannot be greater"
+ " than the content length", where);
@@ -643,12 +643,8 @@ public class GapContent
{
System.arraycopy(addItems, 0, buffer, gapStart, addSize);
- // Position objects having their mark at the end of the gap
- // (results in an offset equal to gapStart) should be moved down
- // because the size of the gap will decrease by addSize and the
- // offsets will increase by the same amount and the latter should
- // not happen.
- setPositionsInRange(gapEnd, 0, gapStart);
+
+ resetMarksAtZero();
gapStart += addSize;
}