01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: EmbeddedStream.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.engine;
09:
10: import com.uwyn.rife.config.RifeConfig;
11: import com.uwyn.rife.tools.ExceptionUtils;
12: import java.io.ByteArrayOutputStream;
13: import java.io.IOException;
14: import java.io.UnsupportedEncodingException;
15: import java.util.ArrayList;
16: import java.util.logging.Logger;
17:
18: class EmbeddedStream extends ByteArrayOutputStream {
19: private ArrayList<CharSequence> mEmbeddedContent = new ArrayList<CharSequence>();
20:
21: public void write(CharSequence chars) {
22: mEmbeddedContent.add(chars);
23: }
24:
25: public void flush() throws IOException {
26: try {
27: write(toString(RifeConfig.Engine.getResponseEncoding()));
28: } catch (UnsupportedEncodingException e) {
29: Logger.getLogger("com.uwyn.rife.engine").severe(
30: ExceptionUtils.getExceptionStackTrace(e));
31: }
32:
33: reset();
34: }
35:
36: ArrayList<CharSequence> getEmbeddedContent() {
37: return mEmbeddedContent;
38: }
39: }
|