KickJava   Java API By Example, From Geeks To Geeks.

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


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.team.internal.core.mapping;
12
13 import java.util.Date JavaDoc;
14
15 import org.eclipse.core.resources.*;
16 import org.eclipse.core.runtime.IProgressMonitor;
17 import org.eclipse.team.core.TeamException;
18 import org.eclipse.team.core.variants.IResourceVariant;
19
20 public class LocalResourceVariant implements IResourceVariant {
21     private final IResource resource;
22
23     public LocalResourceVariant(IResource resource) {
24         this.resource = resource;
25     }
26
27     public byte[] asBytes() {
28         return getContentIdentifier().getBytes();
29     }
30
31     public String JavaDoc getContentIdentifier() {
32         return new Date JavaDoc(resource.getLocalTimeStamp()).toString();
33     }
34
35     public IStorage getStorage(IProgressMonitor monitor) throws TeamException {
36         if (resource.getType() == IResource.FILE) {
37             return (IFile)resource;
38         }
39         return null;
40     }
41
42     public boolean isContainer() {
43         return resource.getType() != IResource.FILE;
44     }
45
46     public String JavaDoc getName() {
47         return resource.getName();
48     }
49 }
Popular Tags