1 7 package org.ejtools.archive; 8 9 import java.util.Collections ; 10 import java.util.Enumeration ; 11 import java.util.HashMap ; 12 import java.util.Iterator ; 13 import java.util.Map ; 14 15 import org.ejtools.archive.io.Reader; 16 import org.ejtools.archive.io.Writer; 17 18 24 public class JarArchive extends JarEntry implements Archive 25 { 26 27 private Map entries = new HashMap (); 28 29 private Archive parent = null; 30 31 32 37 public JarArchive(String uri) 38 { 39 super(uri); 40 } 41 42 43 48 public void accept(Writer visitor) 49 { 50 visitor.visit(this); 51 } 52 53 54 59 public void accept(Reader visitor) 60 { 61 visitor.visit(this); 62 } 63 64 65 70 public void addEntry(Entry entry) 71 { 72 this.entries.put(entry.getURI(), entry); 73 } 74 75 76 81 public void addTo(Archive archive) 82 { 83 this.parent = archive; 84 archive.addEntry(this); 85 } 86 87 88 93 public Enumeration getEntries() 94 { 95 return Collections.enumeration(entries.values()); 96 } 97 98 99 105 public Entry getEntry(String uri) 106 { 107 return (Entry) this.entries.get(uri); 108 } 109 110 111 116 public Entry getManifest() 117 { 118 return (Entry) this.entries.get("META-INF/MANIFEST.MF"); 119 } 120 121 122 127 public Archive getParent() 128 { 129 return this.parent; 130 } 131 132 133 138 public boolean isArchive() 139 { 140 return true; 141 } 142 143 144 149 public boolean isNested() 150 { 151 return (this.parent != null); 152 } 153 154 155 160 public Iterator iterator() 161 { 162 return this.entries.values().iterator(); 163 } 164 165 166 171 public void removeEntry(String uri) 172 { 173 this.entries.remove(uri); 174 } 175 176 177 182 public void removeEntry(Entry entry) 183 { 184 this.removeEntry(entry.getURI()); 185 } 186 } 187 | Popular Tags |