指令数据采集(二)--Instruction 指令对象的实现

1.指令对象需要实现Cloneable接口,来保证每条指令都可以进行拷贝

2.同时指令对象需要有个包含本身的属性,需要能够存储子指令对象能够存储子指令

3.指令对象需要输入,输出参数的属性,保存当前的指令结果,指令的出参和入参也需要实现Cloneable接口,因为指令在复制的时候,属性也需要进行复制创建

下面开始进行代码实现

1.出入参数的设置

 

 1 public class Param implements Cloneable{
 2     /**
 3      * 参数的关键字
 4      */
 5     private ParamKey paramKey;
 6     /**
 7      * 参数值
 8      */
 9     private ParamValue paramValue;
10 
11     public Param(){}
12     public ParamKey getParamKey() {
13         return paramKey;
14     }
15 
16     public void setParamKey(ParamKey paramKey) {
17         this.paramKey = paramKey;
18     }
19 
20     public ParamValue getParamValue() {
21         return paramValue;
22     }
23 
24     public void setParamValue(ParamValue paramValue) {
25         this.paramValue = paramValue;
26     }
27 
28 
29     @Override
30     public Param clone() throws CloneNotSupportedException {
31         Param param = (Param)(super.clone());
32         if(this.paramValue!=null) {
33             param.setParamValue(this.paramValue.clone());
34         }
35         if(this.paramKey!=null) {
36             param.setParamKey(this.paramKey.clone());
37         }
38         return param;
39     }
40 
41     @Override
42     public String toString() {
43         return "Param{" +
44                 "paramKey=" + paramKey +
45                 ", paramValue=" + paramValue +
46                 '}';
47     }
48 }
View Code

2.出入参数的ParamKey ParamValue 对象的封装

