[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] FYI: javax.swing.text.SimpleAttributeSet
From: |
David Gilbert |
Subject: |
[cp-patches] FYI: javax.swing.text.SimpleAttributeSet |
Date: |
Mon, 16 Jan 2006 10:02:21 +0000 |
User-agent: |
Mozilla Thunderbird 1.0.7 (X11/20051013) |
This patch (committed) fixes some failing Mauve tests:
2006-01-16 David Gilbert <address@hidden>
* javax/swing/text/SimpleAttributeSet.java
(SimpleAttributeSet()): Initialise storage directly,
(SimpleAttributeSet(AttributeSet)): Removed null check and documented
NullPointerException,
(containsAttribute): If key is found locally, don't check resolving
parent if the value doesn't match,
(getAttribute): Removed redundant instanceof and cast.
Regards,
Dave
Index: javax/swing/text/SimpleAttributeSet.java
===================================================================
RCS file:
/sources/classpath/classpath/javax/swing/text/SimpleAttributeSet.java,v
retrieving revision 1.13
diff -u -r1.13 SimpleAttributeSet.java
--- javax/swing/text/SimpleAttributeSet.java 16 Jan 2006 09:24:19 -0000
1.13
+++ javax/swing/text/SimpleAttributeSet.java 16 Jan 2006 09:49:37 -0000
@@ -62,21 +62,21 @@
*/
public SimpleAttributeSet()
{
- this(null);
+ tab = new Hashtable();
}
/**
* Creates a new <code>SimpleAttributeSet</code> with the same attributes
* and resolve parent as the specified set.
*
- * @param a the attributes.
+ * @param a the attributes (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if <code>a</code> is <code>null</code>.
*/
public SimpleAttributeSet(AttributeSet a)
{
- // FIXME: null argument should throw NullPointerException
tab = new Hashtable();
- if (a != null)
- addAttributes(a);
+ addAttributes(a);
}
/**
@@ -136,11 +136,18 @@
*/
public boolean containsAttribute(Object name, Object value)
{
- // FIXME: if the name is defined in this set, any match in the parent
- // should be ignored
- return (tab.containsKey(name) && tab.get(name).equals(value)) ||
- (getResolveParent() != null && getResolveParent().
- containsAttribute(name, value));
+ if (value == null)
+ throw new NullPointerException("Null 'value' argument.");
+ if (tab.containsKey(name))
+ return tab.get(name).equals(value);
+ else
+ {
+ AttributeSet p = getResolveParent();
+ if (p != null)
+ return p.containsAttribute(name, value);
+ else
+ return false;
+ }
}
/**
@@ -219,10 +226,9 @@
if (val != null)
return val;
- // FIXME: The following instanceof check and cast is redundant
- Object p = getResolveParent();
- if (p != null && p instanceof AttributeSet)
- return (((AttributeSet)p).getAttribute(name));
+ AttributeSet p = getResolveParent();
+ if (p != null)
+ return p.getAttribute(name);
return null;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] FYI: javax.swing.text.SimpleAttributeSet,
David Gilbert <=