KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > applications > xmlimporter > ObjectMerger


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.applications.xmlimporter;
11
12 import java.util.*;
13
14 /**
15  * This interface provides methods to customize the way objects
16  * are merged in a temporary cloud.
17  *
18  * @author Rob van Maris: Finalist IT Group
19  * @since MMBase-1.5
20  * @version $Id: ObjectMerger.java,v 1.4 2003/03/07 08:50:02 pierre Exp $
21  */

22 public interface ObjectMerger {
23
24     /**
25      * Initialize this instance (called once per transaction).
26      * @param params The initialization parameters, provided as
27      * name/value pairs (both String).
28      * @throws TransactionHandlerException if a failure occurred.
29      */

30     public void init(HashMap params) throws TransactionHandlerException;
31
32     /**
33      * Merges a field.
34      * @param tmpObj1 The first object to be merged. This will hold
35      * the resulting merged object afterwards.
36      * @param tmpObj2 The second object. this object must be deleted
37      * afterwards.
38      * @param name The name of the field.
39      * (Note: "number" and "owner" are not considered fields in this context,
40      * so this method will not be called with these values for name.)
41      */

42     public void mergeField(TmpObject tmpObj1, TmpObject tmpObj2, String JavaDoc name);
43
44     /**
45      * Merges relations.
46      * @param tmpObj1 The first object to be merged. This will hold
47      * the resulting merged object afterwards.
48      * @param tmpObj2 The second object. this object must be deleted
49      * afterwards.
50      * @param relations1 List of all relations of the first
51      * object (as TmpObject instances).
52      * @param relations2 List of all relations of the second
53      * object (as TmpObject instances).
54      */

55     public void mergeRelations(TmpObject tmpObj1, TmpObject tmpObj2,
56         List relations1, List relations2);
57
58     /**
59      * Tests if two relations should be considered duplicates,
60      * indicating that one of them must be disposed of.
61      * This test will only be called for pairs of relations that
62      * have already been verified to be of the same type, and have the
63      * same source and destination.
64      * This method may provide additional tests.
65      * @param relation1 The first relation.
66      * @param relation2 The second relation.
67      * @return true if these relations should be considered duplicates.
68      */

69     public boolean areDuplicates(TmpObject relation1, TmpObject relation2);
70
71     /**
72      * Tests if this object should be added to the persistent cloud
73      * when not present already.
74      * When this returns false, the object will be deleted from the
75      * transaction if no object is found to merge it with.
76      * @param tmpObj The object.
77      * @return true If this object should be added, when not present already.
78      */

79     public boolean isAllowedToAdd(TmpObject tmpObj);
80
81 }
Popular Tags