01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2002,2008 Oracle. All rights reserved.
05: *
06: * $Id: EntityOutput.java,v 1.13.2.3 2008/01/07 15:14:19 cwl Exp $
07: */
08:
09: package com.sleepycat.persist.impl;
10:
11: import java.math.BigInteger;
12:
13: import com.sleepycat.bind.tuple.TupleOutput;
14:
15: /**
16: * Used for writing object fields.
17: *
18: * <p>Unlike TupleOutput, Strings should be passed to {@link #writeObject} when
19: * using this class.</p>
20: *
21: * <p>Note that currently there is only one implementation of EntityOutput:
22: * RecordOutput. There is no RawObjectOutput implemention because we currently
23: * have no need to convert from persistent objects to RawObject instances.
24: * The EntityOutput interface is only for symmetry with EntityInput and in case
25: * we need RawObjectOutput in the future.</p>
26: *
27: * @author Mark Hayes
28: */
29: public interface EntityOutput {
30:
31: /**
32: * Called via Accessor to write all fields with reference types, except for
33: * the primary key field and composite key fields (see writeKeyObject
34: * below).
35: */
36: void writeObject(Object o, Format fieldFormat);
37:
38: /**
39: * Called for a primary key field or composite key field with a reference
40: * type.
41: */
42: void writeKeyObject(Object o, Format fieldFormat);
43:
44: /**
45: * Called via Accessor.writeSecKeyFields for a primary key field with a
46: * reference type. This method must be called before writing any other
47: * fields.
48: */
49: void registerPriKeyObject(Object o);
50:
51: /**
52: * Called by ObjectArrayFormat and PrimitiveArrayFormat to write the array
53: * length.
54: */
55: void writeArrayLength(int length);
56:
57: /**
58: * Called by EnumFormat to write the given index of the enum constant.
59: */
60: void writeEnumConstant(String[] names, int index);
61:
62: /* The following methods are a subset of the methods in TupleOutput. */
63:
64: TupleOutput writeString(String val);
65:
66: TupleOutput writeChar(int val);
67:
68: TupleOutput writeBoolean(boolean val);
69:
70: TupleOutput writeByte(int val);
71:
72: TupleOutput writeShort(int val);
73:
74: TupleOutput writeInt(int val);
75:
76: TupleOutput writeLong(long val);
77:
78: TupleOutput writeSortedFloat(float val);
79:
80: TupleOutput writeSortedDouble(double val);
81:
82: TupleOutput writeBigInteger(BigInteger val);
83: }
|