01: package org.conform.mdl;
02:
03: import java.util.*;
04:
05: /**
06: * Created by IntelliJ IDEA.
07: * User: nina
08: * Date: 23.08.2003
09: * Time: 22:55:39
10: * To change this template use Options | File Templates.
11: */
12: class MutableExpression extends Expression {
13: private Object property;
14: private Vector argV = new Vector();
15:
16: private String capitalize(String propertyName) {
17: if (propertyName.length() == 0) {
18: return propertyName;
19: }
20: return propertyName.substring(0, 1).toUpperCase()
21: + propertyName.substring(1);
22: }
23:
24: public MutableExpression() {
25: super (null, null, null);
26: }
27:
28: public Object[] getArguments() {
29: return argV.toArray();
30: }
31:
32: public String getMethodName() {
33: if (property == null) {
34: return super .getMethodName();
35: }
36: int setterArgs = (property instanceof String) ? 1 : 2;
37: String methodName = (argV.size() == setterArgs) ? "set" : "get";
38: if (property instanceof String) {
39: return methodName + capitalize((String) property);
40: } else {
41: return methodName;
42: }
43: }
44:
45: public void addArg(Object arg) {
46: argV.add(arg);
47: }
48:
49: public void setTarget(Object target) {
50: this .target = target;
51: }
52:
53: public void setMethodName(String methodName) {
54: this .methodName = methodName;
55: }
56:
57: public void setProperty(Object property) {
58: this.property = property;
59: }
60: }
|