1 11 package org.eclipse.core.internal.resources; 12 13 import java.io.*; 14 import java.util.ArrayList ; 15 import java.util.List ; 16 import org.eclipse.core.internal.utils.Messages; 17 import org.eclipse.core.internal.utils.ObjectMap; 18 import org.eclipse.core.resources.IResourceStatus; 19 import org.eclipse.core.runtime.*; 20 import org.eclipse.osgi.util.NLS; 21 22 26 public class SyncInfoReader_3 extends SyncInfoReader { 27 28 public static final byte INDEX = 1; 30 public static final byte QNAME = 2; 31 32 public SyncInfoReader_3(Workspace workspace, Synchronizer synchronizer) { 33 super(workspace, synchronizer); 34 } 35 36 49 public void readSyncInfo(DataInputStream input) throws IOException, CoreException { 50 try { 51 List readPartners = new ArrayList (5); 52 while (true) { 53 IPath path = new Path(input.readUTF()); 54 readSyncInfo(path, input, readPartners); 55 } 56 } catch (EOFException e) { 57 } 59 } 60 61 private void readSyncInfo(IPath path, DataInputStream input, List readPartners) throws IOException, CoreException { 62 int size = input.readInt(); 63 ObjectMap table = new ObjectMap(size); 64 for (int i = 0; i < size; i++) { 65 QualifiedName name = null; 66 byte type = input.readByte(); 67 switch (type) { 68 case QNAME : 69 String qualifier = input.readUTF(); 70 String local = input.readUTF(); 71 name = new QualifiedName(qualifier, local); 72 readPartners.add(name); 73 break; 74 case INDEX : 75 name = (QualifiedName) readPartners.get(input.readInt()); 76 break; 77 default : 78 String msg = NLS.bind(Messages.resources_readSync, path == null ? "" : path.toString()); throw new ResourceException(IResourceStatus.FAILED_READ_METADATA, path, msg, null); 81 } 82 int length = input.readInt(); 84 byte[] bytes = new byte[length]; 85 input.readFully(bytes); 86 table.put(name, bytes); 88 } 89 ResourceInfo info = workspace.getResourceInfo(path, true, false); 91 if (info == null) 92 return; 93 info.setSyncInfo(table); 94 info.clear(ICoreConstants.M_SYNCINFO_SNAP_DIRTY); 95 } 96 } 97 | Popular Tags |