KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > jdo > externalizer > Externalizer


1
2 /*
3  * Copyright (c) 1998 - 2005 Versant Corporation
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Versant Corporation - initial API and implementation
11  */

12 package com.versant.core.jdo.externalizer;
13
14 import javax.jdo.PersistenceManager;
15
16 /**
17  * Externalizers convert an object to/from some other object for storage. This
18  * is done when the object is stored/retrieved from the data store. The
19  * transformation takes place on the "client side" in the context of
20  * a PersistenceManager so references to PC instances can be converted
21  * into OIDs and so on.
22  * <p/>
23  * If the class implementing this Interface has a constructor that accepts
24  * a single Class argument then this will be invoked with the target field
25  * type. Throw an IllegalArgumentException if this type is not suitable.
26  * Otherwise the default constructor is used.
27  *
28  * @see SerializedExternalizer
29  * @see TypeAsBytesExternalizer
30  * @see TypeAsStringExternalizer
31  */

32 public interface Externalizer {
33
34     /**
35      * Convert to an object for storage.
36      */

37     public Object JavaDoc toExternalForm(PersistenceManager pm, Object JavaDoc o);
38
39     /**
40      * Create from an object read from storage.
41      */

42     public Object JavaDoc fromExternalForm(PersistenceManager pm, Object JavaDoc o);
43
44     /**
45      * Return the class that we convert to/from. This is used to decide
46      * how to map the field (e.g. what sort of database column to create).
47      */

48     public Class JavaDoc getExternalType();
49
50 }
51
Popular Tags