KickJava   Java API By Example, From Geeks To Geeks.

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


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

30     protected MarkerSnapshotReader getReader(int formatVersion) throws IOException JavaDoc {
31         switch (formatVersion) {
32             case 1 :
33                 return new MarkerSnapshotReader_1(workspace);
34             case 2 :
35                 return new MarkerSnapshotReader_2(workspace);
36             default :
37                 throw new IOException JavaDoc(NLS.bind(Messages.resources_format, new Integer JavaDoc(formatVersion)));
38         }
39     }
40
41     public void read(DataInputStream JavaDoc input) throws IOException JavaDoc, CoreException {
42         int formatVersion = readVersionNumber(input);
43         MarkerSnapshotReader reader = getReader(formatVersion);
44         reader.read(input);
45     }
46
47     protected static int readVersionNumber(DataInputStream JavaDoc input) throws IOException JavaDoc {
48         return input.readInt();
49     }
50 }
51
Popular Tags