1 23 24 29 30 package com.sun.enterprise.util.io; 31 32 import java.io.*; 33 34 39 public class FileSource 40 { 41 public FileSource(File f) 42 { 43 if(f == null) 44 throw new IllegalArgumentException ("null File argument."); 45 else if(!f.exists()) 46 throw new IllegalArgumentException ("File doesn't exist: " + FileUtils.safeGetCanonicalPath(f)); 47 48 if(f.isDirectory()) 49 isDir = true; 50 else 51 isDir = false; 52 53 fileSource = f; 54 } 55 56 58 public boolean exists() 59 { 60 return fileSource != null && fileSource.exists(); 61 } 62 63 65 public File getSource() 66 { 67 return fileSource; 68 } 69 70 72 public File getFile() 73 { 74 return fileSource; 75 } 76 77 79 public boolean isArchive() 80 { 81 return !isDir; 82 } 83 84 86 public boolean isDirectory() 87 { 88 return isDir; 89 } 90 91 93 public boolean isDir() 94 { 95 return isDirectory(); 96 } 97 98 100 public String toString() 101 { 102 if(fileSource == null) 103 return "null FileSource"; 104 105 return FileUtils.safeGetCanonicalPath(fileSource); 106 } 107 108 110 private File fileSource = null; 111 private boolean isDir = false; 112 } 113 | Popular Tags |