You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@apache.org on 2002/06/24 01:04:16 UTC
cvs commit: jakarta-commons-sandbox/lang/src/java/org/apache/commons/lang Objects.java
scolebourne 2002/06/23 16:04:16
Modified: lang/src/test/org/apache/commons/lang ObjectsTest.java
lang/src/java/org/apache/commons/lang Objects.java
Log:
Serialization methods removed from Objects into Serialization class
Revision Changes Path
1.3 +0 -21 jakarta-commons-sandbox/lang/src/test/org/apache/commons/lang/ObjectsTest.java
Index: ObjectsTest.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/lang/src/test/org/apache/commons/lang/ObjectsTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ObjectsTest.java 16 Mar 2002 18:07:01 -0000 1.2
+++ ObjectsTest.java 23 Jun 2002 23:04:16 -0000 1.3
@@ -87,27 +87,6 @@
Objects.isNull(o, dflt));
}
- public void testDeserialize()
- {
- serializeDeserialize();
- }
-
- public void testSerialize()
- {
- serializeDeserialize();
- }
-
- private void serializeDeserialize()
- {
- HashMap original = new HashMap();
- original.put(FOO, BAR);
- original.put(BAR, FOO);
- byte[] ser = Objects.serialize(original);
- HashMap deser = (HashMap)Objects.deserialize(ser);
- assertEquals(MAP_ERROR, original.get(FOO), deser.get(FOO));
- assertEquals(MAP_ERROR, original.get(BAR), deser.get(BAR));
- }
-
public void testEquals()
{
assertTrue("Objects.equals(null, null) returned false",
1.4 +3 -89 jakarta-commons-sandbox/lang/src/java/org/apache/commons/lang/Objects.java
Index: Objects.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/lang/src/java/org/apache/commons/lang/Objects.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Objects.java 16 Mar 2002 18:07:01 -0000 1.3
+++ Objects.java 23 Jun 2002 23:04:16 -0000 1.4
@@ -54,14 +54,7 @@
* <http://www.apache.org/>.
*/
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.Serializable;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectOutputStream;
-import java.io.IOException;
+
/**
* Common <code>Object</code> manipulation routines.
@@ -69,6 +62,7 @@
* @author <a href="mailto:nissim@nksystems.com">Nissim Karpenstein</a>
* @author <a href="mailto:janekdb@yahoo.co.uk">Janek Bogucki</a>
* @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
+ * @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
* @version $Id$
*/
public class Objects
@@ -83,86 +77,6 @@
public static Object isNull(Object o, Object dflt)
{
return (o != null ? o : dflt);
- }
-
- /**
- * Deserializes a single object from an array of bytes.
- *
- * @param objectData The serialized object.
- * @return The deserialized object, or <code>null</code> on failure.
- */
- public static Object deserialize(byte[] objectData)
- {
- Object object = null;
- if (objectData != null)
- {
- ObjectInputStream in = null;
- try
- {
- InputStream bin = new ByteArrayInputStream(objectData);
- in = new ObjectInputStream(bin);
-
- // If objectData has not been initialized, an
- // exception will occur.
- object = in.readObject();
- }
- catch (Exception returnNull)
- {
- }
- finally
- {
- try
- {
- if (in != null)
- {
- in.close();
- }
- }
- catch (IOException ignored)
- {
- }
- }
- }
- return object;
- }
-
-
- /**
- * Converts a object to a byte array for storage/serialization.
- *
- * @param obj The Serializable to convert.
- * @return A byte[] with the converted Serializable.
- */
- public static byte[] serialize(Serializable obj)
- {
- byte[] byteArray = null;
- ByteArrayOutputStream baos = null;
- ObjectOutputStream out = null;
- try
- {
- // These objects are closed in the finally.
- baos = new ByteArrayOutputStream();
- out = new ObjectOutputStream(baos);
-
- out.writeObject(obj);
- byteArray = baos.toByteArray();
- }
- catch (IOException e)
- {
- byteArray = null;
- }
- finally
- {
- try
- {
- out.close();
- }
- catch (Exception e)
- {
- // ignore;
- }
- }
- return byteArray;
}
/**
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>