01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2002,2008 Oracle. All rights reserved.
05: *
06: * $Id: EvolveConfig.java,v 1.6.2.2 2008/01/07 15:14:19 cwl Exp $
07: */
08:
09: package com.sleepycat.persist.evolve;
10:
11: import java.util.Collections;
12: import java.util.HashSet;
13: import java.util.Set;
14:
15: import com.sleepycat.persist.EntityStore;
16:
17: /**
18: * Configuration properties for eager conversion of unevolved objects. This
19: * configuration is used with {@link EntityStore#evolve EntityStore.evolve}.
20: *
21: * @see com.sleepycat.persist.evolve Class Evolution
22: * @author Mark Hayes
23: */
24: public class EvolveConfig implements Cloneable {
25:
26: private Set<String> classesToEvolve;
27: private EvolveListener listener;
28:
29: /**
30: * Creates an evolve configuration with default properties.
31: */
32: public EvolveConfig() {
33: classesToEvolve = new HashSet<String>();
34: }
35:
36: /**
37: * Returns a shallow copy of the configuration.
38: */
39: public EvolveConfig cloneConfig() {
40: try {
41: return (EvolveConfig) clone();
42: } catch (CloneNotSupportedException cannotHappen) {
43: return null;
44: }
45: }
46:
47: /**
48: * Adds an entity class for a primary index to be converted. If no classes
49: * are added, all indexes that require evolution will be converted.
50: */
51: public void addClassToEvolve(String entityClass) {
52: classesToEvolve.add(entityClass);
53: }
54:
55: /**
56: * Returns an unmodifiable set of the entity classes to be evolved.
57: */
58: public Set<String> getClassesToEvolve() {
59: return Collections.unmodifiableSet(classesToEvolve);
60: }
61:
62: /**
63: * Sets a progress listener that is notified each time an entity is read.
64: */
65: public void setEvolveListener(EvolveListener listener) {
66: this .listener = listener;
67: }
68:
69: /**
70: * Returns the progress listener that is notified each time an entity is
71: * read.
72: */
73: public EvolveListener getEvolveListener() {
74: return listener;
75: }
76: }
|