Package org.eclipse.team.core.variants
Class ResourceVariantByteStore
- java.lang.Object
-
- org.eclipse.team.core.variants.ResourceVariantByteStore
-
- Direct Known Subclasses:
PersistantResourceVariantByteStore
,SessionResourceVariantByteStore
public abstract class ResourceVariantByteStore extends Object
The purpose of aResourceVariantByteStore
is to support the caching of the synchronization bytes for the resource variants that represent a resource line-up of interest such as a version, baseline or branch. The cache stores bytes in order to minimize the memory footprint of the tree. It is the responsibility of the client of this API to cache enough bytes to meaningfully identify a resource variant (and possibly create anIResourceVariant
handle from them).The bytes for a resource variant are accessed using the local
IResource
handle that corresponds to the resource variant (using thegetBytes
method). The potential children of a resource variant are also accessed by using the local handle that corresponds to the resource variant (using themembers
method).- Since:
- 3.0
-
-
Constructor Summary
Constructors Constructor Description ResourceVariantByteStore()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract boolean
deleteBytes(IResource resource)
Method called to indicate that it is known that there is no variant associated with the local resource.abstract void
dispose()
Dispose of any cached sync bytes when this cache is no longer needed.protected boolean
equals(byte[] syncBytes1, byte[] syncBytes2)
Helper method to compare two byte arrays for equalityabstract boolean
flushBytes(IResource resource, int depth)
Remove the bytes from the tree for the resource variants corresponding to the given local resource and its descendants to the given depth.abstract byte[]
getBytes(IResource resource)
Return the bytes for the variant corresponding the given local resource.abstract IResource[]
members(IResource resource)
Return the children of the given resource that have resource variants in this tree.void
run(IResource root, IWorkspaceRunnable runnable, IProgressMonitor monitor)
Run the given action which may contain multiple modifications to the byte store.abstract boolean
setBytes(IResource resource, byte[] bytes)
Set the bytes for the variant corresponding the given local resource.
-
-
-
Method Detail
-
dispose
public abstract void dispose()
Dispose of any cached sync bytes when this cache is no longer needed.
-
getBytes
public abstract byte[] getBytes(IResource resource) throws TeamException
Return the bytes for the variant corresponding the given local resource. A return value ofnull
means that no bytes have been stored for the resource variant. It is up to the client to determine whether this means that the resource variant does not exist or that it has not been fetched or otherwise determined yet.- Parameters:
resource
- the local resource- Returns:
- the bytes that represent the resource's variant
- Throws:
TeamException
- if an error occurs
-
setBytes
public abstract boolean setBytes(IResource resource, byte[] bytes) throws TeamException
Set the bytes for the variant corresponding the given local resource. The bytes should never benull
. If it is known that the remote does not exist,deleteBytes(IResource)
should be used instead. If the sync bytes for the remote are stale and should be removed,flushBytes(IResouce, int)
should be called.- Parameters:
resource
- the local resourcebytes
- the bytes that represent the resource's variant- Returns:
true
if the bytes changed- Throws:
TeamException
- if an error occurs
-
flushBytes
public abstract boolean flushBytes(IResource resource, int depth) throws TeamException
Remove the bytes from the tree for the resource variants corresponding to the given local resource and its descendants to the given depth. After the bytes are removed,getBytes(resource)
will returnnull
for the affected resources.- Parameters:
resource
- the local resourcedepth
- the depth of the operation (one ofIResource.DEPTH_ZERO
,IResource.DEPTH_ONE
, orIResource.DEPTH_INFINITE
)- Returns:
true
if there were bytes present which were removed- Throws:
TeamException
- if an error occurs
-
deleteBytes
public abstract boolean deleteBytes(IResource resource) throws TeamException
Method called to indicate that it is known that there is no variant associated with the local resource. Subclasses may handle this information in different ways. Theflush(IResource, int)
method should be used in the cases where a client wishes to remove bytes for other reason.- Parameters:
resource
- the local resource- Returns:
true
if this changes the bytes for the variant- Throws:
TeamException
- if an error occurs
-
members
public abstract IResource[] members(IResource resource) throws TeamException
Return the children of the given resource that have resource variants in this tree.- Parameters:
resource
- the parent resource- Returns:
- the members who have resource variants in this tree.
- Throws:
TeamException
- if an error occurs
-
equals
protected boolean equals(byte[] syncBytes1, byte[] syncBytes2)
Helper method to compare two byte arrays for equality- Parameters:
syncBytes1
- the first byte array ornull
syncBytes2
- the second byte array ornull
- Returns:
- whether the two arrays are equal (i.e. same content)
-
run
public void run(IResource root, IWorkspaceRunnable runnable, IProgressMonitor monitor) throws TeamException
Run the given action which may contain multiple modifications to the byte store. By default, the action is run. Subclasses may override to obtain scheduling rules or batch deltas (if the byte store modifies workspace resources).- Parameters:
root
- the root resource for all modificationsrunnable
- the action to performmonitor
- a progress monitor.- Throws:
TeamException
- if the operation failed.OperationCanceledException
- if the operation is canceled.
-
-