View Javadoc

1   /*
2    * Copyright (c) 2010.  The Apache Software Foundation
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  
21  package org.apache.hadoop.hbase.jdbc.impl;
22  
23  import org.apache.hadoop.hbase.hbql.client.HRecord;
24  import org.apache.hadoop.hbase.hbql.client.HResultSet;
25  import org.apache.hadoop.hbase.hbql.impl.HRecordImpl;
26  import org.apache.hadoop.hbase.hbql.impl.Query;
27  
28  import java.io.InputStream;
29  import java.io.Reader;
30  import java.math.BigDecimal;
31  import java.net.URL;
32  import java.sql.Array;
33  import java.sql.Blob;
34  import java.sql.Clob;
35  import java.sql.Date;
36  import java.sql.NClob;
37  import java.sql.Ref;
38  import java.sql.ResultSet;
39  import java.sql.ResultSetMetaData;
40  import java.sql.RowId;
41  import java.sql.SQLException;
42  import java.sql.SQLWarning;
43  import java.sql.SQLXML;
44  import java.sql.Statement;
45  import java.sql.Time;
46  import java.sql.Timestamp;
47  import java.util.Calendar;
48  import java.util.Iterator;
49  import java.util.Map;
50  
51  public class ResultSetImpl implements ResultSet {
52  
53      private final StatementImpl statement;
54      private final Query<HRecord> query;
55      private final HResultSet<HRecord> results;
56      private final Iterator<HRecord> resultsIterator;
57      private HRecordImpl currentHRecordImpl = null;
58  
59      public ResultSetImpl(final StatementImpl statement,
60                           final Query<HRecord> query,
61                           final HResultSet<HRecord> results) {
62          this.statement = statement;
63          this.query = query;
64          this.results = results;
65          this.resultsIterator = results.iterator();
66      }
67  
68      public Query<HRecord> getQuery() {
69          return this.query;
70      }
71  
72      private HResultSet<HRecord> getResults() {
73          return this.results;
74      }
75  
76      private Iterator<HRecord> getResultsIterator() {
77          return this.resultsIterator;
78      }
79  
80      private HRecordImpl getCurrentHRecordImpl() {
81          return this.currentHRecordImpl;
82      }
83  
84      public HRecord getCurrentHRecord() {
85          return this.getCurrentHRecordImpl();
86      }
87  
88      private void setCurrentHRecordImpl(final HRecordImpl currentHRecordImpl) {
89          this.currentHRecordImpl = currentHRecordImpl;
90      }
91  
92      public <T> T unwrap(final Class<T> tClass) throws SQLException {
93          return null;
94      }
95  
96      public boolean isWrapperFor(final Class<?> aClass) throws SQLException {
97          return false;
98      }
99  
100     public boolean next() throws SQLException {
101         if (this.getResultsIterator().hasNext()) {
102             this.setCurrentHRecordImpl((HRecordImpl)this.getResultsIterator().next());
103             return true;
104         }
105         else {
106             return false;
107         }
108     }
109 
110     public void close() throws SQLException {
111 
112     }
113 
114     public boolean wasNull() throws SQLException {
115         return false;
116     }
117 
118     public String getString(final int i) throws SQLException {
119         final String name = this.getCurrentHRecordImpl().getAttribName(i);
120         return this.getString(name);
121     }
122 
123     public boolean getBoolean(final int i) throws SQLException {
124         final String name = this.getCurrentHRecordImpl().getAttribName(i);
125         return this.getBoolean(name);
126     }
127 
128     public byte getByte(final int i) throws SQLException {
129         final String name = this.getCurrentHRecordImpl().getAttribName(i);
130         return this.getByte(name);
131     }
132 
133     public short getShort(final int i) throws SQLException {
134         final String name = this.getCurrentHRecordImpl().getAttribName(i);
135         return this.getShort(name);
136     }
137 
138     public int getInt(final int i) throws SQLException {
139         final String name = this.getCurrentHRecordImpl().getAttribName(i);
140         return this.getInt(name);
141     }
142 
143     public long getLong(final int i) throws SQLException {
144         final String name = this.getCurrentHRecordImpl().getAttribName(i);
145         return this.getInt(name);
146     }
147 
148     public float getFloat(final int i) throws SQLException {
149         final String name = this.getCurrentHRecordImpl().getAttribName(i);
150         return this.getInt(name);
151     }
152 
153     public double getDouble(final int i) throws SQLException {
154         final String name = this.getCurrentHRecordImpl().getAttribName(i);
155         return this.getInt(name);
156     }
157 
158     public BigDecimal getBigDecimal(final int i, final int i1) throws SQLException {
159         return null;
160     }
161 
162     public byte[] getBytes(final int i) throws SQLException {
163         final String name = this.getCurrentHRecordImpl().getAttribName(i);
164         return this.getBytes(name);
165     }
166 
167     public Date getDate(final int i) throws SQLException {
168         final String name = this.getCurrentHRecordImpl().getAttribName(i);
169         return this.getDate(name);
170     }
171 
172     public Time getTime(final int i) throws SQLException {
173         return null;
174     }
175 
176     public Timestamp getTimestamp(final int i) throws SQLException {
177         return null;
178     }
179 
180     public InputStream getAsciiStream(final int i) throws SQLException {
181         return null;
182     }
183 
184     public InputStream getUnicodeStream(final int i) throws SQLException {
185         return null;
186     }
187 
188     public InputStream getBinaryStream(final int i) throws SQLException {
189         return null;
190     }
191 
192     public String getString(final String s) throws SQLException {
193         return ((String)this.getCurrentHRecordImpl().getCurrentValue(s));
194     }
195 
196     public boolean getBoolean(final String s) throws SQLException {
197         return ((Boolean)this.getCurrentHRecordImpl().getCurrentValue(s));
198     }
199 
200     public byte getByte(final String s) throws SQLException {
201         return ((Byte)this.getCurrentHRecordImpl().getCurrentValue(s));
202     }
203 
204     public short getShort(final String s) throws SQLException {
205         return ((Number)this.getCurrentHRecordImpl().getCurrentValue(s)).shortValue();
206     }
207 
208     public int getInt(final String s) throws SQLException {
209         return ((Number)this.getCurrentHRecordImpl().getCurrentValue(s)).intValue();
210     }
211 
212     public long getLong(final String s) throws SQLException {
213         return ((Number)this.getCurrentHRecordImpl().getCurrentValue(s)).longValue();
214     }
215 
216     public float getFloat(final String s) throws SQLException {
217         return ((Number)this.getCurrentHRecordImpl().getCurrentValue(s)).floatValue();
218     }
219 
220     public double getDouble(final String s) throws SQLException {
221         return ((Number)this.getCurrentHRecordImpl().getCurrentValue(s)).doubleValue();
222     }
223 
224     public BigDecimal getBigDecimal(final String s, final int i) throws SQLException {
225         return null;
226     }
227 
228     public byte[] getBytes(final String s) throws SQLException {
229         return ((byte[])this.getCurrentHRecordImpl().getCurrentValue(s));
230     }
231 
232     public Date getDate(final String s) throws SQLException {
233         return ((Date)this.getCurrentHRecordImpl().getCurrentValue(s));
234     }
235 
236     public Time getTime(final String s) throws SQLException {
237         return null;
238     }
239 
240     public Timestamp getTimestamp(final String s) throws SQLException {
241         return null;
242     }
243 
244     public InputStream getAsciiStream(final String s) throws SQLException {
245         return null;
246     }
247 
248     public InputStream getUnicodeStream(final String s) throws SQLException {
249         return null;
250     }
251 
252     public InputStream getBinaryStream(final String s) throws SQLException {
253         return null;
254     }
255 
256     public SQLWarning getWarnings() throws SQLException {
257         return null;
258     }
259 
260     public void clearWarnings() throws SQLException {
261 
262     }
263 
264     public String getCursorName() throws SQLException {
265         return null;
266     }
267 
268     public ResultSetMetaData getMetaData() throws SQLException {
269         return new ResultSetMetaDataImpl(this);
270     }
271 
272     public Object getObject(final int i) throws SQLException {
273         return null;
274     }
275 
276     public Object getObject(final String s) throws SQLException {
277         return this.getCurrentHRecordImpl().getCurrentValue(s);
278     }
279 
280     public int findColumn(final String s) throws SQLException {
281         return 0;
282     }
283 
284     public Reader getCharacterStream(final int i) throws SQLException {
285         return null;
286     }
287 
288     public Reader getCharacterStream(final String s) throws SQLException {
289         return null;
290     }
291 
292     public BigDecimal getBigDecimal(final int i) throws SQLException {
293         return null;
294     }
295 
296     public BigDecimal getBigDecimal(final String s) throws SQLException {
297         return null;
298     }
299 
300     public boolean isBeforeFirst() throws SQLException {
301         return false;
302     }
303 
304     public boolean isAfterLast() throws SQLException {
305         return false;
306     }
307 
308     public boolean isFirst() throws SQLException {
309         return false;
310     }
311 
312     public boolean isLast() throws SQLException {
313         return false;
314     }
315 
316     public void beforeFirst() throws SQLException {
317 
318     }
319 
320     public void afterLast() throws SQLException {
321 
322     }
323 
324     public boolean first() throws SQLException {
325         return false;
326     }
327 
328     public boolean last() throws SQLException {
329         return false;
330     }
331 
332     public int getRow() throws SQLException {
333         return 0;
334     }
335 
336     public boolean absolute(final int i) throws SQLException {
337         return false;
338     }
339 
340     public boolean relative(final int i) throws SQLException {
341         return false;
342     }
343 
344     public boolean previous() throws SQLException {
345         return false;
346     }
347 
348     public void setFetchDirection(final int i) throws SQLException {
349 
350     }
351 
352     public int getFetchDirection() throws SQLException {
353         return 0;
354     }
355 
356     public void setFetchSize(final int i) throws SQLException {
357 
358     }
359 
360     public int getFetchSize() throws SQLException {
361         return 0;
362     }
363 
364     public int getType() throws SQLException {
365         return 0;
366     }
367 
368     public int getConcurrency() throws SQLException {
369         return 0;
370     }
371 
372     public boolean rowUpdated() throws SQLException {
373         return false;
374     }
375 
376     public boolean rowInserted() throws SQLException {
377         return false;
378     }
379 
380     public boolean rowDeleted() throws SQLException {
381         return false;
382     }
383 
384     public void updateNull(final int i) throws SQLException {
385 
386     }
387 
388     public void updateBoolean(final int i, final boolean b) throws SQLException {
389 
390     }
391 
392     public void updateByte(final int i, final byte b) throws SQLException {
393 
394     }
395 
396     public void updateShort(final int i, final short i1) throws SQLException {
397 
398     }
399 
400     public void updateInt(final int i, final int i1) throws SQLException {
401 
402     }
403 
404     public void updateLong(final int i, final long l) throws SQLException {
405 
406     }
407 
408     public void updateFloat(final int i, final float v) throws SQLException {
409 
410     }
411 
412     public void updateDouble(final int i, final double v) throws SQLException {
413 
414     }
415 
416     public void updateBigDecimal(final int i, final BigDecimal bigDecimal) throws SQLException {
417 
418     }
419 
420     public void updateString(final int i, final String s) throws SQLException {
421 
422     }
423 
424     public void updateBytes(final int i, final byte[] bytes) throws SQLException {
425 
426     }
427 
428     public void updateDate(final int i, final Date date) throws SQLException {
429 
430     }
431 
432     public void updateTime(final int i, final Time time) throws SQLException {
433 
434     }
435 
436     public void updateTimestamp(final int i, final Timestamp timestamp) throws SQLException {
437 
438     }
439 
440     public void updateAsciiStream(final int i, final InputStream inputStream, final int i1) throws SQLException {
441 
442     }
443 
444     public void updateBinaryStream(final int i, final InputStream inputStream, final int i1) throws SQLException {
445 
446     }
447 
448     public void updateCharacterStream(final int i, final Reader reader, final int i1) throws SQLException {
449 
450     }
451 
452     public void updateObject(final int i, final Object o, final int i1) throws SQLException {
453 
454     }
455 
456     public void updateObject(final int i, final Object o) throws SQLException {
457 
458     }
459 
460     public void updateNull(final String s) throws SQLException {
461 
462     }
463 
464     public void updateBoolean(final String s, final boolean b) throws SQLException {
465 
466     }
467 
468     public void updateByte(final String s, final byte b) throws SQLException {
469 
470     }
471 
472     public void updateShort(final String s, final short i) throws SQLException {
473 
474     }
475 
476     public void updateInt(final String s, final int i) throws SQLException {
477 
478     }
479 
480     public void updateLong(final String s, final long l) throws SQLException {
481 
482     }
483 
484     public void updateFloat(final String s, final float v) throws SQLException {
485 
486     }
487 
488     public void updateDouble(final String s, final double v) throws SQLException {
489 
490     }
491 
492     public void updateBigDecimal(final String s, final BigDecimal bigDecimal) throws SQLException {
493 
494     }
495 
496     public void updateString(final String s, final String s1) throws SQLException {
497 
498     }
499 
500     public void updateBytes(final String s, final byte[] bytes) throws SQLException {
501 
502     }
503 
504     public void updateDate(final String s, final Date date) throws SQLException {
505 
506     }
507 
508     public void updateTime(final String s, final Time time) throws SQLException {
509 
510     }
511 
512     public void updateTimestamp(final String s, final Timestamp timestamp) throws SQLException {
513 
514     }
515 
516     public void updateAsciiStream(final String s, final InputStream inputStream, final int i) throws SQLException {
517 
518     }
519 
520     public void updateBinaryStream(final String s, final InputStream inputStream, final int i) throws SQLException {
521 
522     }
523 
524     public void updateCharacterStream(final String s, final Reader reader, final int i) throws SQLException {
525 
526     }
527 
528     public void updateObject(final String s, final Object o, final int i) throws SQLException {
529 
530     }
531 
532     public void updateObject(final String s, final Object o) throws SQLException {
533 
534     }
535 
536     public void insertRow() throws SQLException {
537 
538     }
539 
540     public void updateRow() throws SQLException {
541 
542     }
543 
544     public void deleteRow() throws SQLException {
545 
546     }
547 
548     public void refreshRow() throws SQLException {
549 
550     }
551 
552     public void cancelRowUpdates() throws SQLException {
553 
554     }
555 
556     public void moveToInsertRow() throws SQLException {
557 
558     }
559 
560     public void moveToCurrentRow() throws SQLException {
561 
562     }
563 
564     public Statement getStatement() throws SQLException {
565         return this.statement;
566     }
567 
568     public Object getObject(final int i, final Map<String, Class<?>> stringClassMap) throws SQLException {
569         return null;
570     }
571 
572     public Ref getRef(final int i) throws SQLException {
573         return null;
574     }
575 
576     public Blob getBlob(final int i) throws SQLException {
577         return null;
578     }
579 
580     public Clob getClob(final int i) throws SQLException {
581         return null;
582     }
583 
584     public Array getArray(final int i) throws SQLException {
585         return null;
586     }
587 
588     public Object getObject(final String s, final Map<String, Class<?>> stringClassMap) throws SQLException {
589         return null;
590     }
591 
592     public Ref getRef(final String s) throws SQLException {
593         return null;
594     }
595 
596     public Blob getBlob(final String s) throws SQLException {
597         return null;
598     }
599 
600     public Clob getClob(final String s) throws SQLException {
601         return null;
602     }
603 
604     public Array getArray(final String s) throws SQLException {
605         return null;
606     }
607 
608     public Date getDate(final int i, final Calendar calendar) throws SQLException {
609         return null;
610     }
611 
612     public Date getDate(final String s, final Calendar calendar) throws SQLException {
613         return null;
614     }
615 
616     public Time getTime(final int i, final Calendar calendar) throws SQLException {
617         return null;
618     }
619 
620     public Time getTime(final String s, final Calendar calendar) throws SQLException {
621         return null;
622     }
623 
624     public Timestamp getTimestamp(final int i, final Calendar calendar) throws SQLException {
625         return null;
626     }
627 
628     public Timestamp getTimestamp(final String s, final Calendar calendar) throws SQLException {
629         return null;
630     }
631 
632     public URL getURL(final int i) throws SQLException {
633         return null;
634     }
635 
636     public URL getURL(final String s) throws SQLException {
637         return null;
638     }
639 
640     public void updateRef(final int i, final Ref ref) throws SQLException {
641 
642     }
643 
644     public void updateRef(final String s, final Ref ref) throws SQLException {
645 
646     }
647 
648     public void updateBlob(final int i, final Blob blob) throws SQLException {
649 
650     }
651 
652     public void updateBlob(final String s, final Blob blob) throws SQLException {
653 
654     }
655 
656     public void updateClob(final int i, final Clob clob) throws SQLException {
657 
658     }
659 
660     public void updateClob(final String s, final Clob clob) throws SQLException {
661 
662     }
663 
664     public void updateArray(final int i, final Array array) throws SQLException {
665 
666     }
667 
668     public void updateArray(final String s, final Array array) throws SQLException {
669 
670     }
671 
672     public RowId getRowId(final int i) throws SQLException {
673         return new RowIdImpl(this.getString(i));
674     }
675 
676     public RowId getRowId(final String s) throws SQLException {
677         return new RowIdImpl(this.getString(s));
678     }
679 
680     public void updateRowId(final int i, final RowId rowId) throws SQLException {
681 
682     }
683 
684     public void updateRowId(final String s, final RowId rowId) throws SQLException {
685 
686     }
687 
688     public int getHoldability() throws SQLException {
689         return 0;
690     }
691 
692     public boolean isClosed() throws SQLException {
693         return false;
694     }
695 
696     public void updateNString(final int i, final String s) throws SQLException {
697 
698     }
699 
700     public void updateNString(final String s, final String s1) throws SQLException {
701 
702     }
703 
704     public void updateNClob(final int i, final NClob nClob) throws SQLException {
705 
706     }
707 
708     public void updateNClob(final String s, final NClob nClob) throws SQLException {
709 
710     }
711 
712     public NClob getNClob(final int i) throws SQLException {
713         return null;
714     }
715 
716     public NClob getNClob(final String s) throws SQLException {
717         return null;
718     }
719 
720     public SQLXML getSQLXML(final int i) throws SQLException {
721         return null;
722     }
723 
724     public SQLXML getSQLXML(final String s) throws SQLException {
725         return null;
726     }
727 
728     public void updateSQLXML(final int i, final SQLXML sqlxml) throws SQLException {
729 
730     }
731 
732     public void updateSQLXML(final String s, final SQLXML sqlxml) throws SQLException {
733 
734     }
735 
736     public String getNString(final int i) throws SQLException {
737         return null;
738     }
739 
740     public String getNString(final String s) throws SQLException {
741         return null;
742     }
743 
744     public Reader getNCharacterStream(final int i) throws SQLException {
745         return null;
746     }
747 
748     public Reader getNCharacterStream(final String s) throws SQLException {
749         return null;
750     }
751 
752     public void updateNCharacterStream(final int i, final Reader reader, final long l) throws SQLException {
753 
754     }
755 
756     public void updateNCharacterStream(final String s, final Reader reader, final long l) throws SQLException {
757 
758     }
759 
760     public void updateAsciiStream(final int i, final InputStream inputStream, final long l) throws SQLException {
761 
762     }
763 
764     public void updateBinaryStream(final int i, final InputStream inputStream, final long l) throws SQLException {
765 
766     }
767 
768     public void updateCharacterStream(final int i, final Reader reader, final long l) throws SQLException {
769 
770     }
771 
772     public void updateAsciiStream(final String s, final InputStream inputStream, final long l) throws SQLException {
773 
774     }
775 
776     public void updateBinaryStream(final String s, final InputStream inputStream, final long l) throws SQLException {
777 
778     }
779 
780     public void updateCharacterStream(final String s, final Reader reader, final long l) throws SQLException {
781 
782     }
783 
784     public void updateBlob(final int i, final InputStream inputStream, final long l) throws SQLException {
785 
786     }
787 
788     public void updateBlob(final String s, final InputStream inputStream, final long l) throws SQLException {
789 
790     }
791 
792     public void updateClob(final int i, final Reader reader, final long l) throws SQLException {
793 
794     }
795 
796     public void updateClob(final String s, final Reader reader, final long l) throws SQLException {
797 
798     }
799 
800     public void updateNClob(final int i, final Reader reader, final long l) throws SQLException {
801 
802     }
803 
804     public void updateNClob(final String s, final Reader reader, final long l) throws SQLException {
805 
806     }
807 
808     public void updateNCharacterStream(final int i, final Reader reader) throws SQLException {
809 
810     }
811 
812     public void updateNCharacterStream(final String s, final Reader reader) throws SQLException {
813 
814     }
815 
816     public void updateAsciiStream(final int i, final InputStream inputStream) throws SQLException {
817 
818     }
819 
820     public void updateBinaryStream(final int i, final InputStream inputStream) throws SQLException {
821 
822     }
823 
824     public void updateCharacterStream(final int i, final Reader reader) throws SQLException {
825 
826     }
827 
828     public void updateAsciiStream(final String s, final InputStream inputStream) throws SQLException {
829 
830     }
831 
832     public void updateBinaryStream(final String s, final InputStream inputStream) throws SQLException {
833 
834     }
835 
836     public void updateCharacterStream(final String s, final Reader reader) throws SQLException {
837 
838     }
839 
840     public void updateBlob(final int i, final InputStream inputStream) throws SQLException {
841 
842     }
843 
844     public void updateBlob(final String s, final InputStream inputStream) throws SQLException {
845 
846     }
847 
848     public void updateClob(final int i, final Reader reader) throws SQLException {
849 
850     }
851 
852     public void updateClob(final String s, final Reader reader) throws SQLException {
853 
854     }
855 
856     public void updateNClob(final int i, final Reader reader) throws SQLException {
857 
858     }
859 
860     public void updateNClob(final String s, final Reader reader) throws SQLException {
861 
862     }
863 }