01: // Copyright 2006 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.internal.util;
16:
17: import java.io.BufferedOutputStream;
18: import java.io.IOException;
19: import java.io.ObjectOutputStream;
20: import java.util.zip.GZIPOutputStream;
21:
22: /**
23: * Wraps a {@link Base64OutputStream} with a {@link GZIPOutputStream} as an
24: * {@link ObjectOutputStream}. This allows an object (or objects) to be encoded into a Base64
25: * string (accessed via {@link #toBase64()}).
26: *
27: * @see Base64ObjectInputStream
28: */
29: public class Base64ObjectOutputStream extends ObjectOutputStream {
30: private final Base64OutputStream _output;
31:
32: private Base64ObjectOutputStream(Base64OutputStream output)
33: throws IOException {
34: super (new BufferedOutputStream(new GZIPOutputStream(output)));
35:
36: _output = output;
37: }
38:
39: public Base64ObjectOutputStream() throws IOException {
40: this (new Base64OutputStream());
41: }
42:
43: public String toBase64() {
44: return _output.toBase64();
45: }
46: }
|