summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schuster <theBohemian@gmx.net>2006-04-28 09:44:08 +0000
committerRobert Schuster <theBohemian@gmx.net>2006-04-28 09:44:08 +0000
commit59975fb231aeca418ff9eb666a4617217cfb1ca5 (patch)
tree0c85184afdf55753056b5c72b003125eb71d697c
parent22838cd64529ad1fdd6f350a1242ed83c32d4b04 (diff)
downloadclasspath-59975fb231aeca418ff9eb666a4617217cfb1ca5.tar.gz
2006-04-28 Robert Schuster <robertschuster@fsfe.org>
* javax/swing/text/Utilities.java: (getNextWord): Use codePointAt instead of charAt, added note, changed if-expression, added throwing of exception. (getPreviousWord): Use codePointAt instead of charAt.
-rw-r--r--ChangeLog7
-rw-r--r--javax/swing/text/Utilities.java23
2 files changed, 23 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 61ae8e543..e795970ab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-04-28 Robert Schuster <robertschuster@fsfe.org>
+
+ * javax/swing/text/Utilities.java:
+ (getNextWord): Use codePointAt instead of charAt, added note, changed
+ if-expression, added throwing of exception.
+ (getPreviousWord): Use codePointAt instead of charAt.
+
2006-04-28 Jeroen Frijters <jeroen@frijters.net>
* java/lang/StringBuilder.java
diff --git a/javax/swing/text/Utilities.java b/javax/swing/text/Utilities.java
index 22da8fa51..f154e55aa 100644
--- a/javax/swing/text/Utilities.java
+++ b/javax/swing/text/Utilities.java
@@ -48,6 +48,7 @@ import java.text.BreakIterator;
* inside this package.
*
* @author Roman Kennke (roman@ontographics.com)
+ * @author Robert Schuster (robertschuster@fsfe.org)
*/
public class Utilities
{
@@ -321,21 +322,31 @@ public class Utilities
String text = c.getText();
BreakIterator wb = BreakIterator.getWordInstance();
wb.setText(text);
+
int last = wb.following(offs);
int current = wb.next();
+ int cp;
+
while (current != BreakIterator.DONE)
{
for (int i = last; i < current; i++)
{
- // FIXME: Should use isLetter(int) and text.codePointAt(int)
- // instead, but isLetter(int) isn't implemented yet
- if (Character.isLetter(text.charAt(i)))
+ cp = text.codePointAt(i);
+
+ // Return the last found bound if there is a letter at the current
+ // location or is not whitespace (meaning it is a number or
+ // punctuation). The first case means that 'last' denotes the
+ // beginning of a word while the second case means it is the start
+ // of some else.
+ if (Character.isLetter(cp)
+ || !Character.isWhitespace(cp))
return last;
}
last = current;
current = wb.next();
}
- return BreakIterator.DONE;
+
+ throw new BadLocationException("no more word", offs);
}
/**
@@ -364,9 +375,7 @@ public class Utilities
{
for (int i = last; i < offs; i++)
{
- // FIXME: Should use isLetter(int) and text.codePointAt(int)
- // instead, but isLetter(int) isn't implemented yet
- if (Character.isLetter(text.charAt(i)))
+ if (Character.isLetter(text.codePointAt(i)))
return last;
}
last = current;