KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > resources > SyncInfoSnapReader_3


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.core.internal.resources;
12
13 import java.io.DataInputStream JavaDoc;
14 import java.io.IOException JavaDoc;
15 import org.eclipse.core.internal.utils.ObjectMap;
16 import org.eclipse.core.runtime.*;
17
18 public class SyncInfoSnapReader_3 extends SyncInfoSnapReader {
19
20     public SyncInfoSnapReader_3(Workspace workspace, Synchronizer synchronizer) {
21         super(workspace, synchronizer);
22     }
23
24     private ObjectMap internalReadSyncInfo(DataInputStream JavaDoc input) throws IOException JavaDoc {
25         int size = input.readInt();
26         ObjectMap map = new ObjectMap(size);
27         for (int i = 0; i < size; i++) {
28             // read the qualified name
29
String JavaDoc qualifier = input.readUTF();
30             String JavaDoc local = input.readUTF();
31             QualifiedName name = new QualifiedName(qualifier, local);
32             // read the bytes
33
int length = input.readInt();
34             byte[] bytes = new byte[length];
35             input.readFully(bytes);
36             // put them in the table
37
map.put(name, bytes);
38         }
39         return map;
40     }
41
42     /**
43      * SNAP_FILE -> [VERSION_ID RESOURCE]*
44      * VERSION_ID -> int
45      * RESOURCE -> RESOURCE_PATH SIZE SYNCINFO*
46      * RESOURCE_PATH -> String
47      * SIZE -> int
48      * SYNCINFO -> QNAME BYTES
49      * QNAME -> String String
50      * BYTES -> byte[]
51      */

52     public void readSyncInfo(DataInputStream JavaDoc input) throws IOException JavaDoc {
53         IPath path = new Path(input.readUTF());
54         ObjectMap map = internalReadSyncInfo(input);
55         // set the table on the resource info
56
ResourceInfo info = workspace.getResourceInfo(path, true, false);
57         if (info == null)
58             return;
59         info.setSyncInfo(map);
60         info.clear(ICoreConstants.M_SYNCINFO_SNAP_DIRTY);
61     }
62 }
63
Popular Tags