KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > je > recovery > stepwise > TestData


1 /*
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2004,2006 Oracle. All rights reserved.
5  *
6  * $Id: TestData.java,v 1.4 2006/10/30 21:14:49 bostic Exp $
7  */

8 package com.sleepycat.je.recovery.stepwise;
9
10 import java.util.Arrays JavaDoc;
11
12 import com.sleepycat.bind.tuple.IntegerBinding;
13 import com.sleepycat.je.DatabaseEntry;
14
15 /**
16  * Wrapper class that encapsulates a record in a database used for recovery
17  * testing.
18  */

19 public class TestData {
20     private DatabaseEntry key;
21     private DatabaseEntry data;
22
23     public TestData(DatabaseEntry key, DatabaseEntry data) {
24         this.key = new DatabaseEntry(key.getData());
25         this.data = new DatabaseEntry(data.getData());
26     }
27
28     public boolean equals(Object JavaDoc o ) {
29         if (this == o)
30             return true;
31         if (!(o instanceof TestData))
32             return false;
33
34         TestData other = (TestData) o;
35         if (Arrays.equals(key.getData(), other.key.getData()) &&
36             Arrays.equals(data.getData(), other.data.getData())) {
37             return true;
38         } else
39             return false;
40     }
41
42     public String JavaDoc toString() {
43         return " k=" + IntegerBinding.entryToInt(key) +
44                 " d=" + IntegerBinding.entryToInt(data);
45     }
46
47     public int hashCode() {
48         return toString().hashCode();
49     }
50
51     public DatabaseEntry getKey() {
52         return key;
53     }
54
55     public DatabaseEntry getData() {
56         return data;
57     }
58 }
59
Popular Tags