KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > core > history > provider > FileRevision


1 /*******************************************************************************
2  * Copyright (c) 2000, 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
12 package org.eclipse.team.core.history.provider;
13
14 import java.net.URI JavaDoc;
15
16 import org.eclipse.core.resources.IFile;
17 import org.eclipse.core.resources.IStorage;
18 import org.eclipse.core.runtime.CoreException;
19 import org.eclipse.core.runtime.IProgressMonitor;
20 import org.eclipse.team.core.history.IFileRevision;
21 import org.eclipse.team.core.history.ITag;
22
23 /**
24  * Abstract implementation of {@link IFileRevision} that can be implemented by
25  * clients.
26  *
27  * @see IFileRevision
28  *
29  * @since 3.2
30  */

31 public abstract class FileRevision implements IFileRevision {
32
33     private static final class LocalFileRevision extends FileRevision {
34         private final IFile file;
35
36         private LocalFileRevision(IFile file) {
37             this.file = file;
38         }
39
40         public IStorage getStorage(IProgressMonitor monitor) {
41             return file;
42         }
43
44         public String JavaDoc getName() {
45             return file.getName();
46         }
47
48         public boolean exists() {
49             return file.exists();
50         }
51
52         public long getTimestamp() {
53             return file.getLocalTimeStamp();
54         }
55
56         public URI JavaDoc getURI() {
57             return file.getLocationURI();
58         }
59
60         public IFileRevision withAllProperties(IProgressMonitor monitor) throws CoreException {
61             return this;
62         }
63
64         public boolean isPropertyMissing() {
65             return false;
66         }
67
68         public int hashCode() {
69             return file.hashCode();
70         }
71
72         public boolean equals(Object JavaDoc obj) {
73             if (obj == this)
74                 return true;
75             if (obj instanceof LocalFileRevision) {
76                 LocalFileRevision other = (LocalFileRevision) obj;
77                 return other.file.equals(this.file);
78             }
79             return false;
80         }
81     }
82
83     /**
84      * Return a file state representing the current state of the
85      * local file.
86      * @param file a local file
87      * @return a file state representing the current state of the
88      * local file
89      */

90     public static IFileRevision getFileRevisionFor(final IFile file) {
91         return new LocalFileRevision(file);
92     }
93
94     /* (non-Javadoc)
95      * @see org.eclipse.team.core.history.IFileState#getURI()
96      */

97     public URI JavaDoc getURI() {
98         return null;
99     }
100
101     /* (non-Javadoc)
102      * @see org.eclipse.team.core.history.IFileState#getTimestamp()
103      */

104     public long getTimestamp() {
105         return -1;
106     }
107
108     /* (non-Javadoc)
109      * @see org.eclipse.team.core.history.IFileState#exists()
110      */

111     public boolean exists() {
112         return true;
113     }
114
115     /* (non-Javadoc)
116      * @see org.eclipse.team.core.history.IFileRevision#getContentIdentifier()
117      */

118     public String JavaDoc getContentIdentifier() {
119         return null;
120     }
121     /* (non-Javadoc)
122      * @see org.eclipse.team.core.history.IFileRevision#getAuthor()
123      */

124     public String JavaDoc getAuthor() {
125         return null;
126     }
127     /* (non-Javadoc)
128      * @see org.eclipse.team.core.history.IFileRevision#getComment()
129      */

130     public String JavaDoc getComment() {
131         return null;
132     }
133     
134     /* (non-Javadoc)
135      * @see org.eclipse.team.core.history.IFileRevision#getTags()
136      */

137     public ITag[] getTags() {
138         return new ITag[0];
139     }
140     
141 }
142
Popular Tags