KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > core > resources > SyncInfoCache


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.resources;
12
13 import org.eclipse.core.resources.IContainer;
14 import org.eclipse.core.resources.IResource;
15 import org.eclipse.core.runtime.IStatus;
16 import org.eclipse.core.runtime.QualifiedName;
17 import org.eclipse.core.runtime.Status;
18 import org.eclipse.team.internal.ccvs.core.*;
19 import org.eclipse.team.internal.ccvs.core.CVSException;
20 import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
21 import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
22
23 /**
24  * The low level cache provides the sync info as bytes
25  */

26 /*package*/ abstract class SyncInfoCache {
27
28     // the resources plugin synchronizer is used to cache and possibly persist. These
29
// are keys for storing the sync info.
30
/*package*/ static final QualifiedName FOLDER_SYNC_KEY = new QualifiedName(CVSProviderPlugin.ID, "folder-sync"); //$NON-NLS-1$
31
/*package*/ static final QualifiedName RESOURCE_SYNC_KEY = new QualifiedName(CVSProviderPlugin.ID, "resource-sync"); //$NON-NLS-1$
32
/*package*/ static final QualifiedName IGNORE_SYNC_KEY = new QualifiedName(CVSProviderPlugin.ID, "folder-ignore"); //$NON-NLS-1$
33

34     /*package*/ static final byte[][] EMPTY_RESOURCE_SYNC_INFOS = new byte[0][0];
35     
36     /*package*/ static final QualifiedName IS_DIRTY = new QualifiedName(CVSProviderPlugin.ID, "is-dirty"); //$NON-NLS-1$
37
/*package*/ static final String JavaDoc IS_DIRTY_INDICATOR = "d"; //$NON-NLS-1$
38
/*package*/ static final String JavaDoc NOT_DIRTY_INDICATOR = "c"; //$NON-NLS-1$
39
/*package*/ static final String JavaDoc RECOMPUTE_INDICATOR = "r"; //$NON-NLS-1$
40

41     /*package*/ static final IStatus STATUS_OK = new Status(IStatus.OK, CVSProviderPlugin.ID, 0, CVSMessages.ok, null);
42     
43     /**
44      * Returns the folder sync info for the container; null if none.
45      * Folder must exist and must not be the workspace root.
46      * The folder sync info for the container MUST ALREADY BE CACHED.
47      * <p>
48      * The <code>canModifyWorkspace</code>
49      * flag is used to indicate whether it is OK to modify ISycnrhonizer entries for
50      * the given resource. A value of <code>true</code> indicates that the client
51      * holds a scheduling rule that encompasses the resource and the workspace is
52      * open for modification.
53      * @param container the container
54      * @param threadSafeAccess if false, the return value can only be used if not null
55      * @param canModifyWorkspace indicates if it is OK to modify the ISycnrhonizer
56      *
57      * @return the folder sync info for the folder, or null if none.
58      * @see #cacheFolderSync
59      */

60     /*package*/ abstract FolderSyncInfo getCachedFolderSync(IContainer container, boolean threadSafeAccess) throws CVSException;
61
62     /**
63      * Sets the folder sync info for the container; if null, deletes it.
64      * Folder must exist and must not be the workspace root.
65      * The folder sync info for the container need not have previously been
66      * cached. The <code>canModifyWorkspace</code>
67      * flag is used to indicate whether it is OK to modify ISycnrhonizer entries for
68      * the given resource. A value of <code>true</code> indicates that the client
69      * holds a scheduling rule that encompasses the resource and the workspace is
70      * open for modification.
71      *
72      * @param container the container
73      * @param info the new folder sync info
74      * @param canModifyWorkspace indicates if it is OK to modify the ISycnrhonizer
75      */

76     /*package*/ abstract void setCachedFolderSync(IContainer container, FolderSyncInfo info, boolean canModifyWorkspace) throws CVSException;
77
78     /**
79      * Returns the resource sync info for the given resource. The resource sync
80      * info for the resource MUST ALREADY BE CACHED.
81      * @param resource the resource
82      * @param threadSafeAccess if false, the return value can only be used if not null
83      *
84      * @return the bytes containing the resource's sync info
85      * @see #cacheResourceSyncForChildren
86      */

87     /*package*/ abstract byte[] getCachedSyncBytes(IResource resource, boolean threadSafeAccess) throws CVSException;
88
89     /**
90      * Sets the resource sync info for the resource; if null, deletes it. Parent
91      * must exist and must not be the workspace root. The resource sync info for
92      * the resource MUST ALREADY BE CACHED. The <code>canModifyWorkspace</code>
93      * flag is used to indicate whether it is OK to modify ISycnrhonizer entries for
94      * the given resource. A value of <code>true</code> indicates that the client
95      * holds a scheduling rule that encompasses the resource and the workspace is
96      * open for modification.
97      *
98      * @param resource the resource
99      * @param syncBytes the bytes containing the new resource sync info
100      * @param canModifyWorkspace indicates if it is OK to modify the ISycnrhonizer
101      * @see #cacheResourceSyncForChildren
102      */

103     /*package*/ abstract void setCachedSyncBytes(IResource resource, byte[] syncBytes, boolean canModifyWorkspace) throws CVSException;
104     
105     /*package*/ abstract String JavaDoc getDirtyIndicator(IResource resource, boolean threadSafeAccess) throws CVSException;
106     
107     /*package*/ abstract void setDirtyIndicator(IResource resource, String JavaDoc indicator) throws CVSException;
108     
109     /*package*/ abstract void flushDirtyCache(IResource resource) throws CVSException;
110     
111     /*package*/ abstract boolean isSyncInfoLoaded(IContainer parent) throws CVSException;
112     
113     /**
114      * Query the low level cache to see if the sync info for the provided
115      * container is loaded.
116      *
117      * @param container
118      * @return boolean
119      * @throws CVSException
120      */

121     /*package*/ abstract boolean isFolderSyncInfoCached(IContainer container) throws CVSException;
122     
123     /**
124      * Query the low level cache to see if the sync info for the direct children
125      * of the provided container is loaded.
126      *
127      * @param container
128      * @return boolean
129      */

130     /*package*/ abstract boolean isResourceSyncInfoCached(IContainer container) throws CVSException;
131     
132     /**
133      * Indicate to the low level cache that the sync info for all it's direct
134      * children have been set so they match what is on disk.
135      *
136      * @param container
137      */

138     /*package*/ abstract void setResourceSyncInfoCached(IContainer container) throws CVSException;
139
140     /**
141      * Return whether the cache also caches dirty state or recomputes it
142      * each time it is requested.
143      */

144     public abstract boolean cachesDirtyState();
145 }
146
Popular Tags