Update of /cvsroot/commonjava/commonjava-projects/commonjava-lang/src/java/org/commonjava/lang
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18825/src/java/org/commonjava/lang
Modified Files:
DateID.java CompoundID.java AbstractID.java
Log Message:
Made AbstractID and CompoundID serializable.
Index: DateID.java
===================================================================
RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-lang/src/java/org/commonjava/lang/DateID.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- DateID.java 18 Sep 2003 01:10:42 -0000 1.1
+++ DateID.java 2 Feb 2004 02:20:35 -0000 1.2
@@ -17,6 +17,9 @@
package org.commonjava.lang;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.util.Date;
/** Identifier (as in primary key) that uses a java.util.Date as its internal
@@ -127,5 +130,17 @@
public String toString(){
return "Date ID: " + String.valueOf(date);
}
+
+ /** Deserialize this data ID.
+ */
+ protected void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ this.date = (Date)in.readObject();
+ }
+
+ /** Serialize this data ID.
+ */
+ protected void writeObject(ObjectOutputStream out) throws IOException {
+ out.writeObject(date);
+ }
}
\ No newline at end of file
Index: CompoundID.java
===================================================================
RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-lang/src/java/org/commonjava/lang/CompoundID.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- CompoundID.java 18 Sep 2003 01:10:42 -0000 1.1
+++ CompoundID.java 2 Feb 2004 02:20:35 -0000 1.2
@@ -17,12 +17,17 @@
package org.commonjava.lang;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
/** Container to wrapper identifiers that are made of multiple other identifiers.
* This is like a primary key that is actually two fields in a database.
*
* @author John Casey
*/
-public abstract class CompoundID extends AbstractID {
+public abstract class CompoundID extends AbstractID implements Serializable{
private AbstractID[] ids;
@@ -58,4 +63,21 @@
*/
public abstract int hashCode();
+ /** Deserailize the ids which compose this compound id instance.
+ *
+ */
+ protected void readObject(ObjectInputStream in)
+ throws IOException, ClassNotFoundException
+ {
+ this.ids = (AbstractID[])in.readObject();
+ }
+
+ /** Serailize the ids which compose this compound id instance.
+ *
+ */
+ protected void writeObject(ObjectOutputStream out)
+ throws IOException
+ {
+ out.writeObject(ids);
+ }
}
\ No newline at end of file
Index: AbstractID.java
===================================================================
RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-lang/src/java/org/commonjava/lang/AbstractID.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- AbstractID.java 18 Sep 2003 01:10:42 -0000 1.1
+++ AbstractID.java 2 Feb 2004 02:20:35 -0000 1.2
@@ -11,6 +11,9 @@
package org.commonjava.lang;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.io.Serializable;
/**
@@ -68,4 +71,21 @@
* @return Object a primitive type wrapper
*/
public abstract Object getValue();
+
+ /** Deserialize this abstract id implementation.
+ *
+ * @param in The input stream from which to deserialize
+ * @throws IOException in case of an error reading from the stream
+ * @throws ClassNotFoundException in case of an error instantiating any member variables.
+ */
+ protected abstract void readObject(ObjectInputStream in)
+ throws IOException, ClassNotFoundException;
+
+ /** Serialize this abstract id implementation.
+ *
+ * @param out the output stream to which this id should be serialized.
+ * @throws IOException in case of any errors writing to the output stream.
+ */
+ protected abstract void writeObject(ObjectOutputStream out)
+ throws IOException;
}
\ No newline at end of file
|