KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > core > subscribers > ChangeSet


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.internal.core.subscribers;
12
13 import org.eclipse.core.resources.IResource;
14
15 /**
16  * A set that contains a group of related changes
17  */

18 public abstract class ChangeSet {
19     
20     private String JavaDoc name;
21
22     /**
23      * Create a change set with no name. Subclasses
24      * that create a change set in this manner should
25      * provide a name before the set is used by other clients.
26      */

27     protected ChangeSet() {
28         super();
29     }
30     
31     /**
32      * Create a change set with the given name.
33      * @param name the name of the change set
34      */

35     public ChangeSet(String JavaDoc name) {
36         this.name = name;
37     }
38
39     /**
40      * Return the resources that are contained in this set.
41      * @return the resources that are contained in this set
42      */

43     public abstract IResource[] getResources();
44     
45     /**
46      * Return whether the set contains any files.
47      * @return whether the set contains any files
48      */

49     public abstract boolean isEmpty();
50
51     /**
52      * Return true if the given file is included in this set.
53      * @param local a local file
54      * @return true if the given file is included in this set
55      */

56     public abstract boolean contains(IResource local);
57     
58     /**
59      * Remove the resource from the set.
60      * @param resource the resource to be removed
61      */

62     public abstract void remove(IResource resource);
63     
64     /**
65      * Remove the resources from the set.
66      * @param resources the resources to be removed
67      */

68     public void remove(IResource[] resources) {
69         for (int i = 0; i < resources.length; i++) {
70             IResource resource = resources[i];
71             remove(resource);
72         }
73     }
74     
75     /**
76      * Remove the resource and it's descendants to the given depth.
77      * @param resource the resource to be removed
78      * @param depth the depth of the removal (one of
79      * <code>IResource.DEPTH_ZERO, IResource.DEPTH_ONE, IResource.DEPTH_INFINITE)</code>
80      */

81     public abstract void rootRemoved(IResource resource, int depth);
82     
83     /**
84      * Return a comment describing the change.
85      * @return a comment describing the change
86      */

87     public abstract String JavaDoc getComment();
88
89     /**
90      * Return the name assigned to this set. The name should be
91      * unique.
92      * @return the name assigned to this set
93      */

94     public String JavaDoc getName() {
95         return name;
96     }
97
98     /**
99      * Set the name of the change set. The name of a change
100      * set can be changed but it is up to subclass to notify
101      * any interested partied of the name change.
102      * @param name the new name for the set
103      */

104     protected void setName(String JavaDoc name) {
105         this.name = name;
106     }
107
108     /**
109      * Return whether the set contains descendants of the given resource
110      * to the given depth.
111      * @param resource the resource
112      * @param depth the depth
113      * @return whether the set contains descendants of the given resource
114      * to the given depth
115      */

116     public abstract boolean containsChildren(IResource resource, int depth);
117 }
118
Popular Tags