1 6 21 22 package de.schlichtherle.io.archive.zip; 23 24 import de.schlichtherle.io.archive.*; 25 import de.schlichtherle.io.archive.spi.*; 26 import de.schlichtherle.io.rof.*; 27 28 import java.io.*; 29 import java.util.zip.*; 30 31 import javax.swing.*; 32 33 46 public class Zip32Driver extends AbstractArchiveDriver { 47 48 private final boolean preambled; 49 50 private final boolean postambled; 51 52 57 public Zip32Driver() { 58 this("IBM437", false, false, null, null); 59 } 60 61 66 public Zip32Driver(String encoding) { 67 this(encoding, false, false, null, null); 68 } 69 70 105 public Zip32Driver( 106 String encoding, 107 boolean preambled, 108 boolean postambled, 109 Icon openIcon, 110 Icon closedIcon) { 111 super(encoding, openIcon, closedIcon); 112 113 this.preambled = preambled; 114 this.postambled = postambled; 115 } 116 117 121 127 public boolean getPreambled() { 128 return preambled; 129 } 130 131 143 public boolean getPostambled() { 144 return postambled; 145 } 146 147 151 public ArchiveEntry createArchiveEntry( 152 final Archive archive, 153 final String entryName, 154 final ArchiveEntry blueprint) 155 throws CharConversionException { 156 ensureEncodable(entryName); 157 158 final Zip32Entry entry; 159 if (blueprint != null) { 160 if (blueprint instanceof Zip32Entry) { 161 entry = new Zip32Entry(entryName, (Zip32Entry) blueprint); 162 } else { 163 entry = new Zip32Entry(entryName); 164 entry.setTime(blueprint.getTime()); 165 } 166 } else { 167 entry = new Zip32Entry(entryName); 168 } 169 170 return entry; 171 } 172 173 public InputArchive createInputArchive(Archive archive, ReadOnlyFile rof) 174 throws UnsupportedEncodingException, FileNotFoundException, IOException { 175 return createZip32InputArchive( 176 rof, getEncoding(), getPreambled(), getPostambled()); 177 } 178 179 protected Zip32InputArchive createZip32InputArchive( 180 ReadOnlyFile rof, 181 String encoding, 182 boolean preambled, 183 boolean postambled) 184 throws NullPointerException , 185 UnsupportedEncodingException, 186 FileNotFoundException, 187 ZipException, 188 IOException { 189 return new Zip32InputArchive(rof, encoding, preambled, postambled); 190 } 191 192 public OutputArchive createOutputArchive( 193 final Archive archive, 194 final OutputStream out, 195 final InputArchive source) 196 throws UnsupportedEncodingException, IOException { 197 return createZip32OutputArchive( 198 out, getEncoding(), (Zip32InputArchive) source); 199 } 200 201 protected Zip32OutputArchive createZip32OutputArchive( 202 final OutputStream out, 203 final String encoding, 204 final Zip32InputArchive source) 205 throws NullPointerException , 206 UnsupportedEncodingException, 207 IOException { 208 return new Zip32OutputArchive(out, encoding, source); 209 } 210 } 211 | Popular Tags |