KickJava   Java API By Example, From Geeks To Geeks.

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


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 - Initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.core.internal.resources;
12
13 import java.io.DataInputStream JavaDoc;
14 import org.eclipse.core.internal.utils.Messages;
15 import org.eclipse.core.internal.watson.ElementTree;
16 import org.eclipse.core.resources.IProject;
17 import org.eclipse.core.resources.IResourceStatus;
18 import org.eclipse.core.runtime.CoreException;
19 import org.eclipse.core.runtime.IProgressMonitor;
20 import org.eclipse.osgi.util.NLS;
21
22 /**
23  * Default tree reader that does not read anything. This is used in cases
24  * where the tree format is unknown (for example when opening a workspace
25  * from a future version).
26  */

27 public abstract class WorkspaceTreeReader {
28     /**
29      * Returns the tree reader associated with the given tree version number
30      */

31     public static WorkspaceTreeReader getReader(Workspace workspace, int version) throws CoreException {
32         switch (version) {
33             case ICoreConstants.WORKSPACE_TREE_VERSION_1 :
34                 return new WorkspaceTreeReader_1(workspace);
35             case ICoreConstants.WORKSPACE_TREE_VERSION_2 :
36                 return new WorkspaceTreeReader_2(workspace);
37             default :
38                 // Unknown tree version - fail to read the tree
39
String JavaDoc msg = NLS.bind(Messages.resources_format, new Integer JavaDoc(version));
40                 throw new ResourceException(IResourceStatus.FAILED_READ_METADATA, null, msg, null);
41         }
42     }
43
44     /**
45      * Returns a snapshot from the stream. This default implementation does nothing.
46      */

47     public abstract ElementTree readSnapshotTree(DataInputStream JavaDoc input, ElementTree complete, IProgressMonitor monitor) throws CoreException;
48
49     /**
50      * Reads all workspace trees from the stream. This default implementation does nothing.
51      */

52     public abstract void readTree(DataInputStream JavaDoc input, IProgressMonitor monitor) throws CoreException;
53
54     /**
55      * Reads a project's trees from the stream. This default implementation does nothing.
56      */

57     public abstract void readTree(IProject project, DataInputStream JavaDoc input, IProgressMonitor monitor) throws CoreException;
58 }
59
Popular Tags