Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * See the file LICENSE for redistribution information.
   * Copyright (c) 2002, 2013 Oracle and/or its affiliates.  All rights reserved.
  package com.sleepycat.persist.evolve;
A mutation for converting an old version of an object value to conform to the current class or field definition. For example:
  package my.package;

  // The old class.  Version 0 is implied.
  class Person {
      // ...

  // The new class.  A new version number must be assigned.
  class Person {
      // Incompatible changes were made here...

  // Add a converter mutation.
  Mutations mutations = new Mutations();

  mutations.addConverter(new Converter(Person.class.getName(), 0,
                                       new MyConversion()));

  // Configure the mutations as described here.

See Conversion for more information.

Mark Hayes
See also:
com.sleepycat.persist.evolve Class Evolution
 public class Converter extends Mutation {
     private static final long serialVersionUID = 4558176842096181863L;
     private Conversion conversion;

Creates a mutation for converting all instances of the given class version to the current version of the class.
     public Converter(String className,
                      int classVersion,
                      Conversion conversion) {

Creates a mutation for converting all values of the given field in the given class version to a type compatible with the current declared type of the field.
     public Converter(String declaringClassName,
                      int declaringClassVersion,
                      String fieldName,
                      Conversion conversion) {
         this. = conversion;
         /* Require explicit implementation of the equals method. */
         Class cls = conversion.getClass();
         try {
             Method m = cls.getMethod("equals"Object.class);
             if (m.getDeclaringClass() == Object.class) {
                 throw new IllegalArgumentException
                     ("Conversion class does not implement the equals method " +
                      "explicitly (Object.equals is not sufficient): " +
         } catch (NoSuchMethodException e) {
             throw DbCompat.unexpectedException(e);

Returns the converter instance specified to the constructor.
     public Conversion getConversion() {
         return ;

Returns true if the conversion objects are equal in this object and given object, and if the Mutation.equals(java.lang.Object) superclass method returns true.
    public boolean equals(Object other) {
        if (other instanceof Converter) {
            Converter o = (Converterother;
            return .equals(o.conversion) &&
        } else {
            return false;
    public int hashCode() {
        return .hashCode() + super.hashCode();
    public String toString() {
        return "[Converter " + super.toString() +
               " Conversion: " +  + ']';
New to GrepCode? Check out our FAQ X