KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > compare > patch > IFilePatchResult


1 /*******************************************************************************
2  * Copyright (c) 2007 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.compare.patch;
12
13 import java.io.InputStream JavaDoc;
14
15 import org.eclipse.core.resources.IEncodedStorage;
16 import org.eclipse.core.runtime.CoreException;
17
18 /**
19  * A file patch result provides the results of an attempt to apply an
20  * {@link IFilePatch} to the contents of a file. *
21  * <p>
22  * This interface is not intended to be implemented by clients. Clients can
23  * obtain patch results from an {@link IFilePatch}.
24  * </p>
25  *
26  * @see IFilePatch
27  * @since 3.3
28  */

29 public interface IFilePatchResult {
30     
31     /**
32      * Return a stream the contains the original contents of the file before
33      * any portions of the patch have been applied.
34      * @return a stream to the original contents of the file before
35      * any portions of the patch have been applied
36      * @see #getPatchedContents()
37      */

38     public InputStream JavaDoc getOriginalContents();
39     
40     /**
41      * Return a stream that contains the file with as much of the patch
42      * applied as possible. if {@link #hasMatches()} returns <code>false</code>
43      * then the patched contents will match the original contents. Otherwise,
44      * at least a portion of the patch could be successfully applied. if
45      * {@link #hasRejects()} returns <code>false</code>, then the entire patch was
46      * applied. Otherwise, portions could not be applied. The portions that could
47      * not be applied can be obtained by calling {@link #getRejects()}.
48      *
49      * @return a stream that contains the file with as much of the patch
50      * applied as possible.
51      */

52     public InputStream JavaDoc getPatchedContents();
53     
54     /**
55      * Return whether the patch has portions that were successfully applied.
56      * @return whether the patch has portions that were successfully applied
57      * @see #getPatchedContents()
58      */

59     public boolean hasMatches();
60     
61     /**
62      * Return whether the patch has portions that were not successfully applied.
63      * @return whether the patch has portions that were not successfully applied
64      * @see #getPatchedContents()
65      */

66     public boolean hasRejects();
67     
68     /**
69      * Return the portions of the patch (referred to a hunks) that could not
70      * be applied.
71      * @return the portions of the patch (referred to a hunks) that could not
72      * be applied
73      * @see #getPatchedContents()
74      */

75     public IHunk[] getRejects();
76     
77     /**
78      * Returns the name of a charset encoding to be used when decoding the contents
79      * of this result into characters. Returns <code>null</code> if a proper
80      * encoding cannot be determined.
81      * <p>
82      * Note that this method does not check whether the result is a supported
83      * charset name. Callers should be prepared to handle
84      * <code>UnsupportedEncodingException</code> where this charset is used.
85      * </p>
86      *
87      * @return the name of a charset, or <code>null</code>
88      * @exception CoreException if an error happens while determining
89      * the charset. See any refinements for more information.
90      * @see IEncodedStorage
91      */

92     public String JavaDoc getCharset() throws CoreException;
93
94 }
95
Popular Tags