1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2002,2008 Oracle.  All rights reserved.
5 *
6 * $Id: EntityOutput.java,v 1.1 2008/02/07 17:12:27 mark Exp $
7 */
8
9package com.sleepycat.persist.impl;
10
11import java.math.BigInteger;
12
13import 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 */
29public 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    TupleOutput writeChar(int val);
66    TupleOutput writeBoolean(boolean val);
67    TupleOutput writeByte(int val);
68    TupleOutput writeShort(int val);
69    TupleOutput writeInt(int val);
70    TupleOutput writeLong(long val);
71    TupleOutput writeSortedFloat(float val);
72    TupleOutput writeSortedDouble(double val);
73    TupleOutput writeBigInteger(BigInteger val);
74}
75