KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jdo > api > persistence > enhancer > OutputStreamWrapper


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 //OutputStreamWrapper - Java Source
25

26
27 //***************** package ***********************************************
28

29 package com.sun.jdo.api.persistence.enhancer;
30
31
32 //***************** import ************************************************
33

34 import java.io.OutputStream JavaDoc;
35
36
37 //#########################################################################
38
/**
39  * This class serves as a wrapper for an output stream of a class file. The
40  * stream is passed as a parameter to the byte code enhancer, that can
41  * sets the classname of the written Java class to the wrapper.
42  * <br>
43  * This wrapper is necessary to determine the classname outside the enhancer,
44  * after the class has been enhanced, since do do not always know the
45  * classname of an opened input stream.
46  * </p>
47  */

48 //#########################################################################
49

50 public class OutputStreamWrapper
51 {
52
53
54     /**
55      * The wrapped output stream.
56      */

57     private OutputStream JavaDoc out;
58
59
60     /**
61      * The classname of the written Java class. This parameter
62      * is set by the enhancer.
63      */

64     private String JavaDoc className = null;
65
66
67     /**********************************************************************
68      * Constructs a new object.
69      *
70      * @param out The output stream to wrap.
71      *********************************************************************/

72
73     public OutputStreamWrapper (OutputStream JavaDoc out)
74     {
75
76         this.out = out;
77
78     } //OutputStreamWrapper.<init>
79

80
81     /**********************************************************************
82      * Gets the wrapped output stream.
83      *
84      * @return The wrapped output stream.
85      *
86      * @see #out
87      *********************************************************************/

88
89     public final OutputStream JavaDoc getStream ()
90     {
91
92         return this.out;
93
94     } //NamedOuptutStream.getStream()
95

96
97     /**********************************************************************
98      * Gets the classname of the written Java class. This method should be
99      * called after the class has been enhanced.
100      *
101      * @return The name of the written Java class.
102      *
103      * @see #className
104      *********************************************************************/

105
106     public final String JavaDoc getClassName ()
107     {
108
109         return this.className;
110
111     } //OutputStreamWrapper.getClassName()
112

113
114     /**********************************************************************
115      * Sets the name of the written Java class. This method should be called
116      * by the enhancer.
117      *
118      * @param classname The name of the Java class.
119      *
120      * @see #className
121      *********************************************************************/

122
123     public final void setClassName (String JavaDoc classname)
124     {
125
126         this.className = classname;
127
128     } //OutputStreamWrapper.setClassName()
129

130
131 } //OutputStreamWrapper
132

133
134 //OutputStreamWrapper - Java Source End
135
Popular Tags