1 /******************************************************************************* 2 * Copyright (c) 2000, 2006 IBM Corporation and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * IBM Corporation - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.team.internal.ccvs.core.syncinfo; 15 16 import org.eclipse.core.resources.IContainer; 17 import org.eclipse.core.resources.IResource; 18 import org.eclipse.team.core.TeamException; 19 import org.eclipse.team.core.variants.ResourceVariantByteStore; 20 import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer; 21 22 23 public class CVSBaseResourceVariantTree extends ResourceVariantByteStore { dispose()24 public void dispose() { 25 // Do nothing 26 } getBytes(IResource resource)27 public byte[] getBytes(IResource resource) throws TeamException { 28 if (resource.getType() == IResource.FILE) { 29 // For a file, return the entry line 30 byte[] bytes = EclipseSynchronizer.getInstance().getSyncBytes(resource); 31 if (bytes != null) { 32 // Use the base sync info (i.e. no deletion or addition) 33 if (ResourceSyncInfo.isDeletion(bytes)) { 34 bytes = ResourceSyncInfo.convertFromDeletion(bytes); 35 } else if (ResourceSyncInfo.isAddition(bytes)) { 36 bytes = null; 37 } 38 } 39 return bytes; 40 } else { 41 // For a folder, return the folder sync info bytes 42 FolderSyncInfo info = EclipseSynchronizer.getInstance().getFolderSync((IContainer)resource); 43 if (info == null) return null; 44 return info.getBytes(); 45 } 46 } isVariantKnown(IResource resource)47 public boolean isVariantKnown(IResource resource) throws TeamException { 48 return getBytes(resource) != null; 49 } flushBytes(IResource resource, int depth)50 public boolean flushBytes(IResource resource, int depth) throws TeamException { 51 throw new UnsupportedOperationException(); 52 } setBytes(IResource resource, byte[] bytes)53 public boolean setBytes(IResource resource, byte[] bytes) throws TeamException { 54 throw new UnsupportedOperationException(); 55 } deleteBytes(IResource resource)56 public boolean deleteBytes(IResource resource) throws TeamException { 57 throw new UnsupportedOperationException(); 58 } 59 60 @Override members(IResource resource)61 public IResource[] members(IResource resource) throws TeamException { 62 if(resource.getType() == IResource.FILE) { 63 return new IResource[0]; 64 } 65 return EclipseSynchronizer.getInstance().members((IContainer)resource); 66 } 67 } 68