summaryrefslogtreecommitdiff
path: root/java/rmi/MarshalledObject.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/rmi/MarshalledObject.java')
-rw-r--r--java/rmi/MarshalledObject.java65
1 files changed, 36 insertions, 29 deletions
diff --git a/java/rmi/MarshalledObject.java b/java/rmi/MarshalledObject.java
index 9ec0ace0e..e07123804 100644
--- a/java/rmi/MarshalledObject.java
+++ b/java/rmi/MarshalledObject.java
@@ -1,5 +1,6 @@
/* MarshalledObject.java --
- Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+ Copyright (c) 1996, 1997, 1998, 1999, 2004, 2006
+ Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,38 +43,43 @@ import gnu.java.rmi.RMIMarshalledObjectInputStream;
import gnu.java.rmi.RMIMarshalledObjectOutputStream;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.io.Serializable;
/**
* FIXME - doc missing
*/
-public final class MarshalledObject implements Serializable
+public final class MarshalledObject
+ implements Serializable
{
- //The following fields are from Java API Documentation "Serialized form"
+ // The following fields are from Java API Documentation "Serialized form"
private static final long serialVersionUID = 8988374069173025854L;
+
byte[] objBytes;
byte[] locBytes;
int hash;
-
+
public MarshalledObject(Object obj) throws java.io.IOException
{
ByteArrayOutputStream objStream = new ByteArrayOutputStream();
- RMIMarshalledObjectOutputStream stream = new RMIMarshalledObjectOutputStream(objStream);
+ RMIMarshalledObjectOutputStream stream =
+ new RMIMarshalledObjectOutputStream(objStream);
stream.writeObject(obj);
stream.flush();
objBytes = objStream.toByteArray();
locBytes = stream.getLocBytes();
-
- //The following algorithm of calculating hashCode is similar to String
+
+ // The following algorithm of calculating hashCode is similar to String
hash = 0;
for (int i = 0; i < objBytes.length; i++)
hash = hash * 31 + objBytes[i];
- if(locBytes != null)
+
+ if (locBytes != null)
for (int i = 0; i < locBytes.length; i++)
- hash = hash * 31 + locBytes[i];
+ hash = hash * 31 + locBytes[i];
}
-
- public boolean equals(Object obj)
+
+ public boolean equals(Object obj)
{
if (! (obj instanceof MarshalledObject))
return false;
@@ -81,33 +87,34 @@ public final class MarshalledObject implements Serializable
// hashCode even differs, don't do the time-consuming comparisons
if (obj.hashCode() != hash)
return false;
-
- MarshalledObject aobj = (MarshalledObject)obj;
+
+ MarshalledObject aobj = (MarshalledObject) obj;
if (objBytes == null || aobj.objBytes == null)
return objBytes == aobj.objBytes;
if (objBytes.length != aobj.objBytes.length)
return false;
- for (int i = 0; i < objBytes.length; i++)
+ for (int i = 0; i < objBytes.length; i++)
{
- if (objBytes[i] != aobj.objBytes[i])
- return false;
+ if (objBytes[i] != aobj.objBytes[i])
+ return false;
}
// Ignore comparison of locBytes(annotation)
return true;
}
-
-public Object get()
- throws java.io.IOException, java.lang.ClassNotFoundException
-{
- if(objBytes == null)
- return null;
- RMIMarshalledObjectInputStream stream =
- new RMIMarshalledObjectInputStream(objBytes, locBytes);
- return stream.readObject();
-}
-
- public int hashCode() {
+
+ public Object get() throws IOException, ClassNotFoundException
+ {
+ if (objBytes == null)
+ return null;
+
+ RMIMarshalledObjectInputStream stream =
+ new RMIMarshalledObjectInputStream(objBytes, locBytes);
+ return stream.readObject();
+ }
+
+ public int hashCode()
+ {
return hash;
}
-
+
}