blob: 701ec7815fe2e89d72e5ecf3bdace155ddc1b18a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
package org.eclipse.jdt.internal.core.index.impl;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import java.io.*;
import org.eclipse.jdt.internal.core.index.*;
/**
* A <code>FileDocument</code> represents a java.io.File.
*/
public class FileDocument extends PropertyDocument {
File file;
public FileDocument(File file) {
super();
this.file= file;
}
/**
* @see IDocument#getByteContent
*/
public byte[] getByteContent() throws IOException {
return Util.getFileByteContent(file);
}
/**
* @see IDocument#getCharContent
*/
public char[] getCharContent() throws IOException {
return Util.getFileCharContent(file);
}
/**
* @see IDocument#getName
*/
public String getName() {
return file.getAbsolutePath().replace(File.separatorChar, IIndexConstants.FILE_SEPARATOR);
}
/**
* @see IDocument#getStringContent
*/
public String getStringContent() throws IOException {
return new String(getCharContent());
}
/**
* @see IDocument#getType
*/
public String getType() {
int lastDot= file.getPath().lastIndexOf('.');
if (lastDot == -1)
return ""/*nonNLS*/;
return file.getPath().substring(lastDot + 1);
}
}
|