xml-commons-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mrgla...@apache.org
Subject svn commit: r327076 - /xml/commons/trunk/java/external/src/javax/xml/namespace/QName.java
Date Fri, 21 Oct 2005 02:17:55 GMT
Author: mrglavas
Date: Thu Oct 20 19:17:51 2005
New Revision: 327076

URL: http://svn.apache.org/viewcvs?rev=327076&view=rev
Log:
Allow older versions of QName which didn't have a prefix field to be deserialized correctly.

Modified:
    xml/commons/trunk/java/external/src/javax/xml/namespace/QName.java

Modified: xml/commons/trunk/java/external/src/javax/xml/namespace/QName.java
URL: http://svn.apache.org/viewcvs/xml/commons/trunk/java/external/src/javax/xml/namespace/QName.java?rev=327076&r1=327075&r2=327076&view=diff
==============================================================================
--- xml/commons/trunk/java/external/src/javax/xml/namespace/QName.java (original)
+++ xml/commons/trunk/java/external/src/javax/xml/namespace/QName.java Thu Oct 20 19:17:51
2005
@@ -18,6 +18,8 @@
 
 package javax.xml.namespace;
 
+import java.io.IOException;
+import java.io.ObjectInputStream;
 import java.io.Serializable;
 
 import javax.xml.XMLConstants;
@@ -80,7 +82,7 @@
     /**
      * <p>prefix of this <code>QName</code>.</p>
      */
-    private final String prefix;
+    private String prefix;
     
     /**
      * <p><code>String</code> representation of this <code>QName</code>.</p>
@@ -441,5 +443,20 @@
             qNameAsString.substring(1, endOfNamespaceURI),
             qNameAsString.substring(endOfNamespaceURI + 1),
             XMLConstants.DEFAULT_NS_PREFIX);
+    }
+    
+    /*
+     * For old versions of QName which didn't have a prefix field,
+     * <code>ObjectInputStream.defaultReadObject()</code> will initialize
+     * the prefix to <code>null</code> instead of the empty string. This
+     * method fixes up the prefix field if it didn't exist in the serialized
+     * object.
+     */
+    private void readObject(ObjectInputStream in) 
+        throws IOException, ClassNotFoundException {
+        in.defaultReadObject();
+        if (prefix == null) {
+            prefix = XMLConstants.DEFAULT_NS_PREFIX;
+        }
     }
 }



Mime
View raw message