Merge "Remove unused warnings suppressions"
[controller.git] / opendaylight / md-sal / sal-dom-xsql / src / main / java / org / opendaylight / controller / md / sal / dom / xsql / jdbc / JDBCResultSet.java
1 package org.opendaylight.controller.md.sal.dom.xsql.jdbc;
2
3 import java.io.InputStream;
4 import java.io.Reader;
5 import java.io.Serializable;
6 import java.lang.reflect.Method;
7 import java.lang.reflect.Proxy;
8 import java.math.BigDecimal;
9 import java.net.URL;
10 import java.sql.Array;
11 import java.sql.Blob;
12 import java.sql.Clob;
13 import java.sql.Date;
14 import java.sql.NClob;
15 import java.sql.Ref;
16 import java.sql.ResultSet;
17 import java.sql.ResultSetMetaData;
18 import java.sql.RowId;
19 import java.sql.SQLException;
20 import java.sql.SQLWarning;
21 import java.sql.SQLXML;
22 import java.sql.Statement;
23 import java.sql.Time;
24 import java.sql.Timestamp;
25 import java.util.ArrayList;
26 import java.util.Calendar;
27 import java.util.HashMap;
28 import java.util.HashSet;
29 import java.util.LinkedList;
30 import java.util.List;
31 import java.util.Map;
32 import java.util.Set;
33 import java.util.concurrent.ConcurrentHashMap;
34
35 import org.opendaylight.controller.md.sal.dom.xsql.XSQLBluePrint;
36 import org.opendaylight.controller.md.sal.dom.xsql.XSQLBluePrintNode;
37 import org.opendaylight.controller.md.sal.dom.xsql.XSQLColumn;
38 import org.opendaylight.controller.md.sal.dom.xsql.XSQLCriteria;
39 import org.opendaylight.controller.md.sal.dom.xsql.XSQLODLUtils;
40
41 public class JDBCResultSet implements Serializable, ResultSet,
42         ResultSetMetaData {
43     private static final long serialVersionUID = -7450200738431047057L;
44
45     private String sql = null;
46     private List<XSQLBluePrintNode> tablesInQuery = new ArrayList<XSQLBluePrintNode>();
47     private Map<String, XSQLBluePrintNode> tablesInQueryMap = new ConcurrentHashMap<String, XSQLBluePrintNode>();
48     private List<XSQLColumn> fieldsInQuery = new ArrayList<XSQLColumn>();
49     private transient LinkedList<Map> records = new LinkedList<Map>();
50     private transient Map currentRecord = null;
51     private boolean finished = false;
52     private int id = 0;
53     private static Integer nextID = new Integer(0);
54     public int numberOfTasks = 0;
55     private Map<String, Map<XSQLColumn, List<XSQLCriteria>>> criteria = new ConcurrentHashMap<String, Map<XSQLColumn, List<XSQLCriteria>>>();
56     private Exception err = null;
57     private List<Record> EMPTY_RESULT = new LinkedList<Record>();
58     private transient Map<String,JDBCResultSet> subQueries = new HashMap<String,JDBCResultSet>();
59
60     public ResultSet getProxy() {
61          return (ResultSet) Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {ResultSet.class }, new JDBCProxy(this));
62     }
63
64     public void setSQL(String _sql) {
65         this.sql = _sql;
66     }
67
68     public JDBCResultSet addSubQuery(String _sql,String logicalName) {
69         if(subQueries == null)
70             subQueries = new HashMap<String,JDBCResultSet>();
71         JDBCResultSet rs = new JDBCResultSet(_sql);
72         this.subQueries.put(logicalName,rs);
73         return rs;
74     }
75
76     public Map<String,JDBCResultSet> getSubQueries() {
77         if(this.subQueries==null)
78             this.subQueries = new HashMap<>();
79         return this.subQueries;
80     }
81
82     public JDBCResultSet(String _sql) {
83         synchronized (JDBCResultSet.class) {
84             nextID++;
85             id = nextID;
86         }
87         this.sql = _sql;
88     }
89
90     public String getSQL() {
91         return this.sql;
92     }
93
94     public void setError(Exception _err) {
95         this.err = _err;
96     }
97
98     public Exception getError() {
99         return this.err;
100     }
101
102     public void updateData(JDBCResultSet rs) {
103         synchronized (this) {
104             this.tablesInQuery = rs.tablesInQuery;
105             this.tablesInQueryMap = rs.tablesInQueryMap;
106             this.fieldsInQuery = rs.fieldsInQuery;
107             this.notifyAll();
108         }
109     }
110
111     public int isObjectFitCriteria(Map objValues, String tableName) {
112         Map<XSQLColumn, List<XSQLCriteria>> tblCriteria = criteria
113                 .get(tableName);
114         if (tblCriteria == null) {
115             return 1;
116         }
117         for (Map.Entry<XSQLColumn, List<XSQLCriteria>> cc : tblCriteria
118                 .entrySet()) {
119             for (XSQLCriteria c : cc.getValue()) {
120                 Object value = objValues.get(cc.getKey().toString());
121                 int result = c.checkValue(value);
122                 if (result == 0) {
123                     return 0;
124                 }
125             }
126         }
127         return 1;
128     }
129
130     public int isObjectFitCriteria(Object element, Class<?> cls) {
131         Map<XSQLColumn, List<XSQLCriteria>> tblCriteria = criteria.get(cls
132                 .getName());
133         if (tblCriteria == null) {
134             return 1;
135         }
136         for (Map.Entry<XSQLColumn, List<XSQLCriteria>> cc : tblCriteria
137                 .entrySet()) {
138             for (XSQLCriteria c : cc.getValue()) {
139                 int result = c.isObjectFitCriteria(element, cc.getKey()
140                         .getName());
141                 if (result == 0) {
142                     return 0;
143                 }
144             }
145         }
146         return 1;
147     }
148
149     public Map<String, Map<XSQLColumn, List<XSQLCriteria>>> getCriteria() {
150         return this.criteria;
151     }
152
153     public int getID() {
154         return this.id;
155     }
156
157     public List<XSQLBluePrintNode> getTables() {
158         return tablesInQuery;
159     }
160
161     public void addTableToQuery(XSQLBluePrintNode node) {
162         if (this.tablesInQueryMap.containsKey(node.getBluePrintNodeName())) {
163             return;
164         }
165         this.tablesInQuery.add(node);
166         this.tablesInQueryMap.put(node.getBluePrintNodeName(), node);
167     }
168
169     public List<XSQLColumn> getFields() {
170         return this.fieldsInQuery;
171     }
172
173     public XSQLBluePrintNode getMainTable() {
174         if (tablesInQuery.size() == 1) {
175             return tablesInQuery.get(0);
176         }
177         XSQLBluePrintNode result = null;
178         for (XSQLBluePrintNode node : tablesInQuery) {
179             if (result == null) {
180                 result = node;
181             } else if (result.getLevel() < node.getLevel()) {
182                 result = node;
183             }
184         }
185         return result;
186     }
187
188     public boolean isFinished() {
189         return finished;
190     }
191
192     public void setFinished(boolean b) {
193         this.finished = b;
194     }
195
196     public int size() {
197         return this.records.size();
198     }
199
200     public void addRecord(Map r) {
201         synchronized (this) {
202             if (records == null) {
203                 records = new LinkedList<Map>();
204             }
205             records.add(r);
206             this.notifyAll();
207         }
208     }
209
210     public void addRecord(ArrayList<?> hierarchy) {
211         Map rec = new HashMap();
212         for (int i = hierarchy.size() - 1; i >= 0; i--) {
213             Object element = hierarchy.get(i);
214             for (XSQLColumn c : fieldsInQuery) {
215                 if (c.getTableName().equals(element.getClass().getSimpleName())) {
216                     try {
217                         Method m = element.getClass().getMethod(c.getName(),
218                                 null);
219                         Object value = m.invoke(element, null);
220                         rec.put(c.getName(), value);
221                     } catch (Exception err) {
222                         err.printStackTrace();
223                     }
224                 }
225             }
226         }
227         this.records.add(rec);
228     }
229
230     public boolean next() {
231         this.currentRecord = null;
232         if (records == null) {
233             records = new LinkedList<Map>();
234         }
235         while (!finished || records.size() > 0) {
236             synchronized (this) {
237                 if (records.size() == 0) {
238                     try {
239                         this.wait(1000);
240                     } catch (Exception err) {
241                     }
242                     if (records.size() > 0) {
243                         try {
244                             currentRecord = records.removeFirst();
245                             return true;
246                         } finally {
247                             this.notifyAll();
248                         }
249                     }
250                 } else {
251                     try {
252                         currentRecord = records.removeFirst();
253                         return true;
254                     } finally {
255                         this.notifyAll();
256                     }
257                 }
258             }
259         }
260         return false;
261     }
262
263     public Map getCurrent() {
264         return this.currentRecord;
265     }
266
267     private void createRecord(Object data, XSQLBluePrintNode node) {
268         Map rec = new HashMap();
269         for (XSQLColumn c : this.fieldsInQuery) {
270             if (c.getTableName().equals(node.getBluePrintNodeName())) {
271                 try {
272                     Method m = node.getInterface().getMethod(c.getName(), null);
273                     Object value = m.invoke(data, null);
274                     if (value != null) {
275                         rec.put(c.getName(), value);
276                     } else {
277                         rec.put(c.getName(), "");
278                     }
279                 } catch (Exception err) {
280                     err.printStackTrace();
281                 }
282
283             }
284         }
285     }
286
287     public static class Record {
288         public Map data = new HashMap();
289         public Object element = null;
290
291         public Map getRecord() {
292             return this.data;
293         }
294     }
295
296     private Map collectColumnValues(Object node, XSQLBluePrintNode bpn) {
297         Map subChildren = XSQLODLUtils.getChildren(node);
298         Map result = new HashMap();
299         for (Object stc : subChildren.values()) {
300             if (stc.getClass().getName().endsWith("ImmutableAugmentationNode")) {
301                 Map values = XSQLODLUtils.getChildren(stc);
302                 for (Object key : values.keySet()) {
303                     Object val = values.get(key);
304                     if (val.getClass().getName().endsWith("ImmutableLeafNode")) {
305                         Object value = XSQLODLUtils.getValue(val);
306                         String k = XSQLODLUtils.getNodeName(val);
307                         if (value != null) {
308                             result.put(bpn.getBluePrintNodeName() + "." + k,
309                                     value.toString());
310                         }
311                     }
312                 }
313             } else if (stc.getClass().getName().endsWith("ImmutableLeafNode")) {
314                 String k = XSQLODLUtils.getNodeName(stc);
315                 Object value = XSQLODLUtils.getValue(stc);
316                 if (value != null) {
317                     result.put(bpn.getBluePrintNodeName() + "." + k,
318                             value.toString());
319                 }
320             }
321         }
322         return result;
323     }
324
325     private void addToData(Record rec, XSQLBluePrintNode bpn,
326             XSQLBluePrint bluePrint, Map fullRecord) {
327         XSQLBluePrintNode eNodes[] = bluePrint
328                 .getBluePrintNodeByODLTableName(XSQLODLUtils
329                         .getNodeIdentiofier(rec.element));
330         if (bpn != null) {
331             for (XSQLColumn c : fieldsInQuery) {
332                 for (XSQLBluePrintNode eNode : eNodes) {
333                     if (((XSQLBluePrintNode) c.getBluePrintNode())
334                             .getBluePrintNodeName().equals(
335                                     eNode.getBluePrintNodeName())) {
336                         // Object value = Criteria.getValue(rec.element,
337                         // c.getName());
338                         String columnName = c.toString();
339                         Object value = fullRecord.get(columnName);
340                         if (value != null) {
341                             try {
342                                 Object rsValue = c.getResultSetValue(value);
343                                 c.setCharWidth(rsValue.toString().length());
344                                 rec.data.put(columnName, rsValue);
345                             } catch (Exception err) {
346                             }
347                         }
348                     }
349                 }
350             }
351         }
352     }
353
354     private boolean beenHere(Set<String> beenHereElement, Object element) {
355         if (beenHereElement == null) {
356             beenHereElement = new HashSet<String>();
357         }
358
359         String elementKey = null;
360
361         try {
362             elementKey = element.toString();
363         } catch (Exception err) {
364             elementKey = "Unknown";
365         }
366
367         if (beenHereElement.contains(elementKey)) {
368             return true;
369         }
370
371         beenHereElement.add(elementKey);
372         return false;
373     }
374
375     public List<Object> getChildren(Object node, String tableName,
376             XSQLBluePrint bluePrint) {
377
378         List<Object> children = XSQLODLUtils.getMChildren(node);
379         List<Object> result = new LinkedList<Object>();
380
381         for (Object child : children) {
382
383             String odlNodeName = XSQLODLUtils.getNodeIdentiofier(child);
384             if (odlNodeName == null)
385                 continue;
386
387             XSQLBluePrintNode eNodes[] = bluePrint
388                     .getBluePrintNodeByODLTableName(odlNodeName);
389             if (eNodes == null)
390                 continue;
391
392             boolean match = false;
393             for (XSQLBluePrintNode enode : eNodes) {
394                 if (tableName.startsWith(enode.toString())) {
395                     match = true;
396                     break;
397                 }
398             }
399
400             if (!match)
401                 continue;
402
403             if (child.getClass().getName().endsWith("ImmutableContainerNode")) {
404                 result.add(child);
405             } else if (child.getClass().getName()
406                     .endsWith("ImmutableAugmentationNode")) {
407                 List<Object> _children = XSQLODLUtils.getMChildren(child);
408                 for (Object c : _children) {
409                     if (c.getClass().getName()
410                             .endsWith("ImmutableContainerNode")) {
411                         result.add(c);
412                     }
413                 }
414             } else if (child.getClass().getName().endsWith("ImmutableMapNode")) {
415                 result.addAll(XSQLODLUtils.getMChildren(child));
416             }
417         }
418         return result;
419     }
420
421     public List<Record> addRecords(Object element, XSQLBluePrintNode node,
422             boolean root, String tableName, XSQLBluePrint bluePrint) {
423
424         List<Record> result = new LinkedList<Record>();
425         String nodeID = XSQLODLUtils.getNodeIdentiofier(element);
426         if (node.getODLTableName().equals(nodeID)) {
427             XSQLBluePrintNode bluePrintNode = bluePrint
428                     .getBluePrintNodeByODLTableName(nodeID)[0];
429             Record rec = new Record();
430             rec.element = element;
431             XSQLBluePrintNode bpn = this.tablesInQueryMap.get(bluePrintNode
432                     .getBluePrintNodeName());
433             if (this.criteria.containsKey(bluePrintNode.getBluePrintNodeName())
434                     || bpn != null) {
435                 Map<?, ?> allKeyValues = collectColumnValues(element, bpn);
436                 if (!(isObjectFitCriteria(allKeyValues,
437                         bpn.getBluePrintNodeName()) == 1)) {
438                     return EMPTY_RESULT;
439                 }
440                 addToData(rec, bpn, bluePrint, allKeyValues);
441             }
442             if (root) {
443                 addRecord(rec.data);
444             } else {
445                 result.add(rec);
446             }
447             return result;
448         }
449
450         XSQLBluePrintNode parent = node.getParent();
451         List<Record> subRecords = addRecords(element, parent, false, tableName,
452                 bluePrint);
453         for (Record subRec : subRecords) {
454             List<Object> subO = getChildren(subRec.element, tableName,
455                     bluePrint);
456             if (subO != null) {
457                 for (Object subData : subO) {
458                     Record rec = new Record();
459                     rec.element = subData;
460                     rec.data.putAll(subRec.data);
461
462                     String recID = XSQLODLUtils.getNodeIdentiofier(rec.element);
463                     XSQLBluePrintNode eNodes[] = bluePrint
464                             .getBluePrintNodeByODLTableName(recID);
465                     XSQLBluePrintNode bpn = null;
466                     for (XSQLBluePrintNode eNode : eNodes) {
467                         bpn = this.tablesInQueryMap.get(eNode
468                                 .getBluePrintNodeName());
469                         if (bpn != null)
470                             break;
471                     }
472                     boolean isObjectInCriteria = true;
473                     if (bpn != null) {
474                         Map allKeyValues = collectColumnValues(rec.element, bpn);
475                         if ((isObjectFitCriteria(allKeyValues,
476                                 bpn.getBluePrintNodeName()) == 1)) {
477                             addToData(rec, bpn, bluePrint, allKeyValues);
478                         } else {
479                             isObjectInCriteria = false;
480                         }
481                     }
482
483                     if (isObjectInCriteria) {
484                         if (root) {
485                             if (!rec.data.isEmpty())
486                                 addRecord(rec.data);
487                         } else {
488                             result.add(rec);
489                         }
490                     }
491                 }
492             }
493         }
494
495         return result;
496     }
497
498     @Override
499     public boolean isWrapperFor(Class<?> iface) throws SQLException {
500         // TODO Auto-generated method stub
501         return false;
502     }
503
504     @Override
505     public <T> T unwrap(Class<T> iface) throws SQLException {
506         // TODO Auto-generated method stub
507         return null;
508     }
509
510     @Override
511     public boolean absolute(int row) throws SQLException {
512         // TODO Auto-generated method stub
513         return false;
514     }
515
516     @Override
517     public void afterLast() throws SQLException {
518         // TODO Auto-generated method stub
519
520     }
521
522     @Override
523     public void beforeFirst() throws SQLException {
524         // TODO Auto-generated method stub
525
526     }
527
528     @Override
529     public void cancelRowUpdates() throws SQLException {
530         // TODO Auto-generated method stub
531
532     }
533
534     @Override
535     public void clearWarnings() throws SQLException {
536         // TODO Auto-generated method stub
537
538     }
539
540     @Override
541     public void close() throws SQLException {
542         // TODO Auto-generated method stub
543
544     }
545
546     @Override
547     public void deleteRow() throws SQLException {
548         // TODO Auto-generated method stub
549
550     }
551
552     @Override
553     public int findColumn(String columnLabel) throws SQLException {
554         // TODO Auto-generated method stub
555         return 0;
556     }
557
558     @Override
559     public boolean first() throws SQLException {
560         // TODO Auto-generated method stub
561         return false;
562     }
563
564     @Override
565     public Array getArray(int columnIndex) throws SQLException {
566         // TODO Auto-generated method stub
567         return null;
568     }
569
570     @Override
571     public Array getArray(String columnLabel) throws SQLException {
572         // TODO Auto-generated method stub
573         return null;
574     }
575
576     @Override
577     public InputStream getAsciiStream(int columnIndex) throws SQLException {
578         // TODO Auto-generated method stub
579         return null;
580     }
581
582     @Override
583     public InputStream getAsciiStream(String columnLabel) throws SQLException {
584         // TODO Auto-generated method stub
585         return null;
586     }
587
588     @Override
589     public BigDecimal getBigDecimal(int columnIndex, int scale)
590             throws SQLException {
591         // TODO Auto-generated method stub
592         return null;
593     }
594
595     @Override
596     public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
597         // TODO Auto-generated method stub
598         return null;
599     }
600
601     @Override
602     public BigDecimal getBigDecimal(String columnLabel, int scale)
603             throws SQLException {
604         // TODO Auto-generated method stub
605         return null;
606     }
607
608     @Override
609     public BigDecimal getBigDecimal(String columnLabel) throws SQLException {
610         // TODO Auto-generated method stub
611         return null;
612     }
613
614     @Override
615     public InputStream getBinaryStream(int columnIndex) throws SQLException {
616         // TODO Auto-generated method stub
617         return null;
618     }
619
620     @Override
621     public InputStream getBinaryStream(String columnLabel) throws SQLException {
622         // TODO Auto-generated method stub
623         return null;
624     }
625
626     @Override
627     public Blob getBlob(int columnIndex) throws SQLException {
628         // TODO Auto-generated method stub
629         return null;
630     }
631
632     @Override
633     public Blob getBlob(String columnLabel) throws SQLException {
634         // TODO Auto-generated method stub
635         return null;
636     }
637
638     @Override
639     public boolean getBoolean(int columnIndex) throws SQLException {
640         // TODO Auto-generated method stub
641         return false;
642     }
643
644     @Override
645     public boolean getBoolean(String columnLabel) throws SQLException {
646         // TODO Auto-generated method stub
647         return false;
648     }
649
650     @Override
651     public byte getByte(int columnIndex) throws SQLException {
652         // TODO Auto-generated method stub
653         return 0;
654     }
655
656     @Override
657     public byte getByte(String columnLabel) throws SQLException {
658         // TODO Auto-generated method stub
659         return 0;
660     }
661
662     @Override
663     public byte[] getBytes(int columnIndex) throws SQLException {
664         // TODO Auto-generated method stub
665         return null;
666     }
667
668     @Override
669     public byte[] getBytes(String columnLabel) throws SQLException {
670         // TODO Auto-generated method stub
671         return null;
672     }
673
674     @Override
675     public Reader getCharacterStream(int columnIndex) throws SQLException {
676         // TODO Auto-generated method stub
677         return null;
678     }
679
680     @Override
681     public Reader getCharacterStream(String columnLabel) throws SQLException {
682         // TODO Auto-generated method stub
683         return null;
684     }
685
686     @Override
687     public Clob getClob(int columnIndex) throws SQLException {
688         // TODO Auto-generated method stub
689         return null;
690     }
691
692     @Override
693     public Clob getClob(String columnLabel) throws SQLException {
694         // TODO Auto-generated method stub
695         return null;
696     }
697
698     @Override
699     public int getConcurrency() throws SQLException {
700         // TODO Auto-generated method stub
701         return 0;
702     }
703
704     @Override
705     public String getCursorName() throws SQLException {
706         // TODO Auto-generated method stub
707         return null;
708     }
709
710     @Override
711     public Date getDate(int columnIndex, Calendar cal) throws SQLException {
712         // TODO Auto-generated method stub
713         return null;
714     }
715
716     @Override
717     public Date getDate(int columnIndex) throws SQLException {
718         // TODO Auto-generated method stub
719         return null;
720     }
721
722     @Override
723     public Date getDate(String columnLabel, Calendar cal) throws SQLException {
724         // TODO Auto-generated method stub
725         return null;
726     }
727
728     @Override
729     public Date getDate(String columnLabel) throws SQLException {
730         // TODO Auto-generated method stub
731         return null;
732     }
733
734     @Override
735     public double getDouble(int columnIndex) throws SQLException {
736         // TODO Auto-generated method stub
737         return 0;
738     }
739
740     @Override
741     public double getDouble(String columnLabel) throws SQLException {
742         // TODO Auto-generated method stub
743         return 0;
744     }
745
746     @Override
747     public int getFetchDirection() throws SQLException {
748         // TODO Auto-generated method stub
749         return 0;
750     }
751
752     @Override
753     public int getFetchSize() throws SQLException {
754         // TODO Auto-generated method stub
755         return 0;
756     }
757
758     @Override
759     public float getFloat(int columnIndex) throws SQLException {
760         // TODO Auto-generated method stub
761         return 0;
762     }
763
764     @Override
765     public float getFloat(String columnLabel) throws SQLException {
766         // TODO Auto-generated method stub
767         return 0;
768     }
769
770     @Override
771     public int getHoldability() throws SQLException {
772         // TODO Auto-generated method stub
773         return 0;
774     }
775
776     @Override
777     public int getInt(int columnIndex) throws SQLException {
778         // TODO Auto-generated method stub
779         return 0;
780     }
781
782     @Override
783     public int getInt(String columnLabel) throws SQLException {
784         // TODO Auto-generated method stub
785         return 0;
786     }
787
788     @Override
789     public long getLong(int columnIndex) throws SQLException {
790         // TODO Auto-generated method stub
791         return 0;
792     }
793
794     @Override
795     public long getLong(String columnLabel) throws SQLException {
796         // TODO Auto-generated method stub
797         return 0;
798     }
799
800     @Override
801     public ResultSetMetaData getMetaData() throws SQLException {
802         return this;
803     }
804
805     @Override
806     public Reader getNCharacterStream(int columnIndex) throws SQLException {
807         // TODO Auto-generated method stub
808         return null;
809     }
810
811     @Override
812     public Reader getNCharacterStream(String columnLabel) throws SQLException {
813         // TODO Auto-generated method stub
814         return null;
815     }
816
817     @Override
818     public NClob getNClob(int columnIndex) throws SQLException {
819         // TODO Auto-generated method stub
820         return null;
821     }
822
823     @Override
824     public NClob getNClob(String columnLabel) throws SQLException {
825         // TODO Auto-generated method stub
826         return null;
827     }
828
829     @Override
830     public String getNString(int columnIndex) throws SQLException {
831         // TODO Auto-generated method stub
832         return null;
833     }
834
835     @Override
836     public String getNString(String columnLabel) throws SQLException {
837         // TODO Auto-generated method stub
838         return null;
839     }
840
841     @Override
842     public Object getObject(int columnIndex, Map<String, Class<?>> map)
843             throws SQLException {
844         return getObject(columnIndex);
845     }
846
847     @Override
848     public Object getObject(int columnIndex) throws SQLException {
849         return currentRecord.get(this.fieldsInQuery.get(columnIndex - 1)
850                 .toString());
851     }
852
853     @Override
854     public Object getObject(String columnLabel, Map<String, Class<?>> map)
855             throws SQLException {
856         return getObject(columnLabel);
857     }
858
859     @Override
860     public Object getObject(String columnLabel) throws SQLException {
861         return currentRecord.get(columnLabel);
862     }
863
864     @Override
865     public Ref getRef(int columnIndex) throws SQLException {
866         // TODO Auto-generated method stub
867         return null;
868     }
869
870     @Override
871     public Ref getRef(String columnLabel) throws SQLException {
872         // TODO Auto-generated method stub
873         return null;
874     }
875
876     @Override
877     public int getRow() throws SQLException {
878         // TODO Auto-generated method stub
879         return 0;
880     }
881
882     @Override
883     public RowId getRowId(int columnIndex) throws SQLException {
884         // TODO Auto-generated method stub
885         return null;
886     }
887
888     @Override
889     public RowId getRowId(String columnLabel) throws SQLException {
890         // TODO Auto-generated method stub
891         return null;
892     }
893
894     @Override
895     public SQLXML getSQLXML(int columnIndex) throws SQLException {
896         // TODO Auto-generated method stub
897         return null;
898     }
899
900     @Override
901     public SQLXML getSQLXML(String columnLabel) throws SQLException {
902         // TODO Auto-generated method stub
903         return null;
904     }
905
906     @Override
907     public short getShort(int columnIndex) throws SQLException {
908         // TODO Auto-generated method stub
909         return 0;
910     }
911
912     @Override
913     public short getShort(String columnLabel) throws SQLException {
914         // TODO Auto-generated method stub
915         return 0;
916     }
917
918     @Override
919     public Statement getStatement() throws SQLException {
920         // TODO Auto-generated method stub
921         return null;
922     }
923
924     @Override
925     public String getString(int columnIndex) throws SQLException {
926         return "Kuku";
927     }
928
929     @Override
930     public String getString(String columnLabel) throws SQLException {
931         return "Kuku";
932     }
933
934     @Override
935     public Time getTime(int columnIndex, Calendar cal) throws SQLException {
936         // TODO Auto-generated method stub
937         return null;
938     }
939
940     @Override
941     public Time getTime(int columnIndex) throws SQLException {
942         // TODO Auto-generated method stub
943         return null;
944     }
945
946     @Override
947     public Time getTime(String columnLabel, Calendar cal) throws SQLException {
948         // TODO Auto-generated method stub
949         return null;
950     }
951
952     @Override
953     public Time getTime(String columnLabel) throws SQLException {
954         // TODO Auto-generated method stub
955         return null;
956     }
957
958     @Override
959     public Timestamp getTimestamp(int columnIndex, Calendar cal)
960             throws SQLException {
961         // TODO Auto-generated method stub
962         return null;
963     }
964
965     @Override
966     public Timestamp getTimestamp(int columnIndex) throws SQLException {
967         // TODO Auto-generated method stub
968         return null;
969     }
970
971     @Override
972     public Timestamp getTimestamp(String columnLabel, Calendar cal)
973             throws SQLException {
974         // TODO Auto-generated method stub
975         return null;
976     }
977
978     @Override
979     public Timestamp getTimestamp(String columnLabel) throws SQLException {
980         // TODO Auto-generated method stub
981         return null;
982     }
983
984     @Override
985     public int getType() throws SQLException {
986         return ResultSet.TYPE_FORWARD_ONLY;
987     }
988
989     @Override
990     public URL getURL(int columnIndex) throws SQLException {
991         // TODO Auto-generated method stub
992         return null;
993     }
994
995     @Override
996     public URL getURL(String columnLabel) throws SQLException {
997         // TODO Auto-generated method stub
998         return null;
999     }
1000
1001     @Override
1002     public InputStream getUnicodeStream(int columnIndex) throws SQLException {
1003         // TODO Auto-generated method stub
1004         return null;
1005     }
1006
1007     @Override
1008     public InputStream getUnicodeStream(String columnLabel) throws SQLException {
1009         // TODO Auto-generated method stub
1010         return null;
1011     }
1012
1013     @Override
1014     public SQLWarning getWarnings() throws SQLException {
1015         // TODO Auto-generated method stub
1016         return null;
1017     }
1018
1019     @Override
1020     public void insertRow() throws SQLException {
1021         // TODO Auto-generated method stub
1022
1023     }
1024
1025     @Override
1026     public boolean isAfterLast() throws SQLException {
1027         // TODO Auto-generated method stub
1028         return false;
1029     }
1030
1031     @Override
1032     public boolean isBeforeFirst() throws SQLException {
1033         // TODO Auto-generated method stub
1034         return false;
1035     }
1036
1037     @Override
1038     public boolean isClosed() throws SQLException {
1039         // TODO Auto-generated method stub
1040         return false;
1041     }
1042
1043     @Override
1044     public boolean isFirst() throws SQLException {
1045         // TODO Auto-generated method stub
1046         return false;
1047     }
1048
1049     @Override
1050     public boolean isLast() throws SQLException {
1051         // TODO Auto-generated method stub
1052         return false;
1053     }
1054
1055     @Override
1056     public boolean last() throws SQLException {
1057         // TODO Auto-generated method stub
1058         return false;
1059     }
1060
1061     @Override
1062     public void moveToCurrentRow() throws SQLException {
1063         // TODO Auto-generated method stub
1064
1065     }
1066
1067     @Override
1068     public void moveToInsertRow() throws SQLException {
1069         // TODO Auto-generated method stub
1070
1071     }
1072
1073     @Override
1074     public boolean previous() throws SQLException {
1075         // TODO Auto-generated method stub
1076         return false;
1077     }
1078
1079     @Override
1080     public void refreshRow() throws SQLException {
1081         // TODO Auto-generated method stub
1082
1083     }
1084
1085     @Override
1086     public boolean relative(int rows) throws SQLException {
1087         // TODO Auto-generated method stub
1088         return false;
1089     }
1090
1091     @Override
1092     public boolean rowDeleted() throws SQLException {
1093         // TODO Auto-generated method stub
1094         return false;
1095     }
1096
1097     @Override
1098     public boolean rowInserted() throws SQLException {
1099         // TODO Auto-generated method stub
1100         return false;
1101     }
1102
1103     @Override
1104     public boolean rowUpdated() throws SQLException {
1105         // TODO Auto-generated method stub
1106         return false;
1107     }
1108
1109     @Override
1110     public void setFetchDirection(int direction) throws SQLException {
1111         // TODO Auto-generated method stub
1112
1113     }
1114
1115     @Override
1116     public void setFetchSize(int rows) throws SQLException {
1117         // TODO Auto-generated method stub
1118
1119     }
1120
1121     @Override
1122     public void updateArray(int columnIndex, Array x) throws SQLException {
1123         // TODO Auto-generated method stub
1124
1125     }
1126
1127     @Override
1128     public void updateArray(String columnLabel, Array x) throws SQLException {
1129         // TODO Auto-generated method stub
1130
1131     }
1132
1133     @Override
1134     public void updateAsciiStream(int columnIndex, InputStream x, int length)
1135             throws SQLException {
1136         // TODO Auto-generated method stub
1137
1138     }
1139
1140     @Override
1141     public void updateAsciiStream(int columnIndex, InputStream x, long length)
1142             throws SQLException {
1143         // TODO Auto-generated method stub
1144
1145     }
1146
1147     @Override
1148     public void updateAsciiStream(int columnIndex, InputStream x)
1149             throws SQLException {
1150         // TODO Auto-generated method stub
1151
1152     }
1153
1154     @Override
1155     public void updateAsciiStream(String columnLabel, InputStream x, int length)
1156             throws SQLException {
1157         // TODO Auto-generated method stub
1158
1159     }
1160
1161     @Override
1162     public void updateAsciiStream(String columnLabel, InputStream x, long length)
1163             throws SQLException {
1164         // TODO Auto-generated method stub
1165
1166     }
1167
1168     @Override
1169     public void updateAsciiStream(String columnLabel, InputStream x)
1170             throws SQLException {
1171         // TODO Auto-generated method stub
1172
1173     }
1174
1175     @Override
1176     public void updateBigDecimal(int columnIndex, BigDecimal x)
1177             throws SQLException {
1178         // TODO Auto-generated method stub
1179
1180     }
1181
1182     @Override
1183     public void updateBigDecimal(String columnLabel, BigDecimal x)
1184             throws SQLException {
1185         // TODO Auto-generated method stub
1186
1187     }
1188
1189     @Override
1190     public void updateBinaryStream(int columnIndex, InputStream x, int length)
1191             throws SQLException {
1192         // TODO Auto-generated method stub
1193
1194     }
1195
1196     @Override
1197     public void updateBinaryStream(int columnIndex, InputStream x, long length)
1198             throws SQLException {
1199         // TODO Auto-generated method stub
1200
1201     }
1202
1203     @Override
1204     public void updateBinaryStream(int columnIndex, InputStream x)
1205             throws SQLException {
1206         // TODO Auto-generated method stub
1207
1208     }
1209
1210     @Override
1211     public void updateBinaryStream(String columnLabel, InputStream x, int length)
1212             throws SQLException {
1213         // TODO Auto-generated method stub
1214
1215     }
1216
1217     @Override
1218     public void updateBinaryStream(String columnLabel, InputStream x,
1219             long length) throws SQLException {
1220         // TODO Auto-generated method stub
1221
1222     }
1223
1224     @Override
1225     public void updateBinaryStream(String columnLabel, InputStream x)
1226             throws SQLException {
1227         // TODO Auto-generated method stub
1228
1229     }
1230
1231     @Override
1232     public void updateBlob(int columnIndex, Blob x) throws SQLException {
1233         // TODO Auto-generated method stub
1234
1235     }
1236
1237     @Override
1238     public void updateBlob(int columnIndex, InputStream inputStream, long length)
1239             throws SQLException {
1240         // TODO Auto-generated method stub
1241
1242     }
1243
1244     @Override
1245     public void updateBlob(int columnIndex, InputStream inputStream)
1246             throws SQLException {
1247         // TODO Auto-generated method stub
1248
1249     }
1250
1251     @Override
1252     public void updateBlob(String columnLabel, Blob x) throws SQLException {
1253         // TODO Auto-generated method stub
1254
1255     }
1256
1257     @Override
1258     public void updateBlob(String columnLabel, InputStream inputStream,
1259             long length) throws SQLException {
1260         // TODO Auto-generated method stub
1261
1262     }
1263
1264     @Override
1265     public void updateBlob(String columnLabel, InputStream inputStream)
1266             throws SQLException {
1267         // TODO Auto-generated method stub
1268
1269     }
1270
1271     @Override
1272     public void updateBoolean(int columnIndex, boolean x) throws SQLException {
1273         // TODO Auto-generated method stub
1274
1275     }
1276
1277     @Override
1278     public void updateBoolean(String columnLabel, boolean x)
1279             throws SQLException {
1280         // TODO Auto-generated method stub
1281
1282     }
1283
1284     @Override
1285     public void updateByte(int columnIndex, byte x) throws SQLException {
1286         // TODO Auto-generated method stub
1287
1288     }
1289
1290     @Override
1291     public void updateByte(String columnLabel, byte x) throws SQLException {
1292         // TODO Auto-generated method stub
1293
1294     }
1295
1296     @Override
1297     public void updateBytes(int columnIndex, byte[] x) throws SQLException {
1298         // TODO Auto-generated method stub
1299
1300     }
1301
1302     @Override
1303     public void updateBytes(String columnLabel, byte[] x) throws SQLException {
1304         // TODO Auto-generated method stub
1305
1306     }
1307
1308     @Override
1309     public void updateCharacterStream(int columnIndex, Reader x, int length)
1310             throws SQLException {
1311         // TODO Auto-generated method stub
1312
1313     }
1314
1315     @Override
1316     public void updateCharacterStream(int columnIndex, Reader x, long length)
1317             throws SQLException {
1318         // TODO Auto-generated method stub
1319
1320     }
1321
1322     @Override
1323     public void updateCharacterStream(int columnIndex, Reader x)
1324             throws SQLException {
1325         // TODO Auto-generated method stub
1326
1327     }
1328
1329     @Override
1330     public void updateCharacterStream(String columnLabel, Reader reader,
1331             int length) throws SQLException {
1332         // TODO Auto-generated method stub
1333
1334     }
1335
1336     @Override
1337     public void updateCharacterStream(String columnLabel, Reader reader,
1338             long length) throws SQLException {
1339         // TODO Auto-generated method stub
1340
1341     }
1342
1343     @Override
1344     public void updateCharacterStream(String columnLabel, Reader reader)
1345             throws SQLException {
1346         // TODO Auto-generated method stub
1347
1348     }
1349
1350     @Override
1351     public void updateClob(int columnIndex, Clob x) throws SQLException {
1352         // TODO Auto-generated method stub
1353
1354     }
1355
1356     @Override
1357     public void updateClob(int columnIndex, Reader reader, long length)
1358             throws SQLException {
1359         // TODO Auto-generated method stub
1360
1361     }
1362
1363     @Override
1364     public void updateClob(int columnIndex, Reader reader) throws SQLException {
1365         // TODO Auto-generated method stub
1366
1367     }
1368
1369     @Override
1370     public void updateClob(String columnLabel, Clob x) throws SQLException {
1371         // TODO Auto-generated method stub
1372
1373     }
1374
1375     @Override
1376     public void updateClob(String columnLabel, Reader reader, long length)
1377             throws SQLException {
1378         // TODO Auto-generated method stub
1379
1380     }
1381
1382     @Override
1383     public void updateClob(String columnLabel, Reader reader)
1384             throws SQLException {
1385         // TODO Auto-generated method stub
1386
1387     }
1388
1389     @Override
1390     public void updateDate(int columnIndex, Date x) throws SQLException {
1391         // TODO Auto-generated method stub
1392
1393     }
1394
1395     @Override
1396     public void updateDate(String columnLabel, Date x) throws SQLException {
1397         // TODO Auto-generated method stub
1398
1399     }
1400
1401     @Override
1402     public void updateDouble(int columnIndex, double x) throws SQLException {
1403         // TODO Auto-generated method stub
1404
1405     }
1406
1407     @Override
1408     public void updateDouble(String columnLabel, double x) throws SQLException {
1409         // TODO Auto-generated method stub
1410
1411     }
1412
1413     @Override
1414     public void updateFloat(int columnIndex, float x) throws SQLException {
1415         // TODO Auto-generated method stub
1416
1417     }
1418
1419     @Override
1420     public void updateFloat(String columnLabel, float x) throws SQLException {
1421         // TODO Auto-generated method stub
1422
1423     }
1424
1425     @Override
1426     public void updateInt(int columnIndex, int x) throws SQLException {
1427         // TODO Auto-generated method stub
1428
1429     }
1430
1431     @Override
1432     public void updateInt(String columnLabel, int x) throws SQLException {
1433         // TODO Auto-generated method stub
1434
1435     }
1436
1437     @Override
1438     public void updateLong(int columnIndex, long x) throws SQLException {
1439         // TODO Auto-generated method stub
1440
1441     }
1442
1443     @Override
1444     public void updateLong(String columnLabel, long x) throws SQLException {
1445         // TODO Auto-generated method stub
1446
1447     }
1448
1449     @Override
1450     public void updateNCharacterStream(int columnIndex, Reader x, long length)
1451             throws SQLException {
1452         // TODO Auto-generated method stub
1453
1454     }
1455
1456     @Override
1457     public void updateNCharacterStream(int columnIndex, Reader x)
1458             throws SQLException {
1459         // TODO Auto-generated method stub
1460
1461     }
1462
1463     @Override
1464     public void updateNCharacterStream(String columnLabel, Reader reader,
1465             long length) throws SQLException {
1466         // TODO Auto-generated method stub
1467
1468     }
1469
1470     @Override
1471     public void updateNCharacterStream(String columnLabel, Reader reader)
1472             throws SQLException {
1473         // TODO Auto-generated method stub
1474
1475     }
1476
1477     @Override
1478     public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
1479         // TODO Auto-generated method stub
1480
1481     }
1482
1483     @Override
1484     public void updateNClob(int columnIndex, Reader reader, long length)
1485             throws SQLException {
1486         // TODO Auto-generated method stub
1487
1488     }
1489
1490     @Override
1491     public void updateNClob(int columnIndex, Reader reader) throws SQLException {
1492         // TODO Auto-generated method stub
1493
1494     }
1495
1496     @Override
1497     public void updateNClob(String columnLabel, NClob nClob)
1498             throws SQLException {
1499         // TODO Auto-generated method stub
1500
1501     }
1502
1503     @Override
1504     public void updateNClob(String columnLabel, Reader reader, long length)
1505             throws SQLException {
1506         // TODO Auto-generated method stub
1507
1508     }
1509
1510     @Override
1511     public void updateNClob(String columnLabel, Reader reader)
1512             throws SQLException {
1513         // TODO Auto-generated method stub
1514
1515     }
1516
1517     @Override
1518     public void updateNString(int columnIndex, String nString)
1519             throws SQLException {
1520         // TODO Auto-generated method stub
1521
1522     }
1523
1524     @Override
1525     public void updateNString(String columnLabel, String nString)
1526             throws SQLException {
1527         // TODO Auto-generated method stub
1528
1529     }
1530
1531     @Override
1532     public void updateNull(int columnIndex) throws SQLException {
1533         // TODO Auto-generated method stub
1534
1535     }
1536
1537     @Override
1538     public void updateNull(String columnLabel) throws SQLException {
1539         // TODO Auto-generated method stub
1540
1541     }
1542
1543     @Override
1544     public void updateObject(int columnIndex, Object x, int scaleOrLength)
1545             throws SQLException {
1546         // TODO Auto-generated method stub
1547
1548     }
1549
1550     @Override
1551     public void updateObject(int columnIndex, Object x) throws SQLException {
1552         // TODO Auto-generated method stub
1553
1554     }
1555
1556     @Override
1557     public void updateObject(String columnLabel, Object x, int scaleOrLength)
1558             throws SQLException {
1559         // TODO Auto-generated method stub
1560
1561     }
1562
1563     @Override
1564     public void updateObject(String columnLabel, Object x) throws SQLException {
1565         // TODO Auto-generated method stub
1566
1567     }
1568
1569     @Override
1570     public void updateRef(int columnIndex, Ref x) throws SQLException {
1571         // TODO Auto-generated method stub
1572
1573     }
1574
1575     @Override
1576     public void updateRef(String columnLabel, Ref x) throws SQLException {
1577         // TODO Auto-generated method stub
1578
1579     }
1580
1581     @Override
1582     public void updateRow() throws SQLException {
1583         // TODO Auto-generated method stub
1584
1585     }
1586
1587     @Override
1588     public void updateRowId(int columnIndex, RowId x) throws SQLException {
1589         // TODO Auto-generated method stub
1590
1591     }
1592
1593     @Override
1594     public void updateRowId(String columnLabel, RowId x) throws SQLException {
1595         // TODO Auto-generated method stub
1596
1597     }
1598
1599     @Override
1600     public void updateSQLXML(int columnIndex, SQLXML xmlObject)
1601             throws SQLException {
1602         // TODO Auto-generated method stub
1603
1604     }
1605
1606     @Override
1607     public void updateSQLXML(String columnLabel, SQLXML xmlObject)
1608             throws SQLException {
1609         // TODO Auto-generated method stub
1610
1611     }
1612
1613     @Override
1614     public void updateShort(int columnIndex, short x) throws SQLException {
1615         // TODO Auto-generated method stub
1616
1617     }
1618
1619     @Override
1620     public void updateShort(String columnLabel, short x) throws SQLException {
1621         // TODO Auto-generated method stub
1622
1623     }
1624
1625     @Override
1626     public void updateString(int columnIndex, String x) throws SQLException {
1627         // TODO Auto-generated method stub
1628
1629     }
1630
1631     @Override
1632     public void updateString(String columnLabel, String x) throws SQLException {
1633         // TODO Auto-generated method stub
1634
1635     }
1636
1637     @Override
1638     public void updateTime(int columnIndex, Time x) throws SQLException {
1639         // TODO Auto-generated method stub
1640
1641     }
1642
1643     @Override
1644     public void updateTime(String columnLabel, Time x) throws SQLException {
1645         // TODO Auto-generated method stub
1646
1647     }
1648
1649     @Override
1650     public void updateTimestamp(int columnIndex, Timestamp x)
1651             throws SQLException {
1652         // TODO Auto-generated method stub
1653
1654     }
1655
1656     @Override
1657     public void updateTimestamp(String columnLabel, Timestamp x)
1658             throws SQLException {
1659         // TODO Auto-generated method stub
1660
1661     }
1662
1663     @Override
1664     public boolean wasNull() throws SQLException {
1665         // TODO Auto-generated method stub
1666         return false;
1667     }
1668
1669     @Override
1670     public String getCatalogName(int column) throws SQLException {
1671         // TODO Auto-generated method stub
1672         return null;
1673     }
1674
1675     @Override
1676     public String getColumnClassName(int column) throws SQLException {
1677         // TODO Auto-generated method stub
1678         return null;
1679     }
1680
1681     @Override
1682     public int getColumnCount() throws SQLException {
1683         return fieldsInQuery.size();
1684     }
1685
1686     @Override
1687     public int getColumnDisplaySize(int column) throws SQLException {
1688         // TODO Auto-generated method stub
1689         return 0;
1690     }
1691
1692     @Override
1693     public String getColumnLabel(int column) throws SQLException {
1694         return this.fieldsInQuery.get(column - 1).toString();
1695     }
1696
1697     @Override
1698     public String getColumnName(int column) throws SQLException {
1699         // TODO Auto-generated method stub
1700         return null;
1701     }
1702
1703     @Override
1704     public int getColumnType(int column) throws SQLException {
1705         return 12;
1706     }
1707
1708     @Override
1709     public String getColumnTypeName(int column) throws SQLException {
1710         // TODO Auto-generated method stub
1711         return null;
1712     }
1713
1714     @Override
1715     public int getPrecision(int column) throws SQLException {
1716         // TODO Auto-generated method stub
1717         return 0;
1718     }
1719
1720     @Override
1721     public int getScale(int column) throws SQLException {
1722         // TODO Auto-generated method stub
1723         return 0;
1724     }
1725
1726     @Override
1727     public String getSchemaName(int column) throws SQLException {
1728         // TODO Auto-generated method stub
1729         return null;
1730     }
1731
1732     @Override
1733     public String getTableName(int column) throws SQLException {
1734         // TODO Auto-generated method stub
1735         return null;
1736     }
1737
1738     @Override
1739     public boolean isAutoIncrement(int column) throws SQLException {
1740         // TODO Auto-generated method stub
1741         return false;
1742     }
1743
1744     @Override
1745     public boolean isCaseSensitive(int column) throws SQLException {
1746         // TODO Auto-generated method stub
1747         return false;
1748     }
1749
1750     @Override
1751     public boolean isCurrency(int column) throws SQLException {
1752         // TODO Auto-generated method stub
1753         return false;
1754     }
1755
1756     @Override
1757     public boolean isDefinitelyWritable(int column) throws SQLException {
1758         // TODO Auto-generated method stub
1759         return false;
1760     }
1761
1762     @Override
1763     public int isNullable(int column) throws SQLException {
1764         // TODO Auto-generated method stub
1765         return 0;
1766     }
1767
1768     @Override
1769     public boolean isReadOnly(int column) throws SQLException {
1770         // TODO Auto-generated method stub
1771         return false;
1772     }
1773
1774     @Override
1775     public boolean isSearchable(int column) throws SQLException {
1776         // TODO Auto-generated method stub
1777         return false;
1778     }
1779
1780     @Override
1781     public boolean isSigned(int column) throws SQLException {
1782         // TODO Auto-generated method stub
1783         return false;
1784     }
1785
1786     @Override
1787     public boolean isWritable(int column) throws SQLException {
1788         // TODO Auto-generated method stub
1789         return false;
1790     }
1791
1792     @Override
1793     public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
1794         // TODO Auto-generated method stub
1795         return null;
1796     }
1797
1798     @Override
1799     public <T> T getObject(String columnLabel, Class<T> type)
1800             throws SQLException {
1801         // TODO Auto-generated method stub
1802         return null;
1803     }
1804
1805     // //Metadata
1806
1807 }