KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > core > syncinfo > MutableResourceSyncInfo


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.ccvs.core.syncinfo;
12
13 import java.util.Date JavaDoc;
14
15 import org.eclipse.core.runtime.Assert;
16 import org.eclipse.team.internal.ccvs.core.CVSException;
17 import org.eclipse.team.internal.ccvs.core.CVSTag;
18 import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
19
20 /**
21  * Mutable version of ResourceSyncInfo. Can be used when either creating a resource sync
22  * object from scratch (e.g. without an entry line) or want to modify an existing
23  * <code>ResourceSyncInfo</code> instance. Example usage:
24  * <pre>
25  * ResourceSyncInfo info = resource.getSyncInfo();
26  * if(info!=null) {
27  * MutableResourceSyncInfo newInfo = info.cloneMutable();
28  * newInfo.setRevision("1.22");
29  * resource.setSyncInfo(newInfo);
30  * }
31  * </pre>
32  * @see ResourceSyncInfo
33  */

34 public class MutableResourceSyncInfo extends ResourceSyncInfo {
35     
36     protected MutableResourceSyncInfo(ResourceSyncInfo info) {
37         this.name = info.getName();
38         setRevision(info.getRevision());
39         setTag(info.getTag());
40         this.timeStamp = info.getTimeStamp();
41         this.isDirectory = info.isDirectory();
42         this.keywordMode = info.getKeywordMode();
43         this.isDeleted = info.isDeleted();
44         if(info.isMergedWithConflicts()) {
45             setSyncType(TYPE_MERGED_WITH_CONFLICTS);
46         } else if(info.isMerged()) {
47             setSyncType(TYPE_MERGED);
48         } else {
49             setSyncType(TYPE_REGULAR);
50         }
51     }
52     
53     /**
54      * Creates a default sync info, if revision is <code>null</code> then
55      * the sync info will be considered in the newly added state.
56      */

57     public MutableResourceSyncInfo(String JavaDoc name, String JavaDoc revision) {
58         Assert.isNotNull(name);
59         this.name = name;
60         setRevision(revision);
61     }
62     
63     /**
64      * Sets the revision.
65      * @param revision The revision to set
66      */

67     public void setRevision(String JavaDoc revision) {
68         super.setRevision(revision);
69     }
70     
71     /**
72      * Sets the timeStamp.
73      * @param timeStamp The timeStamp to set
74      */

75     public void setTimeStamp(Date JavaDoc timeStamp) {
76         this.timeStamp = timeStamp;
77     }
78     
79     /**
80      * Sets the timeStamp.
81      * @param timeStamp The timeStamp to set
82      */

83     public void setTimeStamp(Date JavaDoc timeStamp, boolean clearMerged) {
84         setTimeStamp(timeStamp);
85         if (clearMerged) setSyncType(TYPE_REGULAR);
86     }
87     
88     /**
89      * Sets the keywordMode.
90      * @param keywordMode The keywordMode to set
91      */

92     public void setKeywordMode(KSubstOption keywordMode) {
93         this.keywordMode = keywordMode;
94     }
95
96     /**
97      * Sets the tag.
98      * @param tag The tag to set
99      */

100     public void setTag(CVSTag tag) {
101         super.setTag(tag);
102     }
103     
104     /**
105      * Sets the deleted state.
106      * @param isDeleted The deleted state of this resource sync
107      */

108     public void setDeleted(boolean isDeleted) {
109         this.isDeleted = isDeleted;;
110     }
111     
112     /**
113      * Sets to the added state. The timestamp and other are cleared.
114      */

115     public void setAdded() {
116         setRevision(ADDED_REVISION);
117     }
118     
119     /**
120      * Sets that this resource sync is a result of a non-conflicting merge
121      */

122     public void setMerged() {
123         // if already merged state then ignore
124
if(syncType==TYPE_REGULAR) {
125             this.syncType = TYPE_MERGED;
126         }
127     }
128     
129     /**
130      * @see org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo#setEntryLine(java.lang.String)
131      */

132     public void setEntryLine(String JavaDoc entryLine) throws CVSException {
133         super.setEntryLine(entryLine);
134     }
135 }
136
Popular Tags