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.dwrp;
17:
18: import org.directwebremoting.WebContextFactory;
19: import org.directwebremoting.extend.NonNestedOutboundVariable;
20: import org.directwebremoting.util.LocalUtil;
21:
22: /**
23: * An OutboundVariable that can not be recursive.
24: * @author Joe Walker [joe at getahead dot ltd dot uk]
25: */
26: public class ErrorOutboundVariable extends NonNestedOutboundVariable {
27: /**
28: * Default ctor that leaves blank (not null) members
29: * @param errorMessage Some message for the developer to see.
30: */
31: public ErrorOutboundVariable(String errorMessage) {
32: super (sanitizeErrorMessage(errorMessage));
33: }
34:
35: /* (non-Javadoc)
36: * @see org.directwebremoting.extend.OutboundVariable#getAssignCode()
37: */
38: public static String sanitizeErrorMessage(String errorMessage) {
39: boolean debug = false;
40:
41: Object debugVal = WebContextFactory.get().getContainer()
42: .getBean("debug");
43: if (debugVal != null) {
44: debug = LocalUtil.simpleConvert(debugVal.toString(),
45: Boolean.class);
46: }
47:
48: if (debug) {
49: return "## CONVERSION ERROR: " + errorMessage + " ##";
50: } else {
51: return "null";
52: }
53: }
54: }
|