KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > core > mapping > ResourceVariantFileRevision


1 /*******************************************************************************
2  * Copyright (c) 2006 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.team.internal.core.mapping;
12
13 import org.eclipse.core.resources.IStorage;
14 import org.eclipse.core.runtime.*;
15 import org.eclipse.team.core.history.IFileRevision;
16 import org.eclipse.team.core.history.provider.FileRevision;
17 import org.eclipse.team.core.variants.IResourceVariant;
18
19 public class ResourceVariantFileRevision extends FileRevision implements IAdaptable {
20     private final IResourceVariant variant;
21
22     public ResourceVariantFileRevision(IResourceVariant variant) {
23         this.variant = variant;
24     }
25
26     public IStorage getStorage(IProgressMonitor monitor) throws CoreException {
27         return variant.getStorage(monitor);
28     }
29
30     public String JavaDoc getName() {
31         return variant.getName();
32     }
33
34     public String JavaDoc getContentIdentifier() {
35         return variant.getContentIdentifier();
36     }
37
38     public IResourceVariant getVariant() {
39         return variant;
40     }
41
42     public boolean isPropertyMissing() {
43         return false;
44     }
45
46     public IFileRevision withAllProperties(IProgressMonitor monitor) throws CoreException {
47         return this;
48     }
49
50     public Object JavaDoc getAdapter(Class JavaDoc adapter) {
51         if (adapter == IResourceVariant.class)
52             return variant;
53         Object JavaDoc object = Platform.getAdapterManager().getAdapter(this, adapter);
54         if (object != null)
55             return object;
56         if (variant instanceof IAdaptable ) {
57             IAdaptable adaptable = (IAdaptable ) variant;
58             return adaptable.getAdapter(adapter);
59         }
60         return null;
61     }
62     
63     public boolean equals(Object JavaDoc obj) {
64         if (obj instanceof ResourceVariantFileRevision) {
65             ResourceVariantFileRevision fileRevision = (ResourceVariantFileRevision) obj;
66             return fileRevision.getVariant().equals(getVariant());
67         }
68         return false;
69     }
70     
71     public int hashCode() {
72         return getVariant().hashCode();
73     }
74 }
Popular Tags