This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
FYI: Patch: javax.print.attribute - several fixes
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Tue, 23 Dec 2003 11:28:10 +0100
- Subject: FYI: Patch: javax.print.attribute - several fixes
Hi list,
I commited the attached patch tp fix several issues in javax.print.attribute.
Most of them are pointed out by Jörg Brunsmann.
Michael
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2481
diff -u -b -B -r1.2481 ChangeLog
--- ChangeLog 22 Dec 2003 20:43:36 -0000 1.2481
+++ ChangeLog 23 Dec 2003 10:20:15 -0000
@@ -1,3 +1,19 @@
+2003-12-23 Michael Koch <konqueror@gmx.de>
+
+ * javax/print/attribute/AttributeSetUtilities.java
+ (verifyCategoryForValue): Renamed from verifyCategoryForAttribute.
+ * javax/print/attribute/HashAttributeSet.java
+ (HashAttributeSet): Call internal add methods, added missing
+ exceptions.
+ (add): Call addInternal, added exceptions to documentation.
+ (addInternal): New method.
+ (addAll): Call addAllInternal, added exception to documentation.
+ (addAllInternal): New method.
+ (clear): Added exception to documentation.
+ (remove): Likewise.
+ * javax/print/attribute/URISyntax.java
+ (serialVersionUID): Fixed value.
+
2003-12-22 Thomas Fitzsimmons <fitzsim@redhat.com>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c
Index: javax/print/attribute/AttributeSetUtilities.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/print/attribute/AttributeSetUtilities.java,v
retrieving revision 1.1
diff -u -b -B -r1.1 AttributeSetUtilities.java
--- javax/print/attribute/AttributeSetUtilities.java 21 Dec 2003 19:54:52 -0000 1.1
+++ javax/print/attribute/AttributeSetUtilities.java 23 Dec 2003 10:20:15 -0000
@@ -432,7 +432,7 @@
* @exception IllegalArgumentException if the categories are not equal
* @exception NullPointerException if category is null
*/
- public static void verifyCategoryForAttribute(Class category,
+ public static void verifyCategoryForValue(Class category,
Attribute attribute)
{
if (category == null)
Index: javax/print/attribute/HashAttributeSet.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/print/attribute/HashAttributeSet.java,v
retrieving revision 1.1
diff -u -b -B -r1.1 HashAttributeSet.java
--- javax/print/attribute/HashAttributeSet.java 21 Dec 2003 19:54:52 -0000 1.1
+++ javax/print/attribute/HashAttributeSet.java 23 Dec 2003 10:20:15 -0000
@@ -124,7 +124,7 @@
if (attribute == null)
throw new NullPointerException();
- add(attribute);
+ addInternal(attribute, interfaceName);
}
/**
@@ -142,7 +142,7 @@
throw new NullPointerException();
for (int index = 0; index < attributes.length; index++)
- add(attributes[index]);
+ addInternal(attributes[index], interfaceName);
}
/**
@@ -150,14 +150,13 @@
*
* @exception ClassCastException if any element of attributes is not an
* interface of interfaceName
- * @exception NullPointerException if attributes or interfaceName is null
*/
public HashAttributeSet(AttributeSet attributes, Class interfaceName)
{
this(interfaceName);
if (attributes != null)
- addAll(attributes);
+ addAllInternal(attributes, interfaceName);
}
/**
@@ -166,12 +165,24 @@
* @param attribute the attribute to add
*
* @return true if the attribute set has changed, false otherwise
+ *
+ * @exception NullPointerException if attribute is null
+ * @exception UnmodifiableSetException if this attribute set does not
+ * support this action.
*/
public boolean add(Attribute attribute)
{
+ return addInternal(attribute, interfaceName);
+ }
+
+ private boolean addInternal(Attribute attribute, Class interfaceName)
+ {
if (attribute == null)
throw new NullPointerException("attribute may not be null");
+ AttributeSetUtilities.verifyAttributeCategory(interfaceName,
+ this.interfaceName);
+
Object old = attributeMap.put
(attribute.getCategory(), AttributeSetUtilities.verifyAttributeValue
(attribute, interfaceName));
@@ -184,14 +195,22 @@
* @param attributes the attributes to add
*
* @return true if the attribute set has changed, false otherwise
+ *
+ * @exception UnmodifiableSetException if this attribute set does not
+ * support this action.
*/
public boolean addAll(AttributeSet attributes)
{
+ return addAllInternal(attributes, interfaceName);
+ }
+
+ private boolean addAllInternal(AttributeSet attributes, Class interfaceName)
+ {
boolean modified = false;
Attribute[] array = attributes.toArray();
for (int index = 0; index < array.length; index++)
- if (! add(array[index]))
+ if (addInternal(array[index], interfaceName))
modified = true;
return modified;
@@ -199,6 +218,9 @@
/**
* Removes all attributes from this attribute set.
+ *
+ * @exception UnmodifiableSetException if this attribute set does not
+ * support this action.
*/
public void clear()
{
@@ -285,6 +307,9 @@
* @param attribute the attribute value of the entry to be removed
*
* @return true if the attribute set has changed, false otherwise.
+ *
+ * @exception UnmodifiableSetException if this attribute set does not
+ * support this action.
*/
public boolean remove(Attribute attribute)
{
Index: javax/print/attribute/URISyntax.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/print/attribute/URISyntax.java,v
retrieving revision 1.1
diff -u -b -B -r1.1 URISyntax.java
--- javax/print/attribute/URISyntax.java 21 Dec 2003 11:10:54 -0000 1.1
+++ javax/print/attribute/URISyntax.java 23 Dec 2003 10:20:15 -0000
@@ -46,7 +46,7 @@
public abstract class URISyntax
implements Cloneable, Serializable
{
- private static final long serialVersionUID = 3666874174847632203L;
+ private static final long serialVersionUID = -7842661210486401678L;
private URI uri;