01: /*
02: * Copyright 2005 Joe Walker
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.directwebremoting.bayeux;
17:
18: import java.io.IOException;
19:
20: import org.directwebremoting.ScriptBuffer;
21: import org.directwebremoting.extend.ConverterManager;
22: import org.directwebremoting.extend.MarshallException;
23: import org.directwebremoting.extend.ScriptBufferUtil;
24: import org.directwebremoting.extend.ScriptConduit;
25:
26: /**
27: * @author Greg Wilkins [gregw at webtide dot com]
28: * @author Joe Walker [joe at getahead dot ltd dot uk]
29: */
30: public class BayeuxScriptConduit extends ScriptConduit {
31: /**
32: *
33: */
34: public BayeuxScriptConduit(ConverterManager converterManager,
35: boolean jsonOutput) {
36: super (ScriptConduit.RANK_FAST);
37:
38: this .converterManager = converterManager;
39: this .jsonOutput = jsonOutput;
40: }
41:
42: /* (non-Javadoc)
43: * @see org.directwebremoting.extend.ScriptConduit#addScript(org.directwebremoting.ScriptBuffer)
44: */
45: @Override
46: public boolean addScript(ScriptBuffer script) throws IOException,
47: MarshallException {
48: builder.append(ScriptBufferUtil.createOutput(script,
49: converterManager, jsonOutput));
50: return true;
51: }
52:
53: /* (non-Javadoc)
54: * @see org.directwebremoting.extend.ScriptConduit#toString()
55: */
56: @Override
57: public String toString() {
58: return builder.toString();
59: }
60:
61: /**
62: * Are we outputting in JSON mode?
63: */
64: private boolean jsonOutput = false;
65:
66: private ConverterManager converterManager;
67:
68: private StringBuilder builder = new StringBuilder();
69: }
|