类似于一种Key Value的方式,但是需要封装条件进行判断,并且需要将数据插入到对应的表和字段当中,所以这边还需要进行封装

  1 public class ParamKey implements Cloneable{
  2     private String keyId;
  3     private String keyDesc;
  4     private String keyName;
  5     private Integer keySeq;
  6     //关联的指令ID
  7     private String relaInstId;
  8     /**
  9      * 指令关联的插入的列的ID
 10      */
 11     private String relaColumnId;
 12     private String relaColumnNo;
 13     private String tableNo;
 14 
 15     /**
 16      * 条件判断 的记录
 17      * 作为指令的上下入参的使用
 18      */
 19     /**
 20      * 是否是条件
 21      */
 22     public boolean isCondition;
 23     /**
 24      * 返回值枚举
 25      */
 26     public ConValueEnum conValueType;
 27 
 28     public ParamKey(){}
 29     public String getKeyId() {
 30         return keyId;
 31     }
 32 
 33     public void setKeyId(String keyId) {
 34         this.keyId = keyId;
 35     }
 36 
 37     public String getKeyDesc() {
 38         return keyDesc;
 39     }
 40 
 41     public void setKeyDesc(String keyDesc) {
 42         this.keyDesc = keyDesc;
 43     }
 44 
 45     public String getKeyName() {
 46         return keyName;
 47     }
 48 
 49     public void setKeyName(String keyName) {
 50         this.keyName = keyName;
 51     }
 52 
 53     public Integer getKeySeq() {
 54         return keySeq;
 55     }
 56 
 57     public void setKeySeq(Integer keySeq) {
 58         this.keySeq = keySeq;
 59     }
 60 
 61     public String getRelaInstId() {
 62         return relaInstId;
 63     }
 64 
 65     public void setRelaInstId(String relaInstId) {
 66         this.relaInstId = relaInstId;
 67     }
 68 
 69     @Override
 70     protected ParamKey clone() throws CloneNotSupportedException {
 71         ParamKey paramKey = (ParamKey)(super.clone());
 72         if(StringUtils.isNotBlank(keyId)) {
 73             paramKey.setKeyId(new String(this.keyId));
 74         }else {
 75             paramKey.setKeyId("");
 76         }
 77         if(StringUtils.isNotBlank(this.keyName)) {
 78             paramKey.setKeyName(new String(this.keyName));
 79         }else {
 80             paramKey.setKeyName("");
 81         }
 82         if(StringUtils.isNotBlank(this.keyDesc)) {
 83             paramKey.setKeyDesc(new String(this.keyDesc));
 84         }else {
 85             paramKey.setKeyDesc("");
 86         }
 87         if(this.keySeq!=null) {
 88             paramKey.setKeySeq(new Integer(this.keySeq));
 89         }else {
 90             paramKey.setKeySeq(new Integer(-1));
 91         }
 92         if(StringUtils.isNotBlank(this.relaInstId)){
 93             paramKey.setKeyDesc(new String(this.relaInstId));
 94         }else {
 95             paramKey.setRelaInstId("");
 96         }
 97         if(StringUtils.isNotBlank(this.relaColumnId)){
 98             paramKey.setRelaColumnId(new String(this.relaColumnId));
 99         }else {
100             paramKey.setRelaColumnId("");
101         }
102         if(StringUtils.isNotBlank(this.relaColumnNo)){
103             paramKey.setRelaColumnId(new String(this.relaColumnNo));
104         }else {
105             paramKey.setRelaColumnId("");
106         }
107         if(StringUtils.isNotBlank(this.tableNo)){
108             paramKey.setTableNo(new String(this.tableNo));
109         }else {
110             paramKey.setRelaColumnId("");
111         }
112         if(this.isCondition){
113             paramKey.setIsCondition(new Boolean(this.isCondition));
114         }
115         
116         if(this.getConValueType()!=null){
117             paramKey.setConValueType(this.getConValueType());
118         }
119         return paramKey;
120     }
121 
122     public String getRelaColumnId() {
123         return relaColumnId;
124     }
125 
126     public void setRelaColumnId(String relaColumnId) {
127         this.relaColumnId = relaColumnId;
128     }
129 
130     public String getRelaColumnNo() {
131         return relaColumnNo;
132     }
133 
134     public void setRelaColumnNo(String relaColumnNo) {
135         this.relaColumnNo = relaColumnNo;
136     }
137 
138     public String getTableNo() {
139         return tableNo;
140     }
141 
142     public void setTableNo(String tableNo) {
143         this.tableNo = tableNo;
144     }
145 
146     public boolean isCondition() {
147         return isCondition;
148     }
149 
150     public void setIsCondition(boolean isCondition) {
151         this.isCondition = isCondition;
152     }
153 
154     public ConValueEnum getConValueType() {
155         return conValueType;
156     }
157 
158     public void setConValueType(ConValueEnum conValueType) {
159         this.conValueType = conValueType;
160     }
161 
162     @Override
163     public String toString() {
164         return "ParamKey{" +
165                 "keyId='" + keyId + '\'' +
166                 ", keyDesc='" + keyDesc + '\'' +
167                 ", keyName='" + keyName + '\'' +
168                 ", keySeq=" + keySeq +
169                 ", relaInstId='" + relaInstId + '\'' +
170                 ", relaColumnId='" + relaColumnId + '\'' +
171                 ", relaColumnNo='" + relaColumnNo + '\'' +
172                 ", tableNo='" + tableNo + '\'' +
173                 '}';
174     }
175 }
View Code
 1 public class ParamValue implements Cloneable{
 2     private String valueId;
 3     private String value;
 4     public ParamValue(){}
 5     public String getValueId() {
 6         return valueId;
 7     }
 8 
 9     public void setValueId(String valueId) {
10         this.valueId = valueId;
11     }
12 
13     public String getValue() {
14         return value;
15     }
16 
17     public void setValue(String value) {
18         this.value = value;
19     }
20 
21     @Override
22     public ParamValue clone() throws CloneNotSupportedException{
23         ParamValue paramValue = (ParamValue)(super.clone());
24         if(StringUtils.isNotBlank(valueId)) {
25             paramValue.setValueId(new String(valueId));
26         }else {
27             paramValue.setValueId("");
28         }
29         if(StringUtils.isNotBlank(value)) {
30             paramValue.setValue(new String(value));
31         }else {
32             paramValue.setValue("");
33         }
34         return paramValue;
35     }
36     @Override
37     public String toString() {
38         return "ParamValue{" +
39                 "valueId='" + valueId + '\'' +
40                 ", value='" + value + '\'' +
41                 '}';
42     }
43 }
View Code

ParamKey 定义的时候,需要关联的指令,关联的表,关联的表字段,关联的表和字段用于数据的插入,插入到配置好的表字段当中。是否是条件进行判断以及返回值的枚举,用于条件判断枚举类型存到数据库当中的字典值进行判断,正则则可以通过正则表达式来进行处理

 1 public  enum  ConValueEnum {
 2     /**
 3      * 判断的值为正则表达式
 4      */
 5     REG("2002","REG"),
 6     /**
 7      * 判断的值为枚举类型
 8      */
 9     ENUM("2001","ENUM");
10     private String conValueTypeDesc;
11     private String conValueTypeNo;
12     ConValueEnum(String conValueTypeNo,String conValueTypeDesc){
13         this.conValueTypeDesc = conValueTypeDesc;
14         this.conValueTypeNo = conValueTypeNo;
15     }
16 
17     public String getConValueTypeDesc() {
18         return conValueTypeDesc;
19     }
20 
21     public String getConValueTypeNo() {
22         return conValueTypeNo;
23     }
24 
25     @Override
26     public String toString() {
27         return "ConValueEnum{" +
28                 "conValueTypeDesc='" + conValueTypeDesc + '\'' +
29                 ", conValueTypeNo='" + conValueTypeNo + '\'' +
30                 '}';
31     }
32 }
View Code

 

posted @ 2017-08-25 16:31  BinarySheep  阅读(270)  评论(0编辑  收藏  举报