KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > server > ftp > FileObjectDatabase


1 /*
2  * Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
3  * Initial Developer: H2 Group
4  */

5 package org.h2.server.ftp;
6
7 import java.io.IOException JavaDoc;
8 import java.io.InputStream JavaDoc;
9 import java.io.OutputStream JavaDoc;
10
11 public class FileObjectDatabase implements FileObject {
12
13     static FileObjectDatabase get(FileSystemDatabase db, String JavaDoc name) {
14         return new FileObjectDatabase(db, name);
15     }
16     
17     private FileSystemDatabase db;
18     private String JavaDoc fullName;
19     
20     private FileObjectDatabase(FileSystemDatabase db, String JavaDoc fullName) {
21         this.db = db;
22         this.fullName = fullName;
23     }
24
25     public boolean canRead() {
26         return true;
27     }
28
29     public boolean canWrite() {
30         return true;
31     }
32
33     public boolean delete() {
34         db.delete(fullName);
35         return true;
36     }
37
38     public boolean exists() {
39         return db.exists(fullName);
40     }
41
42     public void read(long skip, OutputStream JavaDoc out) throws IOException JavaDoc {
43         db.read(fullName, skip, out);
44     }
45
46     public String JavaDoc getName() {
47         return db.getName(fullName);
48     }
49
50     public void write(InputStream JavaDoc in) throws IOException JavaDoc {
51         db.write(fullName, in);
52     }
53
54     public boolean isDirectory() {
55         return db.isDirectory(fullName);
56     }
57
58     public boolean isFile() {
59         return !db.isDirectory(fullName);
60     }
61
62     public long lastModified() {
63         return db.lastModified(fullName);
64     }
65
66     public long length() {
67         return db.length(fullName);
68     }
69
70     public FileObject[] listFiles() {
71         return db.listFiles(fullName);
72     }
73
74     public boolean mkdirs() {
75         db.mkdirs(fullName);
76         return true;
77     }
78
79     public boolean renameTo(FileObject fileNew) {
80         return db.renameTo(fullName, ((FileObjectDatabase)fileNew).fullName);
81     }
82
83 }
84
Popular Tags