You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2009/03/20 00:36:09 UTC
svn commit: r756262 - in
/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype:
DurationImpl.java SerializedDuration.java
SerializedXMLGregorianCalendar.java XMLGregorianCalendarImpl.java
Author: mrglavas
Date: Thu Mar 19 23:36:08 2009
New Revision: 756262
URL: http://svn.apache.org/viewvc?rev=756262&view=rev
Log:
Use lexical form for Java serialization to reduce compatibility concerns which may arise
from making changes to the internal representation of Duration and XMLGregorianCalendar.
Added:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/SerializedDuration.java (with props)
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/SerializedXMLGregorianCalendar.java (with props)
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/DurationImpl.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/XMLGregorianCalendarImpl.java
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/DurationImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/DurationImpl.java?rev=756262&r1=756261&r2=756262&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/DurationImpl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/DurationImpl.java Thu Mar 19 23:36:08 2009
@@ -18,7 +18,6 @@
package org.apache.xerces.jaxp.datatype;
import java.io.IOException;
-import java.io.ObjectStreamException;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -100,6 +99,11 @@
class DurationImpl
extends Duration
implements Serializable {
+
+ /**
+ * <p>Stream Unique Identifier.</p>
+ */
+ private static final long serialVersionUID = -2650025807136350131L;
/**
* <p>Internal array of value Fields.</p>
@@ -1936,12 +1940,16 @@
}
/**
- * <p>Stream Unique Identifier.</p>
+ * Calls the {@link Calendar#getTimeInMillis} method.
+ * Prior to JDK1.4, this method was protected and therefore
+ * cannot be invoked directly.
*
- * <p>TODO: Serialization should use the XML string representation as
- * the serialization format to ensure future compatibility.</p>
+ * In future, this should be replaced by
+ * <code>cal.getTimeInMillis()</code>
*/
- private static final long serialVersionUID = 1L;
+ private static long getCalendarTimeInMillis(Calendar cal) {
+ return cal.getTime().getTime();
+ }
/**
* Writes {@link Duration} as a lexical representation
@@ -1952,42 +1960,6 @@
* returned by <code>this.toString()</code>.
*/
private Object writeReplace() throws IOException {
- return new DurationStream(this.toString());
- }
-
- /**
- * Representation of {@link Duration} in the object stream.
- *
- * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
- */
- private static class DurationStream implements Serializable {
- private final String lexical;
-
- private DurationStream(String _lexical) {
- this.lexical = _lexical;
- }
-
- private Object readResolve() throws ObjectStreamException {
- // try {
- return new DurationImpl(lexical);
- // } catch( ParseException e ) {
- // throw new StreamCorruptedException("unable to parse "+lexical+" as duration");
- // }
- }
-
- private static final long serialVersionUID = 1L;
- }
-
- /**
- * Calls the {@link Calendar#getTimeInMillis} method.
- * Prior to JDK1.4, this method was protected and therefore
- * cannot be invoked directly.
- *
- * In future, this should be replaced by
- * <code>cal.getTimeInMillis()</code>
- */
- private static long getCalendarTimeInMillis(Calendar cal) {
- return cal.getTime().getTime();
+ return new SerializedDuration(toString());
}
}
-
Added: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/SerializedDuration.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/SerializedDuration.java?rev=756262&view=auto
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/SerializedDuration.java (added)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/SerializedDuration.java Thu Mar 19 23:36:08 2009
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.jaxp.datatype;
+
+import java.io.ObjectStreamException;
+import java.io.Serializable;
+
+/**
+ * <p>Serialized form of <code>javax.xml.datatype.Duration</code>.</p>
+ *
+ * @author Michael Glavassevich, IBM
+ * @version $Id$
+ */
+final class SerializedDuration implements Serializable {
+
+ private static final long serialVersionUID = 3897193592341225793L;
+ private final String lexicalValue;
+
+ public SerializedDuration(String lexicalValue) {
+ this.lexicalValue = lexicalValue;
+ }
+
+ private Object readResolve() throws ObjectStreamException {
+ return new DatatypeFactoryImpl().newDuration(lexicalValue);
+ }
+}
Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/SerializedDuration.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/SerializedDuration.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/SerializedXMLGregorianCalendar.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/SerializedXMLGregorianCalendar.java?rev=756262&view=auto
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/SerializedXMLGregorianCalendar.java (added)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/SerializedXMLGregorianCalendar.java Thu Mar 19 23:36:08 2009
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.jaxp.datatype;
+
+import java.io.ObjectStreamException;
+import java.io.Serializable;
+
+/**
+ * <p>Serialized form of <code>javax.xml.datatype.XMLGregorianCalendar</code>.</p>
+ *
+ * @author Michael Glavassevich, IBM
+ * @version $Id$
+ */
+final class SerializedXMLGregorianCalendar implements Serializable {
+
+ private static final long serialVersionUID = -7752272381890705397L;
+ private final String lexicalValue;
+
+ public SerializedXMLGregorianCalendar(String lexicalValue) {
+ this.lexicalValue = lexicalValue;
+ }
+
+ private Object readResolve() throws ObjectStreamException {
+ return new DatatypeFactoryImpl().newXMLGregorianCalendar(lexicalValue);
+ }
+}
Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/SerializedXMLGregorianCalendar.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/SerializedXMLGregorianCalendar.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/XMLGregorianCalendarImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/XMLGregorianCalendarImpl.java?rev=756262&r1=756261&r2=756262&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/XMLGregorianCalendarImpl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/datatype/XMLGregorianCalendarImpl.java Thu Mar 19 23:36:08 2009
@@ -17,6 +17,7 @@
package org.apache.xerces.jaxp.datatype;
+import java.io.IOException;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -179,6 +180,11 @@
class XMLGregorianCalendarImpl
extends XMLGregorianCalendar
implements Serializable, Cloneable {
+
+ /**
+ * <p>Stream Unique Identifier.</p>
+ */
+ private static final long serialVersionUID = 3905403108073447394L;
/** Backup values **/
private BigInteger orig_eon;
@@ -334,15 +340,7 @@
"Second",
"Millisecond",
"Timezone"
- };
-
- /**
- * <p>Stream Unique Identifier.</p>
- *
- * <p>TODO: Serialization should use the XML string representation as
- * the serialization format to ensure future compatibility.</p>
- */
- private static final long serialVersionUID = 1L;
+ };
/**
* <p>Use as a template for default field values when
@@ -3177,5 +3175,17 @@
fractionalSecond = orig_fracSeconds;
timezone = orig_timezone;
}
+
+ /**
+ * Writes {@link XMLGregorianCalendar} as a lexical representation
+ * for maximum future compatibility.
+ *
+ * @return
+ * An object that encapsulates the string
+ * returned by <code>this.toXMLFormat()</code>.
+ */
+ private Object writeReplace() throws IOException {
+ return new SerializedXMLGregorianCalendar(toXMLFormat());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org