662 lines
26 KiB
HTML
662 lines
26 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<!--NewPage-->
|
|
<HTML>
|
|
<HEAD>
|
|
<!-- Generated by javadoc (build 1.5.0) on Thu May 15 17:17:33 EDT 2008 -->
|
|
<TITLE>
|
|
Conversion (Oracle - Berkeley DB Java API)
|
|
</TITLE>
|
|
|
|
<META NAME="keywords" CONTENT="com.sleepycat.persist.evolve.Conversion interface">
|
|
|
|
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../style.css" TITLE="Style">
|
|
|
|
<SCRIPT type="text/javascript">
|
|
function windowTitle()
|
|
{
|
|
parent.document.title="Conversion (Oracle - Berkeley DB Java API)";
|
|
}
|
|
</SCRIPT>
|
|
<NOSCRIPT>
|
|
</NOSCRIPT>
|
|
|
|
</HEAD>
|
|
|
|
<BODY BGCOLOR="white" onload="windowTitle();">
|
|
|
|
|
|
<!-- ========= START OF TOP NAVBAR ======= -->
|
|
<A NAME="navbar_top"><!-- --></A>
|
|
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
|
|
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
|
|
<TR>
|
|
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
|
|
<A NAME="navbar_top_firstrow"><!-- --></A>
|
|
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
|
|
<TR ALIGN="center" VALIGN="top">
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Conversion.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
|
|
</TR>
|
|
</TABLE>
|
|
</TD>
|
|
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
|
|
<b>Berkeley DB</b><br><font size="-1"> version 4.7.25</font></EM>
|
|
</TD>
|
|
</TR>
|
|
|
|
<TR>
|
|
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
|
PREV CLASS
|
|
<A HREF="../../../../com/sleepycat/persist/evolve/Converter.html" title="class in com.sleepycat.persist.evolve"><B>NEXT CLASS</B></A></FONT></TD>
|
|
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
|
<A HREF="../../../../index.html?com/sleepycat/persist/evolve/Conversion.html" target="_top"><B>FRAMES</B></A>
|
|
<A HREF="Conversion.html" target="_top"><B>NO FRAMES</B></A>
|
|
<SCRIPT type="text/javascript">
|
|
<!--
|
|
if(window==top) {
|
|
document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
|
|
}
|
|
//-->
|
|
</SCRIPT>
|
|
<NOSCRIPT>
|
|
<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
|
|
</NOSCRIPT>
|
|
|
|
|
|
</FONT></TD>
|
|
</TR>
|
|
<TR>
|
|
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
|
SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD>
|
|
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
|
DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD>
|
|
</TR>
|
|
</TABLE>
|
|
<A NAME="skip-navbar_top"></A>
|
|
<!-- ========= END OF TOP NAVBAR ========= -->
|
|
|
|
<HR>
|
|
<!-- ======== START OF CLASS DATA ======== -->
|
|
<H2>
|
|
<FONT SIZE="-1">
|
|
com.sleepycat.persist.evolve</FONT>
|
|
<BR>
|
|
Interface Conversion</H2>
|
|
<DL>
|
|
<DT><B>All Superinterfaces:</B> <DD><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/io/Serializable.html" title="class or interface in java.io">Serializable</A></DD>
|
|
</DL>
|
|
<HR>
|
|
<DL>
|
|
<DT><PRE>public interface <B>Conversion</B><DT>extends <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/io/Serializable.html" title="class or interface in java.io">Serializable</A></DL>
|
|
</PRE>
|
|
|
|
<P>
|
|
Converts an old version of an object value to conform to the current class
|
|
or field definition.
|
|
|
|
<p>The <code>Conversion</code> interface is implemented by the user. A
|
|
<code>Conversion</code> instance is passed to the <A HREF="../../../../com/sleepycat/persist/evolve/Converter.html#Converter(java.lang.String, int, java.lang.String, com.sleepycat.persist.evolve.Conversion)"><CODE>Converter.Converter(java.lang.String, int, java.lang.String, com.sleepycat.persist.evolve.Conversion)</CODE></A>
|
|
constructor.</p>
|
|
|
|
<p>The <code>Conversion</code> interface extends <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/io/Serializable.html" title="class or interface in java.io"><CODE>Serializable</CODE></A> and the
|
|
<code>Conversion</code> instance is serialized for storage using standard Java
|
|
serialization. Normally, the <code>Conversion</code> class should only have
|
|
transient fields that are initialized in the <A HREF="../../../../com/sleepycat/persist/evolve/Conversion.html#initialize(com.sleepycat.persist.model.EntityModel)"><CODE>initialize(com.sleepycat.persist.model.EntityModel)</CODE></A> method.
|
|
While non-transient fields are allowed, care must be taken to only include
|
|
fields that are serializable and will not pull in large amounts of data.</p>
|
|
|
|
<p>When a class conversion is specified, two special considerations
|
|
apply:</p>
|
|
<ol>
|
|
<li>A class conversion is only applied when to instances of that class. The
|
|
conversion will not be applied when the class when it appears as a
|
|
superclass of the instance's class. In this case, a conversion for the
|
|
instance's class must also be specified.</li>
|
|
<li>Although field renaming (as well as all other changes) is handled by the
|
|
conversion method, a field Renamer is still needed when a secondary key
|
|
field is renamed and field Deleter is still needed when a secondary key
|
|
field is deleted. This is necessary for evolution of the metadata;
|
|
specifically, if the key name changes the database must be renamed and if
|
|
the key field is deleted the secondary database must be deleted.</li>
|
|
</ol>
|
|
|
|
<p>The <code>Conversion</code> class must implement the standard equals method.
|
|
See <A HREF="../../../../com/sleepycat/persist/evolve/Conversion.html#equals(java.lang.Object)"><CODE>equals(java.lang.Object)</CODE></A> for more information.</p>
|
|
|
|
<p>Conversions of simple types are generally simple. For example, a <code>String</code> field that contains only integer values can be easily converted to
|
|
an <code>int</code> field:</p>
|
|
<pre class="code">
|
|
// The old class. Version 0 is implied.
|
|
//
|
|
@Persistent
|
|
class Address {
|
|
String zipCode;
|
|
...
|
|
}
|
|
|
|
// The new class. A new version number must be assigned.
|
|
//
|
|
@Persistent(version=1)
|
|
class Address {
|
|
int zipCode;
|
|
...
|
|
}
|
|
|
|
// The conversion class.
|
|
//
|
|
class MyConversion1 implements Conversion {
|
|
|
|
public void initialize(EntityModel model) {
|
|
// No initialization needed.
|
|
}
|
|
|
|
public Object convert(Object fromValue) {
|
|
return Integer.valueOf((String) fromValue);
|
|
}
|
|
|
|
<code>@Override</code>
|
|
public boolean equals(Object o) {
|
|
return o instanceof MyConversion1;
|
|
}
|
|
}
|
|
|
|
// Create a field converter mutation.
|
|
//
|
|
Converter converter = new Converter(Address.class.getName(), 0,
|
|
"zipCode", new MyConversion1());
|
|
|
|
// Configure the converter as described <A HREF="../../../../com/sleepycat/persist/evolve/Mutations.html" title="class in com.sleepycat.persist.evolve"><CODE>here</CODE></A>.</pre>
|
|
|
|
<p>A conversion may perform arbitrary transformations on an object. For
|
|
example, a conversion may transform a single String address field into an
|
|
Address object containing four fields for street, city, state and zip
|
|
code.</p>
|
|
<pre class="code">
|
|
// The old class. Version 0 is implied.
|
|
//
|
|
@Entity
|
|
class Person {
|
|
String address;
|
|
...
|
|
}
|
|
|
|
// The new class. A new version number must be assigned.
|
|
//
|
|
@Entity(version=1)
|
|
class Person {
|
|
Address address;
|
|
...
|
|
}
|
|
|
|
// The new address class.
|
|
//
|
|
@Persistent
|
|
class Address {
|
|
String street;
|
|
String city;
|
|
String state;
|
|
int zipCode;
|
|
...
|
|
}
|
|
|
|
class MyConversion2 implements Conversion {
|
|
private transient RawType addressType;
|
|
|
|
public void initialize(EntityModel model) {
|
|
addressType = model.getRawType(Address.class.getName());
|
|
}
|
|
|
|
public Object convert(Object fromValue) {
|
|
|
|
// Parse the old address and populate the new address fields
|
|
//
|
|
String oldAddress = (String) fromValue;
|
|
Map<String,Object> addressValues = new HashMap<String,Object>();
|
|
addressValues.put("street", parseStreet(oldAddress));
|
|
addressValues.put("city", parseCity(oldAddress));
|
|
addressValues.put("state", parseState(oldAddress));
|
|
addressValues.put("zipCode", parseZipCode(oldAddress));
|
|
|
|
// Return new raw Address object
|
|
//
|
|
return new RawObject(addressType, addressValues, null);
|
|
}
|
|
|
|
<code>@Override</code>
|
|
public boolean equals(Object o) {
|
|
return o instanceof MyConversion2;
|
|
}
|
|
|
|
private String parseStreet(String oldAddress) { ... }
|
|
private String parseCity(String oldAddress) { ... }
|
|
private String parseState(String oldAddress) { ... }
|
|
private Integer parseZipCode(String oldAddress) { ... }
|
|
}
|
|
|
|
// Create a field converter mutation.
|
|
//
|
|
Converter converter = new Converter(Person.class.getName(), 0,
|
|
"address", new MyConversion2());
|
|
|
|
// Configure the converter as described <A HREF="../../../../com/sleepycat/persist/evolve/Mutations.html" title="class in com.sleepycat.persist.evolve"><CODE>here</CODE></A>.</pre>
|
|
|
|
<p>Note that when a conversion returns a <A HREF="../../../../com/sleepycat/persist/raw/RawObject.html" title="class in com.sleepycat.persist.raw"><CODE>RawObject</CODE></A>, it must return
|
|
it with a <A HREF="../../../../com/sleepycat/persist/raw/RawType.html" title="interface in com.sleepycat.persist.raw"><CODE>RawType</CODE></A> that is current as defined by the current class
|
|
definitions. The proper types can be obtained from the <A HREF="../../../../com/sleepycat/persist/model/EntityModel.html" title="class in com.sleepycat.persist.model"><CODE>EntityModel</CODE></A>
|
|
in the conversion's <A HREF="../../../../com/sleepycat/persist/evolve/Conversion.html#initialize(com.sleepycat.persist.model.EntityModel)"><CODE>initialize</CODE></A> method.</p>
|
|
|
|
<p>A variation on the example above is where several fields in a class
|
|
(street, city, state and zipCode) are converted to a single field (address).
|
|
In this case a class converter rather than a field converter is used.</p>
|
|
|
|
<pre class="code">
|
|
// The old class. Version 0 is implied.
|
|
//
|
|
@Entity
|
|
class Person {
|
|
String street;
|
|
String city;
|
|
String state;
|
|
int zipCode;
|
|
...
|
|
}
|
|
|
|
// The new class. A new version number must be assigned.
|
|
//
|
|
@Entity(version=1)
|
|
class Person {
|
|
Address address;
|
|
...
|
|
}
|
|
|
|
// The new address class.
|
|
//
|
|
@Persistent
|
|
class Address {
|
|
String street;
|
|
String city;
|
|
String state;
|
|
int zipCode;
|
|
...
|
|
}
|
|
|
|
class MyConversion3 implements Conversion {
|
|
private transient RawType newPersonType;
|
|
private transient RawType addressType;
|
|
|
|
public void initialize(EntityModel model) {
|
|
newPersonType = model.getRawType(Person.class.getName());
|
|
addressType = model.getRawType(Address.class.getName());
|
|
}
|
|
|
|
public Object convert(Object fromValue) {
|
|
|
|
// Get field value maps for old and new objects.
|
|
//
|
|
RawObject person = (RawObject) fromValue;
|
|
Map<String,Object> personValues = person.getValues();
|
|
Map<String,Object> addressValues = new HashMap<String,Object>();
|
|
RawObject address = new RawObject(addressType, addressValues, null);
|
|
|
|
// Remove the old address fields and insert the new one.
|
|
//
|
|
addressValues.put("street", personValues.remove("street"));
|
|
addressValues.put("city", personValues.remove("city"));
|
|
addressValues.put("state", personValues.remove("state"));
|
|
addressValues.put("zipCode", personValues.remove("zipCode"));
|
|
personValues.put("address", address);
|
|
|
|
return new RawObject(newPersonType, personValues, person.getSuper());
|
|
}
|
|
|
|
<code>@Override</code>
|
|
public boolean equals(Object o) {
|
|
return o instanceof MyConversion3;
|
|
}
|
|
}
|
|
|
|
// Create a class converter mutation.
|
|
//
|
|
Converter converter = new Converter(Person.class.getName(), 0,
|
|
new MyConversion3());
|
|
|
|
// Configure the converter as described <A HREF="../../../../com/sleepycat/persist/evolve/Mutations.html" title="class in com.sleepycat.persist.evolve"><CODE>here</CODE></A>.</pre>
|
|
|
|
|
|
<p>A conversion can also handle changes to class hierarchies. For example,
|
|
if a "name" field originally declared in class A is moved to its superclass
|
|
B, a conversion can move the field value accordingly:</p>
|
|
|
|
<pre class="code">
|
|
// The old classes. Version 0 is implied.
|
|
//
|
|
@Persistent
|
|
class A extends B {
|
|
String name;
|
|
...
|
|
}
|
|
@Persistent
|
|
abstract class B {
|
|
...
|
|
}
|
|
|
|
// The new classes. A new version number must be assigned.
|
|
//
|
|
@Persistent(version=1)
|
|
class A extends B {
|
|
...
|
|
}
|
|
@Persistent(version=1)
|
|
abstract class B {
|
|
String name;
|
|
...
|
|
}
|
|
|
|
class MyConversion4 implements Conversion {
|
|
private transient RawType newAType;
|
|
private transient RawType newBType;
|
|
|
|
public void initialize(EntityModel model) {
|
|
newAType = model.getRawType(A.class.getName());
|
|
newBType = model.getRawType(B.class.getName());
|
|
}
|
|
|
|
public Object convert(Object fromValue) {
|
|
RawObject oldA = (RawObject) fromValue;
|
|
RawObject oldB = oldA.getSuper();
|
|
Map<String,Object> aValues = oldA.getValues();
|
|
Map<String,Object> bValues = oldB.getValues();
|
|
bValues.put("name", aValues.remove("name"));
|
|
RawObject newB = new RawObject(newBType, bValues, oldB.getSuper());
|
|
RawObject newA = new RawObject(newAType, aValues, newB);
|
|
return newA;
|
|
}
|
|
|
|
<code>@Override</code>
|
|
public boolean equals(Object o) {
|
|
return o instanceof MyConversion4;
|
|
}
|
|
}
|
|
|
|
// Create a class converter mutation.
|
|
//
|
|
Converter converter = new Converter(A.class.getName(), 0,
|
|
new MyConversion4());
|
|
|
|
// Configure the converter as described <A HREF="../../../../com/sleepycat/persist/evolve/Mutations.html" title="class in com.sleepycat.persist.evolve"><CODE>here</CODE></A>.</pre>
|
|
|
|
<p>A conversion may return an instance of a different class entirely, as
|
|
long as it conforms to current class definitions and is the type expected
|
|
in the given context (a subtype of the old type, or a type compatible with
|
|
the new field type). For example, a field that is used to discriminate
|
|
between two types of objects could be removed and replaced by two new
|
|
subclasses:</p> <pre class="code">
|
|
// The old class. Version 0 is implied.
|
|
//
|
|
@Persistent
|
|
class Pet {
|
|
boolean isCatNotDog;
|
|
...
|
|
}
|
|
|
|
// The new classes. A new version number must be assigned to the Pet class.
|
|
//
|
|
@Persistent(version=1)
|
|
class Pet {
|
|
...
|
|
}
|
|
@Persistent
|
|
class Cat extends Pet {
|
|
...
|
|
}
|
|
@Persistent
|
|
class Dog extends Pet {
|
|
...
|
|
}
|
|
|
|
class MyConversion5 implements Conversion {
|
|
private transient RawType newPetType;
|
|
private transient RawType dogType;
|
|
private transient RawType catType;
|
|
|
|
public void initialize(EntityModel model) {
|
|
newPetType = model.getRawType(Pet.class.getName());
|
|
dogType = model.getRawType(Dog.class.getName());
|
|
catType = model.getRawType(Cat.class.getName());
|
|
}
|
|
|
|
public Object convert(Object fromValue) {
|
|
RawObject pet = (RawObject) fromValue;
|
|
Map<String,Object> petValues = pet.getValues();
|
|
Boolean isCat = (Boolean) petValues.remove("isCatNotDog");
|
|
RawObject newPet = new RawObject(newPetType, petValues,
|
|
pet.getSuper());
|
|
RawType newSubType = isCat ? catType : dogType;
|
|
return new RawObject(newSubType, Collections.emptyMap(), newPet);
|
|
}
|
|
|
|
<code>@Override</code>
|
|
public boolean equals(Object o) {
|
|
return o instanceof MyConversion5;
|
|
}
|
|
}
|
|
|
|
// Create a class converter mutation.
|
|
//
|
|
Converter converter = new Converter(Pet.class.getName(), 0,
|
|
new MyConversion5());
|
|
|
|
// Configure the converter as described <A HREF="../../../../com/sleepycat/persist/evolve/Mutations.html" title="class in com.sleepycat.persist.evolve"><CODE>here</CODE></A>.</pre>
|
|
|
|
<p>The primary limitation of a conversion is that it may access at most a
|
|
single entity instance at one time. Conversions involving multiple entities
|
|
at once may be made by performing a <a
|
|
href="package-summary.html#storeConversion">store conversion</a>.</p>
|
|
<P>
|
|
|
|
<P>
|
|
<DL>
|
|
<DT><B>See Also:</B><DD><A HREF="../../../../com/sleepycat/persist/evolve/package-summary.html"><CODE>Class Evolution</CODE></A></DL>
|
|
<HR>
|
|
|
|
<P>
|
|
|
|
<!-- ========== METHOD SUMMARY =========== -->
|
|
|
|
<A NAME="method_summary"><!-- --></A>
|
|
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
|
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
|
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
|
|
<B>Method Summary</B></FONT></TH>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A></CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../../com/sleepycat/persist/evolve/Conversion.html#convert(java.lang.Object)">convert</A></B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A> fromValue)</CODE>
|
|
|
|
<BR>
|
|
Converts an old version of an object value to conform to the current
|
|
class or field definition.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> boolean</CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../../com/sleepycat/persist/evolve/Conversion.html#equals(java.lang.Object)">equals</A></B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A> other)</CODE>
|
|
|
|
<BR>
|
|
The standard <code>equals</code> method that must be implemented by
|
|
conversion class.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> void</CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../../com/sleepycat/persist/evolve/Conversion.html#initialize(com.sleepycat.persist.model.EntityModel)">initialize</A></B>(<A HREF="../../../../com/sleepycat/persist/model/EntityModel.html" title="class in com.sleepycat.persist.model">EntityModel</A> model)</CODE>
|
|
|
|
<BR>
|
|
Initializes the conversion, allowing it to obtain raw type information
|
|
from the entity model.</TD>
|
|
</TR>
|
|
</TABLE>
|
|
|
|
<P>
|
|
|
|
<!-- ============ METHOD DETAIL ========== -->
|
|
|
|
<A NAME="method_detail"><!-- --></A>
|
|
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
|
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
|
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
|
|
<B>Method Detail</B></FONT></TH>
|
|
</TR>
|
|
</TABLE>
|
|
|
|
<A NAME="initialize(com.sleepycat.persist.model.EntityModel)"><!-- --></A><H3>
|
|
initialize</H3>
|
|
<PRE>
|
|
void <B>initialize</B>(<A HREF="../../../../com/sleepycat/persist/model/EntityModel.html" title="class in com.sleepycat.persist.model">EntityModel</A> model)</PRE>
|
|
<DL>
|
|
<DD>Initializes the conversion, allowing it to obtain raw type information
|
|
from the entity model.
|
|
<P>
|
|
<DD><DL>
|
|
</DL>
|
|
</DD>
|
|
<DD><DL>
|
|
</DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="convert(java.lang.Object)"><!-- --></A><H3>
|
|
convert</H3>
|
|
<PRE>
|
|
<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A> <B>convert</B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A> fromValue)</PRE>
|
|
<DL>
|
|
<DD>Converts an old version of an object value to conform to the current
|
|
class or field definition.
|
|
|
|
<p>If a <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/RuntimeException.html" title="class or interface in java.lang"><CODE>RuntimeException</CODE></A> is thrown by this method, it will be
|
|
thrown to the original caller. Similarly, a <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang"><CODE>IllegalArgumentException</CODE></A> will be thrown to the original caller if the
|
|
object returned by this method does not conform to current class
|
|
definitions.</p>
|
|
|
|
<p>The class of the input and output object may be one of the simple
|
|
types or <A HREF="../../../../com/sleepycat/persist/raw/RawObject.html" title="class in com.sleepycat.persist.raw"><CODE>RawObject</CODE></A>. For primitive types, the primitive wrapper
|
|
class is used.</p>
|
|
<P>
|
|
<DD><DL>
|
|
</DL>
|
|
</DD>
|
|
<DD><DL>
|
|
<DT><B>Parameters:</B><DD><CODE>fromValue</CODE> - the object value being converted. The type of this
|
|
value is defined by the old class version that is being converted.
|
|
<DT><B>Returns:</B><DD>the converted object. The type of this value must conform to
|
|
a current class definition. If this is a class conversion, it must
|
|
be the current version of the class. If this is a field conversion, it
|
|
must be of a type compatible with the current declared type of the
|
|
field.</DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="equals(java.lang.Object)"><!-- --></A><H3>
|
|
equals</H3>
|
|
<PRE>
|
|
boolean <B>equals</B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A> other)</PRE>
|
|
<DL>
|
|
<DD>The standard <code>equals</code> method that must be implemented by
|
|
conversion class.
|
|
|
|
<p>When mutations are specified when opening a store, the specified and
|
|
previously stored mutations are compared for equality. If they are
|
|
equal, there is no need to replace the existing mutations in the stored
|
|
catalog. To accurately determine equality, the conversion class must
|
|
implement the <code>equals</code> method.</p>
|
|
|
|
<p>If the <code>equals</code> method is not explicitly implemented by the
|
|
conversion class or a superclass other than <code>Object</code>, <code>IllegalArgumentException</code> will be thrown when the store is opened.</p>
|
|
|
|
<p>Normally whenever <code>equals</code> is implemented the <code>hashCode</code>
|
|
method should also be implemented to support hash sets and maps.
|
|
However, hash sets and maps containing <code>Conversion</code> objects
|
|
are not used by the DPL and therefore the DPL does not require
|
|
<code>hashCode</code> to be implemented.</p>
|
|
<P>
|
|
<DD><DL>
|
|
<DT><B>Overrides:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang">equals</A></CODE> in class <CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A></CODE></DL>
|
|
</DD>
|
|
<DD><DL>
|
|
</DL>
|
|
</DD>
|
|
</DL>
|
|
<!-- ========= END OF CLASS DATA ========= -->
|
|
<HR>
|
|
|
|
|
|
<!-- ======= START OF BOTTOM NAVBAR ====== -->
|
|
<A NAME="navbar_bottom"><!-- --></A>
|
|
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
|
|
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
|
|
<TR>
|
|
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
|
|
<A NAME="navbar_bottom_firstrow"><!-- --></A>
|
|
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
|
|
<TR ALIGN="center" VALIGN="top">
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Conversion.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
|
|
</TR>
|
|
</TABLE>
|
|
</TD>
|
|
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
|
|
<b>Berkeley DB</b><br><font size="-1"> version 4.7.25</font></EM>
|
|
</TD>
|
|
</TR>
|
|
|
|
<TR>
|
|
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
|
PREV CLASS
|
|
<A HREF="../../../../com/sleepycat/persist/evolve/Converter.html" title="class in com.sleepycat.persist.evolve"><B>NEXT CLASS</B></A></FONT></TD>
|
|
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
|
<A HREF="../../../../index.html?com/sleepycat/persist/evolve/Conversion.html" target="_top"><B>FRAMES</B></A>
|
|
<A HREF="Conversion.html" target="_top"><B>NO FRAMES</B></A>
|
|
<SCRIPT type="text/javascript">
|
|
<!--
|
|
if(window==top) {
|
|
document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
|
|
}
|
|
//-->
|
|
</SCRIPT>
|
|
<NOSCRIPT>
|
|
<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
|
|
</NOSCRIPT>
|
|
|
|
|
|
</FONT></TD>
|
|
</TR>
|
|
<TR>
|
|
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
|
SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD>
|
|
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
|
DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD>
|
|
</TR>
|
|
</TABLE>
|
|
<A NAME="skip-navbar_bottom"></A>
|
|
<!-- ======== END OF BOTTOM NAVBAR ======= -->
|
|
|
|
<HR>
|
|
<font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font>
|
|
</BODY>
|
|
</HTML>
|