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