KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
20  * This class is used to read markers from disk. Subclasses implement
21  * version specific reading code.
22  */

23 public class MarkerReader {
24     protected Workspace workspace;
25
26     public MarkerReader(Workspace workspace) {
27         super();
28         this.workspace = workspace;
29     }
30
31     /**
32      * Returns the appropriate reader for the given version.
33      */

34     protected MarkerReader getReader(int formatVersion) throws IOException JavaDoc {
35         switch (formatVersion) {
36             case 1 :
37                 return new MarkerReader_1(workspace);
38             case 2 :
39                 return new MarkerReader_2(workspace);
40             case 3 :
41                 return new MarkerReader_3(workspace);
42             default :
43                 throw new IOException JavaDoc(NLS.bind(Messages.resources_format, new Integer JavaDoc(formatVersion)));
44         }
45     }
46
47     public void read(DataInputStream JavaDoc input, boolean generateDeltas) throws IOException JavaDoc, CoreException {
48         int formatVersion = readVersionNumber(input);
49         MarkerReader reader = getReader(formatVersion);
50         reader.read(input, generateDeltas);
51     }
52
53     protected static int readVersionNumber(DataInputStream JavaDoc input) throws IOException JavaDoc {
54         return input.readInt();
55     }
56 }
57
Popular Tags