1 11 package org.eclipse.update.internal.core; 12 13 import java.io.File ; 14 import java.io.IOException ; 15 import java.io.InputStream ; 16 import java.net.URL ; 17 import java.util.jar.JarFile ; 18 import java.util.zip.ZipEntry ; 19 20 import org.eclipse.core.runtime.CoreException; 21 import org.eclipse.update.core.JarContentReference; 22 import org.eclipse.update.core.model.FeatureModel; 23 import org.xml.sax.SAXException ; 24 25 public class Digest { 26 27 private URL source; 28 private File localSource; 29 private JarFile digestJar; 30 private InputStream inputStream; 31 32 33 public Digest(URL source){ 34 this.source = source; 35 } 36 37 public FeatureModel[] parseDigest() throws IOException , CoreException, SAXException { 38 DigestContentProvider digestContentProvider = new DigestContentProvider(source); 39 localSource = digestContentProvider.asLocalReference(new JarContentReference( null, source), null).asFile(); 40 digestJar = new JarFile (localSource); 41 42 ZipEntry digestEntry = digestJar.getEntry("digest.xml"); 44 if (digestEntry != null) { 45 inputStream = digestJar.getInputStream(digestEntry); 46 DigestParser digest = new DigestParser(); 47 digest.init(new LiteFeatureFactory()); 48 return digest.parse(inputStream); 49 } else { 50 throw new CoreException(null); 51 } 52 } 53 54 } 55 | Popular Tags |