1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2002,2008 Oracle.  All rights reserved.
5 *
6 * $Id: Enhanced3.java,v 1.1 2008/02/07 17:12:32 mark Exp $
7 */
8
9package com.sleepycat.persist.test;
10
11/*
12import java.math.BigIngeter;
13import java.math.BigDecimal;
14*/
15import java.util.Date;
16
17import com.sleepycat.persist.impl.Enhanced;
18import com.sleepycat.persist.impl.EnhancedAccessor;
19import com.sleepycat.persist.impl.EntityInput;
20import com.sleepycat.persist.impl.EntityOutput;
21import com.sleepycat.persist.impl.Format;
22import com.sleepycat.persist.model.KeyField;
23import com.sleepycat.persist.model.Persistent;
24
25/**
26 * For running ASMifier -- a composite key class using all simple data types,
27 * does not follow from previous EnhancedN.java files
28 */
29@Persistent
30class Enhanced3 implements Enhanced {
31
32    @KeyField(1) boolean z;
33    @KeyField(2) char c;
34    @KeyField(3) byte b;
35    @KeyField(4) short s;
36    @KeyField(5) int i;
37    @KeyField(6) long l;
38    @KeyField(7) float f;
39    @KeyField(8) double d;
40
41    @KeyField(9) Boolean zw;
42    @KeyField(10) Character cw;
43    @KeyField(11) Byte bw;
44    @KeyField(12) Short sw;
45    @KeyField(13) Integer iw;
46    @KeyField(14) Long lw;
47    @KeyField(15) Float fw;
48    @KeyField(16) Double dw;
49
50    @KeyField(17) Date date;
51    @KeyField(18) String str;
52    /*
53    @KeyField(19) BigIngeter bigint;
54    @KeyField(20) BigDecimal bigdec;
55    */
56
57    static {
58        EnhancedAccessor.registerClass(null, new Enhanced3());
59    }
60
61    public Object bdbNewInstance() {
62        return new Enhanced3();
63    }
64
65    public Object bdbNewArray(int len) {
66        return new Enhanced3[len];
67    }
68
69    public boolean bdbIsPriKeyFieldNullOrZero() {
70        return false;
71    }
72
73    public void bdbWritePriKeyField(EntityOutput output, Format format) {
74    }
75
76    public void bdbReadPriKeyField(EntityInput input, Format format) {
77    }
78
79    public void bdbWriteSecKeyFields(EntityOutput output) {
80    }
81
82    public void bdbReadSecKeyFields(EntityInput input,
83                                    int startField,
84                                    int endField,
85                                    int superLevel) {
86    }
87
88    public void bdbWriteNonKeyFields(EntityOutput output) {
89        output.writeBoolean(z);
90        output.writeChar(c);
91        output.writeByte(b);
92        output.writeShort(s);
93        output.writeInt(i);
94        output.writeLong(l);
95        output.writeSortedFloat(f);
96        output.writeSortedDouble(d);
97
98        output.writeBoolean(zw.booleanValue());
99        output.writeChar(cw.charValue());
100        output.writeByte(bw.byteValue());
101        output.writeShort(sw.shortValue());
102        output.writeInt(iw.intValue());
103        output.writeLong(lw.longValue());
104        output.writeSortedFloat(fw.floatValue());
105        output.writeSortedDouble(dw.doubleValue());
106
107        output.writeLong(date.getTime());
108        output.writeString(str);
109    }
110
111    public void bdbReadNonKeyFields(EntityInput input,
112                                    int startField,
113                                    int endField,
114                                    int superLevel) {
115        z = input.readBoolean();
116        c = input.readChar();
117        b = input.readByte();
118        s = input.readShort();
119        i = input.readInt();
120        l = input.readLong();
121        f = input.readSortedFloat();
122        d = input.readSortedDouble();
123
124        zw = Boolean.valueOf(input.readBoolean());
125        cw = Character.valueOf(input.readChar());
126        bw = Byte.valueOf(input.readByte());
127        sw = Short.valueOf(input.readShort());
128        iw = Integer.valueOf(input.readInt());
129        lw = Long.valueOf(input.readLong());
130        fw = Float.valueOf(input.readSortedFloat());
131        dw = Double.valueOf(input.readSortedDouble());
132
133        date = new Date(input.readLong());
134        str = input.readString();
135    }
136
137    public boolean bdbNullifyKeyField(Object o,
138                                      int field,
139                                      int superLevel,
140                                      boolean isSecField,
141                                      Object keyElement) {
142        // Didn't bother with this one.
143        return false;
144    }
145
146    public Object bdbGetField(Object o,
147                              int field,
148                              int superLevel,
149                              boolean isSecField) {
150        // Didn't bother with this one.
151        return null;
152    }
153
154    public void bdbSetField(Object o,
155                            int field,
156                            int superLevel,
157                            boolean isSecField,
158                            Object value) {
159        // Didn't bother with this one.
160    }
161}
162