| 1 |
/*- |
| 2 |
* See the file LICENSE for redistribution information. |
| 3 |
* |
| 4 |
* Copyright (c) 2002, 2013 Oracle and/or its affiliates. All rights reserved. |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
package com.sleepycat.persist.impl; |
| 9 |
|
| 10 |
import java.math.BigDecimal; |
| 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 |
throws RefreshException; |
| 38 |
|
| 39 |
/** |
| 40 |
* Called for a primary key field or composite key field with a reference |
| 41 |
* type. |
| 42 |
*/ |
| 43 |
void writeKeyObject(Object o, Format fieldFormat) |
| 44 |
throws RefreshException; |
| 45 |
|
| 46 |
/** |
| 47 |
* Called via Accessor.writeSecKeyFields for a primary key field with a |
| 48 |
* reference type. This method must be called before writing any other |
| 49 |
* fields. |
| 50 |
*/ |
| 51 |
void registerPriKeyObject(Object o); |
| 52 |
|
| 53 |
/** |
| 54 |
* Called by ObjectArrayFormat and PrimitiveArrayFormat to write the array |
| 55 |
* length. |
| 56 |
*/ |
| 57 |
void writeArrayLength(int length); |
| 58 |
|
| 59 |
/** |
| 60 |
* Called by EnumFormat to write the given index of the enum constant. |
| 61 |
*/ |
| 62 |
void writeEnumConstant(String[] names, int index); |
| 63 |
|
| 64 |
/* The following methods are a subset of the methods in TupleOutput. */ |
| 65 |
|
| 66 |
TupleOutput writeString(String val); |
| 67 |
TupleOutput writeChar(int val); |
| 68 |
TupleOutput writeBoolean(boolean val); |
| 69 |
TupleOutput writeByte(int val); |
| 70 |
TupleOutput writeShort(int val); |
| 71 |
TupleOutput writeInt(int val); |
| 72 |
TupleOutput writeLong(long val); |
| 73 |
TupleOutput writeSortedFloat(float val); |
| 74 |
TupleOutput writeSortedDouble(double val); |
| 75 |
TupleOutput writeBigInteger(BigInteger val); |
| 76 |
TupleOutput writeSortedBigDecimal(BigDecimal val); |
| 77 |
} |