diff options
author | Mark Wielaard <mark@klomp.org> | 2006-05-14 16:43:58 +0000 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2006-05-14 16:43:58 +0000 |
commit | ded9851466cb577f9fa9df994826769011613d3c (patch) | |
tree | 4bbd1abe018ba225ff620198dcdc9227d9b8d325 | |
parent | 3b0f954cf611df0f4e12b05ca98f0fd89474a01b (diff) | |
download | classpath-ded9851466cb577f9fa9df994826769011613d3c.tar.gz |
2006-05-14 Robert Schuster <robertschuster@fsfe.org>
PR classpath/27595
* javax/swing/text/AbstractDocument.java:
(insertString): Flipped if-expression and its blocks.
(remove): Dito.
(replace): Flipped if-expression and its blocks, added note, invoke
insertString and remove instead of insertStringImpl and removeImpl.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | javax/swing/text/AbstractDocument.java | 28 |
2 files changed, 28 insertions, 9 deletions
@@ -1,3 +1,12 @@ +2006-05-14 Robert Schuster <robertschuster@fsfe.org> + + PR classpath/27595 + * javax/swing/text/AbstractDocument.java: + (insertString): Flipped if-expression and its blocks. + (remove): Dito. + (replace): Flipped if-expression and its blocks, added note, invoke + insertString and remove instead of insertStringImpl and removeImpl. + 2006-05-13 Tom Tromey <tromey@redhat.com> * java/nio/ByteBufferImpl.java (compact): Always set position. diff --git a/javax/swing/text/AbstractDocument.java b/javax/swing/text/AbstractDocument.java index 3b27c6d76..1ef81732f 100644 --- a/javax/swing/text/AbstractDocument.java +++ b/javax/swing/text/AbstractDocument.java @@ -562,10 +562,10 @@ public abstract class AbstractDocument implements Document, Serializable if (text == null || text.length() == 0) return; - if (documentFilter != null) - documentFilter.insertString(getBypass(), offset, text, attributes); - else + if (documentFilter == null) insertStringImpl(offset, text, attributes); + else + documentFilter.insertString(getBypass(), offset, text, attributes); } void insertStringImpl(int offset, String text, AttributeSet attributes) @@ -731,10 +731,10 @@ public abstract class AbstractDocument implements Document, Serializable */ public void remove(int offset, int length) throws BadLocationException { - if (documentFilter != null) - documentFilter.remove(getBypass(), offset, length); - else + if (documentFilter == null) removeImpl(offset, length); + else + documentFilter.remove(getBypass(), offset, length); } void removeImpl(int offset, int length) throws BadLocationException @@ -795,10 +795,20 @@ public abstract class AbstractDocument implements Document, Serializable && (text == null || text.length() == 0)) return; - if (documentFilter != null) - documentFilter.replace(getBypass(), offset, length, text, attributes); + if (documentFilter == null) + { + // It is important to call the methods which again do the checks + // of the arguments and the DocumentFilter because subclasses may + // have overridden these methods and provide crucial behavior + // which would be skipped if we call the non-checking variants. + // An example for this is PlainDocument where insertString can + // provide a filtering of newlines. + remove(offset, length); + insertString(offset, text, attributes); + } else - replaceImpl(offset, length, text, attributes); + documentFilter.replace(getBypass(), offset, length, text, attributes); + } void replaceImpl(int offset, int length, String text, |