1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.synchronoss.cpo.meta.domain;
22
23 import org.slf4j.*;
24 import org.synchronoss.cpo.meta.bean.CpoFunctionBean;
25
26 import java.util.*;
27
28 public class CpoFunction extends CpoFunctionBean {
29
30 private static final Logger logger = LoggerFactory.getLogger(CpoFunction.class);
31 List<CpoArgument> arguments = new ArrayList<CpoArgument>();
32
33 public CpoFunction() {
34 }
35
36 public List<CpoArgument> getArguments() {
37 return arguments;
38 }
39
40 public void addArgument(CpoArgument argument) {
41 if (argument != null) {
42 arguments.add(argument);
43 }
44 }
45
46 public boolean removeArgument(CpoArgument argument) {
47 if (argument != null) {
48 return arguments.remove(argument);
49 }
50 return false;
51 }
52
53 public boolean removeArgument(int index) {
54 if (index > 0 && index < arguments.size()) {
55 return (arguments.remove(index) != null);
56 }
57 return false;
58 }
59
60
61
62
63
64
65
66 public String parameterToString(CpoFunction function) {
67 List<CpoArgument> args;
68 int j;
69 CpoArgument argument;
70 CpoAttribute attribute;
71 int type = 0;
72 Class<?> c;
73 StringBuilder sb = new StringBuilder("Parameter list for ");
74
75 if (function == null) {
76 return " null function.";
77 }
78
79
80
81 args = function.getArguments();
82
83 for (j = 1; j <= args.size(); j++) {
84 argument = args.get(j - 1);
85
86 if (argument != null) {
87 try {
88 attribute = argument.getAttribute();
89 c = attribute.getGetter().getReturnType();
90
91
92 if (c != null) {
93 sb.append(" col" + j + ":" + c.getName() + " type:"
94 + type + " ");
95 } else {
96 sb.append(j + ":null type:" + type + " ");
97 }
98 } catch (Exception e) {
99 String msg = "parameterToString() Failed:";
100 logger.error(msg);
101 }
102 }
103 }
104
105 return sb.toString();
106 }
107
108 @Override
109 public String toString() {
110 return this.getName();
111 }
112
113 public String toStringFull() {
114 return super.toString();
115 }
116 }