You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by le...@apache.org on 2002/04/24 04:04:52 UTC
cvs commit: xml-xerces/java/tests/dom/serialization Test.java
lehors 02/04/23 19:04:52
Modified: java/docs releases.xml
java/src/org/apache/xerces/dom DocumentImpl.java
NodeListCache.java
Added: java/tests/dom/serialization Test.java
Log:
fixed Java serialization and added a Test for it
Revision Changes Path
1.115 +9 -2 xml-xerces/java/docs/releases.xml
Index: releases.xml
===================================================================
RCS file: /home/cvs/xml-xerces/java/docs/releases.xml,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -r1.114 -r1.115
--- releases.xml 23 Apr 2002 10:36:56 -0000 1.114
+++ releases.xml 24 Apr 2002 02:04:51 -0000 1.115
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
-<!-- $Id: releases.xml,v 1.114 2002/04/23 10:36:56 andyc Exp $ -->
+<!-- $Id: releases.xml,v 1.115 2002/04/24 02:04:51 lehors Exp $ -->
<!DOCTYPE releases SYSTEM 'dtd/releases.dtd'>
<releases>
<release version="TBD">
@@ -40,9 +40,16 @@
</fix>
<update>
<note>Improved management of ID attributes in the DOM so that
- Document.getElementByID is more reliable.</note>
+ Document.getElementByID is more reliable.
+ </note>
<submitter name='Arnaud Le Hors'/>
</update>
+ <fix>
+ <note>Applied patch from Scott Sanders to fix Java serialization of the
+ DOM and add a test.
+ </note>
+ <submitter name='Arnaud Le Hors'/>
+ </fix>
</changes>
</release>
<release version='Xerces 2.0.1'>
1.71 +4 -3 xml-xerces/java/src/org/apache/xerces/dom/DocumentImpl.java
Index: DocumentImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/DocumentImpl.java,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- DocumentImpl.java 12 Apr 2002 01:52:07 -0000 1.70
+++ DocumentImpl.java 24 Apr 2002 02:04:51 -0000 1.71
@@ -59,6 +59,7 @@
import java.util.Hashtable;
import java.util.Vector;
+import java.io.Serializable;
import org.w3c.dom.Attr;
import org.w3c.dom.DOMException;
@@ -121,7 +122,7 @@
* @author Joe Kesselman, IBM
* @author Andy Clark, IBM
* @author Ralf Pfeiffer, IBM
- * @version $Id: DocumentImpl.java,v 1.70 2002/04/12 01:52:07 lehors Exp $
+ * @version $Id: DocumentImpl.java,v 1.71 2002/04/24 02:04:51 lehors Exp $
* @since PR-DOM-Level-1-19980818.
*/
public class DocumentImpl
@@ -520,7 +521,7 @@
* is probably short in most cases, it might not be worth spending
* the space. ***** REVISIT WHEN WE HAVE MORE EXPERIENCE.
*/
- class LEntry
+ class LEntry implements Serializable
{
String type;
EventListener listener;
@@ -861,7 +862,7 @@
* (two values, the Attr node affected (if any) and its previous
* string value. Simple struct, no methods.
*/
- class EnclosingAttr
+ class EnclosingAttr implements Serializable
{
AttrImpl node;
String oldvalue;
1.3 +4 -2 xml-xerces/java/src/org/apache/xerces/dom/NodeListCache.java
Index: NodeListCache.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/NodeListCache.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- NodeListCache.java 29 Jan 2002 01:15:07 -0000 1.2
+++ NodeListCache.java 24 Apr 2002 02:04:52 -0000 1.3
@@ -1,4 +1,4 @@
-/* $Id: NodeListCache.java,v 1.2 2002/01/29 01:15:07 lehors Exp $ */
+/* $Id: NodeListCache.java,v 1.3 2002/04/24 02:04:52 lehors Exp $ */
/*
* The Apache Software License, Version 1.1
*
@@ -58,12 +58,14 @@
package org.apache.xerces.dom;
+import java.io.Serializable;
+
/**
* This class is used, via a pool managed on CoreDocumentImpl, in ParentNode to
* improve performance of the NodeList accessors, getLength() and item(i).
* @author Arnaud Le Hors, IBM
*/
-class NodeListCache {
+class NodeListCache implements Serializable {
/** Cached node list length. */
int fLength = -1;
1.1 xml-xerces/java/tests/dom/serialization/Test.java
Index: Test.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package dom.serialization;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
import dom.ParserWrapper;
/**
* A java serialization test. This sample program parses a
* document, then serializes out to a file, then reloads
* it from the file. The intent is to have zero exceptions
* in the process.
*
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
* @version $Id: Test.java,v 1.1 2002/04/24 02:04:52 lehors Exp $
*/
public class Test {
protected static final String NAMESPACES_FEATURE_ID = "http://xml.org/sax/features/namespaces";
protected static final String DEFAULT_PARSER_NAME = "dom.wrappers.Xerces";
public static void main(String args[]) {
if (args.length != 2) {
System.exit(1);
}
ParserWrapper parser = null;
try {
parser = (ParserWrapper) Class.forName(DEFAULT_PARSER_NAME).newInstance();
} catch (Exception e) {
System.err.println("error: Unable to instantiate parser (" + DEFAULT_PARSER_NAME + ")");
}
try {
parser.setFeature(NAMESPACES_FEATURE_ID, true);
} catch (SAXException e) {
System.err.println("warning: Parser does not support feature (" + NAMESPACES_FEATURE_ID + ")");
}
try {
Document document = null;
document = parser.parse(args[0]);
serialize(document, args[1]);
Document newDocument = deserialize(args[1]);
} catch (Exception e) {
System.err.println("error: Error occurred - " + e.getMessage());
Exception se = e;
if (e instanceof SAXException) {
se = ((SAXException) e).getException();
}
if (se != null)
se.printStackTrace(System.err);
else
e.printStackTrace(System.err);
}
}
public static void serialize(Document document, String filename) throws Exception {
System.out.println("Serializing parsed document");
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(filename));
out.writeObject(document);
out.close();
}
public static Document deserialize(String filename) throws Exception {
System.out.println("De-Serializing parsed document");
ObjectInputStream in = new ObjectInputStream(new FileInputStream(filename));
Document result = (Document) in.readObject();
return result;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org