KickJava   Java API By Example, From Geeks To Geeks.

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


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.Messages;
16 import org.eclipse.osgi.util.NLS;
17
18 public class SyncInfoSnapReader {
19     protected Workspace workspace;
20     protected Synchronizer synchronizer;
21
22     public SyncInfoSnapReader(Workspace workspace, Synchronizer synchronizer) {
23         super();
24         this.workspace = workspace;
25         this.synchronizer = synchronizer;
26     }
27
28     /**
29      * Returns the appropriate reader for the given version.
30      */

31     protected SyncInfoSnapReader getReader(int formatVersion) throws IOException JavaDoc {
32         switch (formatVersion) {
33             case 3 :
34                 return new SyncInfoSnapReader_3(workspace, synchronizer);
35             default :
36                 throw new IOException JavaDoc(NLS.bind(Messages.resources_format, new Integer JavaDoc(formatVersion)));
37         }
38     }
39
40     public void readSyncInfo(DataInputStream JavaDoc input) throws IOException JavaDoc {
41         // dispatch to the appropriate reader depending
42
// on the version of the file
43
int formatVersion = readVersionNumber(input);
44         SyncInfoSnapReader reader = getReader(formatVersion);
45         reader.readSyncInfo(input);
46     }
47
48     protected static int readVersionNumber(DataInputStream JavaDoc input) throws IOException JavaDoc {
49         return input.readInt();
50     }
51 }
52
Popular Tags