01: /*
02: * PPFAuxFile.java
03: *
04: * Created on October 25, 2001, 3:05 PM
05: */
06:
07: package com.sun.portal.desktop.deployment;
08:
09: import java.io.FileInputStream;
10: import java.io.InputStream;
11: import java.io.File;
12:
13: import java.util.zip.ZipEntry;
14:
15: import java.util.jar.JarFile;
16:
17: /**
18: * ProviderPackageFile for encapsulating a class file extracted from a jar.
19: *
20: * @author yabob
21: * @version
22: */
23: public class ClassJarPPF extends ClassPPF {
24:
25: public ClassJarPPF(String pkg, String classname, String jar,
26: int types) {
27: super (pkg, classname, types);
28: m_JarName = jar;
29: }
30:
31: public ClassJarPPF(String fullname, String jar, int types) {
32: super (fullname, types);
33: m_JarName = jar;
34: }
35:
36: public InputStream getStream() throws ParFileException {
37:
38: // classExists assures creation of ZipEntry the first time it is called.
39:
40: if (classExists()) {
41: try {
42: return m_Jar.getInputStream(m_ZE);
43: } catch (Exception ex) {
44: throw new ParFileException("errorClassStream", ex);
45: }
46: }
47:
48: throw new ParFileException("errorNoClassInJar");
49: }
50:
51: public boolean classExists() {
52: if (m_Jar == null) {
53: try {
54: m_Jar = new JarFile(m_JarName);
55: m_ZE = m_Jar.getEntry(Par.classToFile(m_Pkg,
56: m_ClassName));
57: } catch (Exception ex) {
58: return false;
59: }
60: }
61:
62: return m_ZE != null;
63: }
64:
65: private String m_JarName = null;
66: private JarFile m_Jar = null;
67: private ZipEntry m_ZE = null;
68: }
|