1
2
3
4
5
6
7
8
9
10
11 package com.legstar.coxb.impl;
12
13 import java.util.ArrayList;
14 import java.util.List;
15
16 import com.legstar.coxb.CobolElement;
17 import com.legstar.coxb.ICobolComplexBinding;
18 import com.legstar.coxb.host.HostException;
19 import com.legstar.coxb.common.CArrayBinding;
20
21
22
23
24
25 public abstract class AbstractArrayAlphaNumericBinding extends CArrayBinding {
26
27
28 private List < String > mList = null;
29
30
31
32
33
34
35
36
37
38
39 public AbstractArrayAlphaNumericBinding(
40 final String bindingName,
41 final String jaxbName,
42 final Class < ? > jaxbType,
43 final CobolElement cobolAnnotations,
44 final ICobolComplexBinding parentBinding) {
45 super(bindingName, jaxbName, jaxbType, cobolAnnotations, parentBinding);
46 }
47
48
49
50
51 public List < String > getStringList() {
52 return mList;
53 }
54
55
56
57
58 public void setStringList(
59 final List < String > list) {
60 mList = list;
61 }
62
63
64 public Object getObjectValue(
65 final Class < ? > type) throws HostException {
66 if (type.equals(String.class)) {
67 return mList;
68 } else {
69 throw new HostException("Attempt to get binding " + getBindingName()
70 + " as an incompatible type " + type);
71 }
72 }
73
74
75 @SuppressWarnings("unchecked")
76 public void setObjectValue(final Object value) throws HostException {
77 if (value == null) {
78 mList = null;
79 return;
80 }
81 if (value instanceof List) {
82 if (((List <?>) value).size() == 0) {
83 mList = new ArrayList < String >();
84 return;
85 }
86
87
88 Object item = ((List <?>) value).get(0);
89 if (item instanceof String) {
90 mList = (List <String>) value;
91 return;
92 }
93 }
94 throw new HostException("Attempt to set binding " + getBindingName()
95 + " from an incompatible value " + value);
96 }
97
98
99 public boolean isSet() {
100 return (mList != null);
101 }
102 }