1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.jdo.impl.enhancer;
19
20 import java.io.OutputStream;
21
22 /***
23 * This class serves as a wrapper for an output stream of a class file. The
24 * stream is passed as a parameter to the byte code enhancer, that can
25 * sets the classname of the written Java class to the wrapper.
26 * <br>
27 * This wrapper is necessary to determine the classname outside the enhancer,
28 * after the class has been enhanced, since do do not always know the
29 * classname of an opened input stream.
30 *
31 */
32 public class OutputStreamWrapper
33 {
34 /***
35 * The wrapped output stream.
36 */
37 private OutputStream out;
38
39 /***
40 * The classname of the written Java class. This parameter
41 * is set by the enhancer.
42 */
43 private String className = null;
44
45 /***
46 * Constructs a new object.
47 *
48 * @param out The output stream to wrap.
49 */
50 public OutputStreamWrapper(OutputStream out)
51 {
52 this.out = out;
53 }
54
55 /***
56 * Gets the wrapped output stream.
57 *
58 * @return The wrapped output stream.
59 */
60 public final OutputStream getStream()
61 {
62 return out;
63 }
64
65 /***
66 * Gets the classname of the written Java class. This method should be
67 * called after the class has been enhanced.
68 *
69 * @return The name of the written Java class.
70 */
71 public final String getClassName()
72 {
73 return className;
74 }
75
76 /***
77 * Sets the name of the written Java class. This method should be called
78 * by the enhancer.
79 *
80 * @param classname The name of the Java class.
81 */
82 public final void setClassName(String classname)
83 {
84 this.className = classname;
85 }
86 }