KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > jayasoft > ivy > repository > file > FileResource


1 /*
2  * This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
3  * Copyright Jayasoft 2005 - All rights reserved
4  *
5  * #SNAPSHOT#
6  */

7 package fr.jayasoft.ivy.repository.file;
8
9 import java.io.File JavaDoc;
10 import java.io.FileInputStream JavaDoc;
11 import java.io.IOException JavaDoc;
12 import java.io.InputStream JavaDoc;
13
14 import fr.jayasoft.ivy.repository.Resource;
15
16 public class FileResource implements Resource {
17     private File JavaDoc _file;
18     private FileRepository _repository;
19
20     public FileResource(FileRepository repository, File JavaDoc f) {
21         _repository = repository;
22         _file = f;
23     }
24
25     public String JavaDoc getName() {
26         return _file.getPath();
27     }
28     
29     public Resource clone(String JavaDoc cloneName) {
30         return new FileResource(_repository, new File JavaDoc(cloneName));
31     }
32
33     public long getLastModified() {
34         return _file.lastModified();
35     }
36
37     public long getContentLength() {
38         return _file.length();
39     }
40
41     public boolean exists() {
42         return _file.exists();
43     }
44
45     public String JavaDoc toString() {
46         return getName();
47     }
48
49     public File JavaDoc getFile() {
50         return _file;
51     }
52     
53     public FileRepository getRepository() {
54         return _repository;
55     }
56     
57     public boolean isLocal() {
58         return _repository.isLocal();
59     }
60
61     public InputStream JavaDoc openStream() throws IOException JavaDoc {
62         return new FileInputStream JavaDoc(_file);
63     }
64 }
65
Popular Tags