KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > editors > text > JavaFileStorage


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 package org.eclipse.ui.internal.editors.text;
12
13 import java.io.InputStream JavaDoc;
14
15 import org.eclipse.core.filesystem.EFS;
16 import org.eclipse.core.filesystem.IFileStore;
17
18 import org.eclipse.core.runtime.CoreException;
19 import org.eclipse.core.runtime.IPath;
20 import org.eclipse.core.runtime.Path;
21
22 import org.eclipse.core.resources.IStorage;
23
24 import org.eclipse.jface.text.Assert;
25
26 /**
27  * A storage for java.io.File.
28  *
29  * @since 3.2
30  */

31 class JavaFileStorage implements IStorage {
32
33     private IFileStore fFileStore;
34     private IPath fFullPath;
35     
36     public JavaFileStorage(IFileStore fileStore) {
37         Assert.isNotNull(fileStore);
38         Assert.isTrue(EFS.SCHEME_FILE.equals(fileStore.getFileSystem().getScheme()));
39         fFileStore= fileStore;
40     }
41     
42     /*
43      * @see org.eclipse.core.resources.IStorage#getContents()
44      */

45     public InputStream JavaDoc getContents() throws CoreException {
46         return fFileStore.openInputStream(EFS.NONE, null);
47     }
48
49     /*
50      * @see org.eclipse.core.resources.IStorage#getFullPath()
51      */

52     public IPath getFullPath() {
53         if (fFullPath == null)
54             fFullPath= new Path(fFileStore.toURI().getPath());
55         return fFullPath;
56     }
57
58     /*
59      * @see org.eclipse.core.resources.IStorage#getName()
60      */

61     public String JavaDoc getName() {
62         return fFileStore.getName();
63     }
64
65     /*
66      * @see org.eclipse.core.resources.IStorage#isReadOnly()
67      */

68     public boolean isReadOnly() {
69         return fFileStore.fetchInfo().getAttribute(EFS.ATTRIBUTE_READ_ONLY);
70     }
71
72     /*
73      * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
74      */

75     public Object JavaDoc getAdapter(Class JavaDoc adapter) {
76         return null;
77     }
78 }
79
Popular Tags