1 17 package org.apache.geronimo.deployment.util; 18 19 import java.util.jar.JarEntry ; 20 import java.util.jar.Attributes ; 21 import java.util.jar.Manifest ; 22 import java.util.zip.ZipEntry ; 23 import java.io.IOException ; 24 import java.io.File ; 25 import java.security.cert.Certificate ; 26 27 30 public class UnpackedJarEntry extends JarEntry { 31 private final File file; 32 private final Manifest manifest; 33 34 public UnpackedJarEntry(String name, File file, Manifest manifest) { 35 super(name); 36 this.file = file; 37 this.manifest = manifest; 38 } 39 40 public File getFile() { 41 return file; 42 } 43 44 public Attributes getAttributes() throws IOException { 45 if (manifest == null) { 46 return null; 47 } 48 return manifest.getAttributes(getName()); 49 } 50 51 57 public Certificate [] getCertificates() { 58 return null; 59 } 60 61 66 public void setTime(long time) throws UnsupportedOperationException { 67 throw new UnsupportedOperationException ("Can not change the time of unpacked jar entry"); 68 } 69 70 public long getTime() { 71 return file.lastModified(); 72 } 73 74 79 public void setSize(long size) throws UnsupportedOperationException { 80 throw new UnsupportedOperationException ("Can not change the size of unpacked jar entry"); 81 } 82 83 public long getSize() { 84 if (file.isDirectory()) { 85 return -1; 86 } else { 87 return file.length(); 88 } 89 } 90 91 95 public long getCompressedSize() { 96 return getSize(); 97 } 98 99 104 public void setCompressedSize(long compressedSize) { 105 throw new UnsupportedOperationException ("Can not change the compressed size of unpacked jar entry"); 106 } 107 108 public long getCrc() { 109 return super.getCrc(); } 111 112 117 public void setCrc(long crc) { 118 throw new UnsupportedOperationException ("Can not change the crc of unpacked jar entry"); 119 } 120 121 public int getMethod() { 122 return ZipEntry.STORED; 123 } 124 125 130 public void setMethod(int method) { 131 throw new UnsupportedOperationException ("Can not change the method of unpacked jar entry"); 132 } 133 134 138 public byte[] getExtra() { 139 return null; 140 } 141 142 147 public void setExtra(byte[] extra) { 148 throw new UnsupportedOperationException ("Can not change the extra data of unpacked jar entry"); 149 } 150 151 155 public String getComment() { 156 return null; 157 } 158 159 164 public void setComment(String comment) { 165 throw new UnsupportedOperationException ("Can not change the comment of unpacked jar entry"); 166 } 167 168 public boolean isDirectory() { 169 return file.isDirectory(); 170 } 171 172 public Object clone() { 173 return new UnpackedJarEntry(getName(), file, manifest); 174 } 175 } 176 | Popular Tags |