diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2006-05-10 09:53:20 +0000 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2006-05-10 09:53:20 +0000 |
commit | 93eeec8e54c8fc01d45e5e7b8fef854dfb61a8c0 (patch) | |
tree | 377f12fc88a7bb3305ae8bd039b2e97661f7807b | |
parent | 836c0d15e7ae358504391e38db644134faa82f79 (diff) | |
download | classpath-93eeec8e54c8fc01d45e5e7b8fef854dfb61a8c0.tar.gz |
2006-05-09 Robert Schuster <robertschuster@fsfe.org>
PR classpath/24216
* javax/swing/text/AbstractDocument.java:
(insertString): Added more documentation, added argument check.
(remove): Added more documentation.
(removeImpl): Added argument check.
(replace): Added more documentation, added argument check.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | javax/swing/text/AbstractDocument.java | 31 |
2 files changed, 38 insertions, 2 deletions
@@ -1,3 +1,12 @@ +2006-05-09 Robert Schuster <robertschuster@fsfe.org> + + PR classpath/24216 + * javax/swing/text/AbstractDocument.java: + (insertString): Added more documentation, added argument check. + (remove): Added more documentation. + (removeImpl): Added argument check. + (replace): Added more documentation, added argument check. + 2006-05-08 Lillian Angel <langel@redhat.com> * java/net/URLClassLoader.java diff --git a/javax/swing/text/AbstractDocument.java b/javax/swing/text/AbstractDocument.java index 881b4d7f2..3b27c6d76 100644 --- a/javax/swing/text/AbstractDocument.java +++ b/javax/swing/text/AbstractDocument.java @@ -543,6 +543,10 @@ public abstract class AbstractDocument implements Document, Serializable * * <p>If a {@link DocumentFilter} is installed in this document, the * corresponding method of the filter object is called.</p> + * + * <p>The method has no effect when <code>text</code> is <code>null</code> + * or has a length of zero.</p> + * * * @param offset the location at which the string should be inserted * @param text the content to be inserted @@ -554,6 +558,10 @@ public abstract class AbstractDocument implements Document, Serializable public void insertString(int offset, String text, AttributeSet attributes) throws BadLocationException { + // Bail out if we have a bogus insertion (Behavior observed in RI). + if (text == null || text.length() == 0) + return; + if (documentFilter != null) documentFilter.insertString(getBypass(), offset, text, attributes); else @@ -706,8 +714,14 @@ public abstract class AbstractDocument implements Document, Serializable * Removes a piece of content from this <code>Document</code>. * * <p>If a {@link DocumentFilter} is installed in this document, the - * corresponding method of the filter object is called.</p> - * + * corresponding method of the filter object is called. The + * <code>DocumentFilter</code> is called even if <code>length</code> + * is zero. This is different from {@link #replace}.</p> + * + * <p>Note: When <code>length</code> is zero or below the call is not + * forwarded to the underlying {@link AbstractDocument.Content} instance + * of this document and no exception is thrown.</p> + * * @param offset the start offset of the fragment to be removed * @param length the length of the fragment to be removed * @@ -725,6 +739,10 @@ public abstract class AbstractDocument implements Document, Serializable void removeImpl(int offset, int length) throws BadLocationException { + // Prevent some unneccessary method invocation (observed in the RI). + if (length <= 0) + return; + DefaultDocumentEvent event = new DefaultDocumentEvent(offset, length, DocumentEvent.EventType.REMOVE); @@ -752,6 +770,10 @@ public abstract class AbstractDocument implements Document, Serializable * * <p>If a {@link DocumentFilter} is installed in this document, the * corresponding method of the filter object is called.</p> + * + * <p>The method has no effect if <code>length</code> is zero (and + * only zero) and, at the same time, <code>text</code> is + * <code>null</code> or has zero length.</p> * * @param offset the start offset of the fragment to be removed * @param length the length of the fragment to be removed @@ -768,6 +790,11 @@ public abstract class AbstractDocument implements Document, Serializable AttributeSet attributes) throws BadLocationException { + // Bail out if we have a bogus replacement (Behavior observed in RI). + if (length == 0 + && (text == null || text.length() == 0)) + return; + if (documentFilter != null) documentFilter.replace(getBypass(), offset, length, text, attributes); else |