1 25 26 package org.objectweb.jonas_lib.genbase.archive; 27 28 import java.io.File ; 29 import java.util.Hashtable ; 30 import java.util.Map ; 31 import java.util.jar.Manifest ; 32 33 import org.objectweb.jonas_lib.I18n; 34 35 41 public abstract class AbsArchive implements Archive { 42 43 44 private static I18n i18n = I18n.getInstance(AbsArchive.class); 45 46 47 private File root; 48 49 50 private Manifest manifest = null; 51 52 53 private Map files = null; 54 55 60 public AbsArchive(File file) { 61 root = file; 62 files = new Hashtable (); 63 } 64 65 70 public void addDirectory(File directory) { 71 addDirectoryIn("", directory); 72 } 73 74 81 public void addDirectoryIn(String dirName, File directory) { 82 File [] childs = directory.listFiles(); 83 84 if (childs != null) { 86 for (int i = 0; i < childs.length; i++) { 87 if (childs[i].isFile()) { 88 addFileIn(dirName, childs[i]); 90 } else { 91 addDirectoryIn(dirName + childs[i].getName() + File.separator, childs[i]); 93 } 94 } 95 } 96 } 97 98 103 public void addFile(File file) { 104 addFileIn("", file); 105 } 106 107 113 public void addFile(File file, String name) { 114 files.put(name, file); 115 } 116 117 123 public void addFileIn(String dirName, File file) { 124 files.put(dirName + file.getName(), file); 125 } 126 127 132 public File getRootFile() { 133 return root; 134 } 135 136 141 public String getName() { 142 return root.getName(); 143 } 144 145 148 public Manifest getManifest() { 149 if (manifest == null) { 150 manifest = new Manifest (); 151 } 152 return manifest; 153 } 154 157 public void setManifest(Manifest manifest) { 158 this.manifest = manifest; 159 } 160 163 public static I18n getI18n() { 164 return i18n; 165 } 166 169 public Map getFiles() { 170 return files; 171 } 172 173 176 public void close() { 177 this.files = null; 178 this.manifest = null; 179 } 180 } | Popular Tags |