Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

TestSerial.java

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 2000-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: TestSerial.java,v 12.1 2005/01/31 19:27:36 mark Exp $
00008  */
00009 package com.sleepycat.collections.test.serial;
00010 
00014 class TestSerial implements java.io.Serializable {
00015 
00016     static final long serialVersionUID = -3738980000390384920L;
00017 
00018     private int i = 123;
00019     private TestSerial other;
00020 
00021     // The following field 's' was added after this class was compiled and
00022     // serialized instances were saved in resource files.  This allows testing
00023     // that the original stored instances can be deserialized after changing
00024     // the class.  The serialVersionUID is needed for this according to Java
00025     // serialization rules, and was generated with the serialver tool.
00026     //
00027     private String s = "string";
00028 
00029     TestSerial(TestSerial other) {
00030 
00031         this.other = other;
00032     }
00033 
00034     TestSerial getOther() {
00035 
00036         return other;
00037     }
00038 
00039     int getIntField() {
00040 
00041         return i;
00042     }
00043 
00044     String getStringField() {
00045 
00046         return s; // this returned null before field 's' was added.
00047     }
00048 
00049     public boolean equals(Object object) {
00050 
00051         try {
00052             TestSerial o = (TestSerial) object;
00053             if ((o.other == null) ? (this.other != null)
00054                                   : (!o.other.equals(this.other))) {
00055                 return false;
00056             }
00057             if (this.i != o.i) {
00058                 return false;
00059             }
00060             // the following test was not done before field 's' was added
00061             if ((o.s == null) ? (this.s != null)
00062                               : (!o.s.equals(this.s))) {
00063                 return false;
00064             }
00065             return true;
00066         } catch (ClassCastException e) {
00067             return false;
00068         }
00069     }
00070 }

Generated on Sun Dec 25 12:14:55 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2