| 1 7 package fr.jayasoft.ivy.repository.file; 8 9 import java.io.File ; 10 import java.io.FileInputStream ; 11 import java.io.IOException ; 12 import java.io.InputStream ; 13 14 import fr.jayasoft.ivy.repository.Resource; 15 16 public class FileResource implements Resource { 17 private File _file; 18 private FileRepository _repository; 19 20 public FileResource(FileRepository repository, File f) { 21 _repository = repository; 22 _file = f; 23 } 24 25 public String getName() { 26 return _file.getPath(); 27 } 28 29 public Resource clone(String cloneName) { 30 return new FileResource(_repository, new File (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 toString() { 46 return getName(); 47 } 48 49 public File 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 openStream() throws IOException { 62 return new FileInputStream (_file); 63 } 64 } 65 | Popular Tags |