01: package org.gui4j.core.call;
02:
03: import java.util.Map;
04:
05: import org.apache.commons.logging.Log;
06: import org.apache.commons.logging.LogFactory;
07: import org.gui4j.exception.Gui4jUncheckedException;
08:
09: final class Gui4jAccessSetValue extends Gui4jAccessImpl {
10: static final Log mLogger = LogFactory
11: .getLog(Gui4jAccessSetValue.class);
12:
13: private final ParseCtx mParseCtx;
14: private final String mParamName;
15:
16: Gui4jAccessSetValue(ParseCtx parseCtx, String accessPath) {
17: mParseCtx = parseCtx;
18: // accessPath.charAt(parsePosition.i) = '?'
19: parseCtx.i = parseCtx.i + 1;
20: int endIdx = minIndex(accessPath, ".,;)}", parseCtx.i);
21: if (endIdx == -1) {
22: mParamName = accessPath.substring(parseCtx.i);
23: parseCtx.i = accessPath.length();
24: } else {
25: mParamName = accessPath.substring(parseCtx.i, endIdx);
26: parseCtx.i = endIdx;
27: }
28: if (parseCtx.getValueClass(mParamName) == null) {
29: Object[] args = { mParamName, accessPath };
30: throw new Gui4jUncheckedException.ResourceError(parseCtx
31: .getConfigurationName(), parseCtx.getLineNumber(),
32: RESOURCE_ERROR_access_value_type_not_defined, args);
33: }
34: parseCtx.addUsedParam(mParamName);
35: }
36:
37: Class getResultClass() {
38: Class c = mParseCtx.getValueClass(mParamName);
39: return c;
40: }
41:
42: public boolean isConstant() {
43: return false;
44: }
45:
46: public Object getValue(Object baseInstance, Object this Instance,
47: Map paramMap) {
48: Object value = null;
49: if (paramMap != null) {
50: value = paramMap.get(mParamName);
51: }
52: if (value == null && !paramMap.containsKey(mParamName)) {
53: mLogger.warn("Parameter " + mParamName
54: + " is not defined in paramMap, accessPath="
55: + mParseCtx.getAccessPath());
56: }
57: return value;
58: }
59:
60: }
|