0d36d75a2b63ec9e58b903cc74fb95ac468a5fa7
[controller.git] / opendaylight / md-sal / sal-dom-xsql / src / main / java / org / opendaylight / controller / md / sal / dom / xsql / jdbc / JDBCCommand.java
1 /*
2  * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.md.sal.dom.xsql.jdbc;
10
11 import java.io.Serializable;
12 import java.util.Map;
13
14 import org.opendaylight.controller.md.sal.dom.xsql.XSQLBluePrint;
15
16 public class JDBCCommand implements Serializable {
17     private static final long serialVersionUID = 1L;
18
19     public int type = 0;
20     public static final int TYPE_EXECUTE_QUERY = 1;
21     public static final int TYPE_QUERY_REPLY = 2;
22     public static final int TYPE_QUERY_RECORD = 3;
23     public static final int TYPE_QUERY_FINISH = 4;
24     public static final int TYPE_QUERY_ERROR = 5;
25     public static final int TYPE_METADATA = 6;
26     public static final int TYPE_METADATA_REPLY = 7;
27
28     private JDBCResultSet rs = null;
29     private Map<String, Object> record = null;
30     private int rsID = -1;
31     private Exception err = null;
32     private XSQLBluePrint bluePrint = null;
33
34     public JDBCCommand() {
35
36     }
37
38     public void setType(int t) {
39         this.type = t;
40     }
41
42     public JDBCCommand(Exception _err, int _RSID) {
43         this.type = TYPE_QUERY_ERROR;
44         this.err = _err;
45         this.rsID = _RSID;
46     }
47
48     public JDBCCommand(XSQLBluePrint bl) {
49         this.type = TYPE_METADATA_REPLY;
50         this.bluePrint = bl;
51     }
52
53     public JDBCCommand(JDBCResultSet _rs, int _type) {
54         this.type = TYPE_EXECUTE_QUERY;
55         this.rs = _rs;
56         this.type = _type;
57         this.rsID = rs.getID();
58     }
59
60     public JDBCCommand(Map<String, Object> _record, int _rsID) {
61         this.record = _record;
62         this.rsID = _rsID;
63         this.type = TYPE_QUERY_RECORD;
64     }
65
66     public JDBCCommand(int _rsID) {
67         this.rsID = _rsID;
68         this.type = TYPE_QUERY_FINISH;
69     }
70
71     public int getType() {
72         return this.type;
73     }
74
75     public JDBCResultSet getRS() {
76         return this.rs;
77     }
78
79     public Map<String, Object> getRecord() {
80         return this.record;
81     }
82
83     public int getRSID() {
84         return this.rsID;
85     }
86
87     public Exception getERROR() {
88         return this.err;
89     }
90
91     public XSQLBluePrint getBluePrint() {
92         return this.bluePrint;
93     }
94 }