KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.eclipse.core.resources.IContainer;
14 import org.eclipse.core.resources.IResource;
15 import org.eclipse.team.core.TeamException;
16 import org.eclipse.team.core.variants.ResourceVariantByteStore;
17 import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
18
19
20 public class CVSBaseResourceVariantTree extends ResourceVariantByteStore {
21     public void dispose() {
22         // Do nothing
23
}
24     public byte[] getBytes(IResource resource) throws TeamException {
25         if (resource.getType() == IResource.FILE) {
26             // For a file, return the entry line
27
byte[] bytes = EclipseSynchronizer.getInstance().getSyncBytes(resource);
28             if (bytes != null) {
29                 // Use the base sync info (i.e. no deletion or addition)
30
if (ResourceSyncInfo.isDeletion(bytes)) {
31                     bytes = ResourceSyncInfo.convertFromDeletion(bytes);
32                 } else if (ResourceSyncInfo.isAddition(bytes)) {
33                     bytes = null;
34                 }
35             }
36             return bytes;
37         } else {
38             // For a folder, return the folder sync info bytes
39
FolderSyncInfo info = EclipseSynchronizer.getInstance().getFolderSync((IContainer)resource);
40             if (info == null) return null;
41             return info.getBytes();
42         }
43     }
44     public boolean isVariantKnown(IResource resource) throws TeamException {
45         return getBytes(resource) != null;
46     }
47     public boolean flushBytes(IResource resource, int depth) throws TeamException {
48         throw new UnsupportedOperationException JavaDoc();
49     }
50     public boolean setBytes(IResource resource, byte[] bytes) throws TeamException {
51         throw new UnsupportedOperationException JavaDoc();
52     }
53     public boolean deleteBytes(IResource resource) throws TeamException {
54         throw new UnsupportedOperationException JavaDoc();
55     }
56     
57     /* (non-Javadoc)
58      * @see org.eclipse.team.core.subscribers.utils.SynchronizationCache#members(org.eclipse.core.resources.IResource)
59      */

60     public IResource[] members(IResource resource) throws TeamException {
61         if(resource.getType() == IResource.FILE) {
62             return new IResource[0];
63         }
64         return EclipseSynchronizer.getInstance().members((IContainer)resource);
65     }
66 }
67
Popular Tags