KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > core > mapping > IStorageMerger


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

11 package org.eclipse.team.core.mapping;
12
13 import java.io.OutputStream JavaDoc;
14
15 import org.eclipse.core.resources.IEncodedStorage;
16 import org.eclipse.core.resources.IStorage;
17 import org.eclipse.core.runtime.*;
18
19 /**
20  * This interface defines a single operation for performing a three-way merge on three
21  * instances of {@link IStorage}. The merged result is written to an output stream.
22  * <p>
23  * Clients must implement this interface when contributing new mergers to the
24  * <code>org.eclipse.team.core.storageMergers</code> extension point.
25  * </p>
26  *
27  * @since 3.2
28  */

29 public interface IStorageMerger {
30
31     /**
32      * Indicates the successful completion of the merge operation (value <code>IStatus.OK</code>)
33      */

34     public static final int OK= IStatus.OK;
35     
36     /**
37      * Indicates that a change conflict prevented the merge from successful completion (value <code>1</code>)
38      */

39     public static final int CONFLICT= 1;
40     
41     /**
42      * Status code describing an internal error (value <code>2</code>)
43      */

44     public static final int INTERNAL_ERROR= 2;
45     
46     /**
47      * Indicates that at least one of the encodings associated with the input was unsupported (value <code>3</code>)
48      */

49     public static final int UNSUPPORTED_ENCODING= 3;
50    
51    /**
52     * Performs a merge operation on the given storage instances and writes the merge result to the output stream.
53     * On success a status <code>IStatus.OK</code> is returned, on error a status <code>IStatus.ERROR</code>.
54     * If the merge operation cannot deal with conflicts, the code of the error status has the value <code>IStreamMerger.CONFLICT</code>.
55     * For text oriented mergers the encoding for the input and output is honored if they implement
56     * {@link IEncodedStorage}.
57     * It is the responsibility of callers to close the output stream.
58     * <p>
59     * The provided ancestor may be <code>null</code> if this merger
60     * returns <code>true</code> from {@link #canMergeWithoutAncestor()}.
61     *
62     * @param output the byte stream to which the merge result is written; the merger will not close the stream
63     * @param outputEncoding the encoding to use when writing to the output stream
64     * @param ancestor the storage from which the common ancestor is read
65     * @param target the storage containing the target of the merge
66     * @param other the storage containing the target of the merge
67     * @param monitor reports progress of the merge operation
68     * @return returns the completion status of the operation
69     * @throws CoreException if an error occurs
70     */

71     IStatus merge(OutputStream JavaDoc output, String JavaDoc outputEncoding,
72             IStorage ancestor, IStorage target, IStorage other,
73             IProgressMonitor monitor) throws CoreException;
74     
75     /**
76      * Return whether this merger can merge the two contributors
77      * without an ancestor. Thsi is typically not possible but may be
78      * for some file types (for instances, files that contain a
79      * timestamp based list of events).
80      * @return whether this merger can merge the two contributors
81      * without an ancestor
82      */

83     boolean canMergeWithoutAncestor();
84    
85 }
86
Popular Tags