KickJava   Java API By Example, From Geeks To Geeks.

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


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.util.HashMap JavaDoc;
14
15 /**
16  * A patch configuration allows clients to set parameters that control how a patch
17  * is applied.
18  * <p>
19  * This class may be instantiated by clients but is not intended to be subclassed.
20  * </p>
21  * @see IFilePatch
22  * @since 3.3
23  */

24 public class PatchConfiguration {
25
26     private int fStripPrefixSegments;
27     private int fFuzz;
28     private boolean fIgnoreWhitespace= false;
29     private boolean fReverse= false;
30     private HashMap JavaDoc properties = new HashMap JavaDoc();
31
32     /**
33      * Return whether the patch should be reversed when applied.
34      * @return whether the patch should be reversed when applied
35      */

36     public boolean isReversed() {
37         return fReverse;
38     }
39
40     /**
41      * Set whether the patch should be reversed when applied.
42      * @param reversed whether the patch should be reversed when applied
43      */

44     public void setReversed(boolean reversed) {
45         this.fReverse = reversed;
46     }
47
48     /**
49      * Return the number of prefix segments to be stripped when attempting
50      * to apply a patch.
51      * @return the number of prefix segments to be stripped when attempting
52      * to apply a patch
53      */

54     public int getPrefixSegmentStripCount() {
55         return fStripPrefixSegments;
56     }
57
58     /**
59      * Set the number of prefix segments to be stripped when attempting
60      * to apply a patch.
61      * @param stripCount the number of prefix segments to be stripped when attempting
62      * to apply a patch.
63      */

64     public void setPrefixSegmentStripCount(int stripCount) {
65         this.fStripPrefixSegments = stripCount;
66     }
67
68     /**
69      * Return the fuzz factor to be used when applying a patch.
70      * If the fuzz factor is set to -1, then the patcher is to make a best
71      * effort to apply the patch by adjusting the fuzz factor
72      * accordingly.
73      * @return the fuzz factor to be used when applying a patch.
74      */

75     public int getFuzz() {
76         return fFuzz;
77     }
78     
79     /**
80      * Set the fuzz factor to be used when applying a patch.
81      * @param fuzz the fuzz factor to be used when applying a patch.
82      */

83     public void setFuzz(int fuzz) {
84         fFuzz = fuzz;
85     }
86
87     /**
88      * Return whether whitespace should be ignored.
89      * @return whether whitespace should be ignored
90      */

91     public boolean isIgnoreWhitespace() {
92         return fIgnoreWhitespace;
93     }
94     
95     /**
96      * Set whether whitespace should be ignored
97      * @param ignoreWhitespace whether whitespace should be ignored
98      */

99     public void setIgnoreWhitespace(boolean ignoreWhitespace) {
100         fIgnoreWhitespace = ignoreWhitespace;
101     }
102     
103     /**
104      * Return the property associated with the given key or
105      * <code>null</code> if there is no property for the key.
106      * @param key the key
107      * @return the property associated with the given key or
108      * <code>null</code>
109      */

110     public Object JavaDoc getProperty(String JavaDoc key) {
111         return properties.get(key);
112     }
113     
114     /**
115      * Set the property associated with the given key
116      * @param key the key
117      * @param value the value to be associated with the key
118      */

119     public void setProperty(String JavaDoc key, Object JavaDoc value) {
120         properties.put(key, value);
121     }
122 }
123
Popular Tags