1 32 33 package com.mockobjects.eziba.sql; 34 import java.sql.SQLException ; 35 import java.math.BigDecimal ; 36 import java.util.Calendar ; 37 import java.util.Map ; 38 import java.util.HashMap ;public class ResultSet 39 implements java.sql.ResultSet 40 { 41 42 public static final ResultSet EMPTY_SET = new ResultSet(); 43 44 private ResultSet() 45 { 46 this (null, new Object [0], null); 47 } 48 49 50 private int m_current; 51 private boolean m_wasNull = false; 52 53 public ResultSet(Object [] p_data, String [] p_names) 54 { 55 this(p_data, p_names, p_names); 56 } 57 58 62 63 private static Object [] validateConstructorArgs(Object [] p_data, 64 String [] p_columnNames, 65 String [] p_propNames) 66 { 67 if (p_data == null) 68 { 69 throw new IllegalArgumentException ("Object array can't be null"); 70 } 71 if (p_columnNames == null) 72 { 73 throw new IllegalArgumentException ("Column names can't be null"); 74 } 75 if (p_propNames == null) 76 { 77 throw new IllegalArgumentException ("Property names can't be null"); 78 } 79 if (p_columnNames.length != p_propNames.length) 80 { 81 throw new IllegalArgumentException ("Number of column names (" 82 + p_columnNames.length + ")" 83 + " does not match " 84 + " number of property names (" 85 + p_propNames.length + ")"); 86 } 87 return p_data; 88 } 89 90 public ResultSet(Object [] p_data, 91 String [] p_columnNames, 92 String [] p_propNames) 93 { 94 this (new ReflectiveResultSetRowGenerator(p_propNames), 95 validateConstructorArgs(p_data, p_columnNames, p_propNames), 96 createMapFromStringArray(p_columnNames)); 97 } 98 99 private static Map createMapFromStringArray(String [] p_columnNames) 100 { 101 Map map = new HashMap (); 102 for (int i = 0; i < p_columnNames.length; ++i) 103 { 104 map.put(p_columnNames[i],new Integer (i)); 105 } 106 return map; 107 } 108 109 public ResultSet(ResultSetRowGenerator p_generator, 110 Object [] p_data, 111 Map p_columnNameMap) 112 { 113 m_generator = p_generator; 114 m_data = p_data; 115 m_columnNameMap = p_columnNameMap; 116 m_current = -1; 117 } 118 119 private final ResultSetRowGenerator m_generator; 120 private final Object [] m_data; 121 private final Map m_columnNameMap; 122 123 private Object [] getCurrentRow() 124 throws SQLException 125 { 126 Object [] result = m_generator.createRow(m_data[m_current]); 127 return result; 131 } 132 133 private Object getColumnData(int p_columnNum) 134 throws SQLException 135 { 136 Object [] row = getCurrentRow(); 137 if (p_columnNum < 0 || p_columnNum >= row.length) 138 { 139 throw new SQLException ("Illegal column number " + p_columnNum); 140 } 141 144 Object result = row[p_columnNum]; 145 146 m_wasNull = (result == null); 147 148 return result; 149 } 150 151 public int findColumn(String p_columnName) 152 throws SQLException 153 { 154 Integer i = (Integer ) m_columnNameMap.get(p_columnName); 155 if (i != null) 156 { 157 return i.intValue(); 158 } 159 else 160 { 161 throw new SQLException ("No such column " + p_columnName); 162 } 163 } 164 165 public boolean next() 166 throws SQLException 167 { 168 m_current++; 169 return m_current < m_data.length; 170 } 171 172 public void close() 173 throws SQLException 174 { 175 } 177 178 public boolean wasNull() 179 throws SQLException 180 { 181 return m_wasNull; 182 } 183 184 public String getString(int columnIndex) 185 throws SQLException 186 { 187 return (String ) getColumnData(columnIndex); 188 } 189 190 public boolean getBoolean(int columnIndex) 191 throws SQLException 192 { 193 return ((Boolean ) getColumnData(columnIndex)).booleanValue(); 194 } 195 196 public byte getByte(int columnIndex) 197 throws SQLException 198 { 199 return ((Byte ) getColumnData(columnIndex)).byteValue(); 200 } 201 202 public short getShort(int columnIndex) 203 throws SQLException 204 { 205 return ((Short ) getColumnData(columnIndex)).shortValue(); 206 } 207 208 public int getInt(int columnIndex) 209 throws SQLException 210 { 211 Integer i = (Integer ) getColumnData(columnIndex); 212 return i == null ? 0 : i.intValue(); 213 } 214 215 public long getLong(int columnIndex) 216 throws SQLException 217 { 218 return ((Long ) getColumnData(columnIndex)).longValue(); 219 } 220 221 public float getFloat(int columnIndex) 222 throws SQLException 223 { 224 return ((Float ) getColumnData(columnIndex)).floatValue(); 225 } 226 227 public double getDouble(int columnIndex) 228 throws SQLException 229 { 230 return ((Double ) getColumnData(columnIndex)).doubleValue(); 231 } 232 233 236 public BigDecimal getBigDecimal(int columnIndex, int scale) 237 throws SQLException 238 { 239 return (BigDecimal ) getColumnData(columnIndex); 240 } 241 242 public byte[] getBytes(int columnIndex) 243 throws SQLException 244 { 245 return (byte []) getColumnData(columnIndex); 246 } 247 248 public java.sql.Date getDate(int columnIndex) 249 throws SQLException 250 { 251 Object o = getColumnData(columnIndex); 253 if (o == null) 254 { 255 return null; 256 } 257 else if (o instanceof java.sql.Date ) 258 { 259 return (java.sql.Date ) o; 260 } 261 else if (o instanceof java.util.Date ) 262 { 263 return new java.sql.Date (((java.util.Date )o).getTime()); 264 } 265 else 266 { 267 throw new SQLException ("Expected date type, got " + o.getClass()); 268 } 269 } 270 271 public java.sql.Time getTime(int columnIndex) 272 throws SQLException 273 { 274 return (java.sql.Time ) getColumnData(columnIndex); 275 } 276 277 public java.sql.Timestamp getTimestamp(int columnIndex) 278 throws SQLException 279 { 280 return (java.sql.Timestamp ) getColumnData(columnIndex); 281 } 282 283 public java.io.InputStream getAsciiStream(int columnIndex) 284 throws SQLException 285 { 286 return (java.io.InputStream ) getColumnData(columnIndex); 287 } 288 289 292 public java.io.InputStream getUnicodeStream(int columnIndex) 293 throws SQLException 294 { 295 return (java.io.InputStream ) getColumnData(columnIndex); 296 } 297 298 public java.io.InputStream getBinaryStream(int columnIndex) 299 300 throws SQLException 301 { 302 return (java.io.InputStream ) getColumnData(columnIndex); 303 } 304 305 309 public String getString(String columnName) 310 throws SQLException 311 { 312 return getString(findColumn(columnName)); 313 } 314 315 public boolean getBoolean(String columnName) 316 throws SQLException 317 { 318 return getBoolean(findColumn(columnName)); 319 } 320 321 public byte getByte(String columnName) 322 throws SQLException 323 { 324 return getByte(findColumn(columnName)); 325 } 326 327 public short getShort(String columnName) 328 throws SQLException 329 { 330 return getShort(findColumn(columnName)); 331 } 332 333 public int getInt(String columnName) 334 throws SQLException 335 { 336 return getInt(findColumn(columnName)); 337 } 338 339 public long getLong(String columnName) 340 throws SQLException 341 { 342 return getLong(findColumn(columnName)); 343 } 344 345 public float getFloat(String columnName) 346 throws SQLException 347 { 348 return getFloat(findColumn(columnName)); 349 } 350 351 public double getDouble(String columnName) 352 throws SQLException 353 { 354 return getDouble(findColumn(columnName)); 355 } 356 357 360 public BigDecimal getBigDecimal(String columnName, int scale) 361 throws SQLException 362 { 363 throw new NotImplementedException(); 364 } 365 366 public byte[] getBytes(String columnName) 367 throws SQLException 368 { 369 return getBytes(findColumn(columnName)); 370 } 371 372 public java.sql.Date getDate(String columnName) 373 throws SQLException 374 { 375 return getDate(findColumn(columnName)); 376 } 377 378 public java.sql.Time getTime(String columnName) 379 throws SQLException 380 { 381 return getTime(findColumn(columnName)); 382 } 383 384 public java.sql.Timestamp getTimestamp(String columnName) 385 throws SQLException 386 { 387 return getTimestamp(findColumn(columnName)); 388 } 389 390 public java.io.InputStream getAsciiStream(String columnName) 391 throws SQLException 392 { 393 return getAsciiStream(findColumn(columnName)); 394 } 395 396 399 public java.io.InputStream getUnicodeStream(String columnName) 400 throws SQLException 401 { 402 return getUnicodeStream(findColumn(columnName)); 403 } 404 405 public java.io.InputStream getBinaryStream(String columnName) 406 407 throws SQLException 408 { 409 return getBinaryStream(findColumn(columnName)); 410 } 411 412 public BigDecimal getBigDecimal(String columnName) 413 throws SQLException 414 { 415 return (BigDecimal ) getColumnData(findColumn(columnName)); 416 } 417 418 public boolean first() 419 throws SQLException 420 { 421 m_current = -1; 422 return m_data.length > 0; 423 } 424 425 429 public java.sql.SQLWarning getWarnings() 430 throws SQLException 431 { 432 throw new NotImplementedException(); 433 } 434 435 public void clearWarnings() 436 throws SQLException 437 { 438 throw new NotImplementedException(); 439 } 440 441 public String getCursorName() 442 throws SQLException 443 { 444 throw new NotImplementedException(); 445 } 446 447 public java.sql.ResultSetMetaData getMetaData() 448 throws SQLException 449 { 450 throw new NotImplementedException(); 451 } 452 453 public Object getObject(int columnIndex) 454 throws SQLException 455 { 456 throw new NotImplementedException(); 457 } 458 459 public Object getObject(String columnName) 460 throws SQLException 461 { 462 throw new NotImplementedException(); 463 } 464 465 467 468 469 471 475 public java.io.Reader getCharacterStream(int columnIndex) 476 throws SQLException 477 { 478 throw new NotImplementedException(); 479 } 480 481 public java.io.Reader getCharacterStream(String columnName) 482 throws SQLException 483 { 484 throw new NotImplementedException(); 485 } 486 487 public BigDecimal getBigDecimal(int columnIndex) 488 throws SQLException 489 { 490 throw new NotImplementedException(); 491 } 492 493 497 public boolean isBeforeFirst() 498 throws SQLException 499 { 500 throw new NotImplementedException(); 501 } 502 503 public boolean isAfterLast() 504 throws SQLException 505 { 506 throw new NotImplementedException(); 507 } 508 509 public boolean isFirst() 510 throws SQLException 511 { 512 throw new NotImplementedException(); 513 } 514 515 public boolean isLast() 516 throws SQLException 517 { 518 throw new NotImplementedException(); 519 } 520 521 public void beforeFirst() 522 throws SQLException 523 { 524 throw new NotImplementedException(); 525 } 526 527 public void afterLast() 528 throws SQLException 529 { 530 throw new NotImplementedException(); 531 } 532 533 public boolean last() 534 throws SQLException 535 { 536 throw new NotImplementedException(); 537 } 538 539 public int getRow() 540 throws SQLException 541 { 542 throw new NotImplementedException(); 543 } 544 545 public boolean absolute( int row ) 546 throws SQLException 547 { 548 throw new NotImplementedException(); 549 } 550 551 public boolean relative( int rows ) 552 throws SQLException 553 { 554 throw new NotImplementedException(); 555 } 556 557 public boolean previous() 558 throws SQLException 559 { 560 throw new NotImplementedException(); 561 } 562 563 567 public void setFetchDirection(int direction) 568 throws SQLException 569 { 570 throw new NotImplementedException(); 571 } 572 573 public int getFetchDirection() 574 throws SQLException 575 { 576 return FETCH_FORWARD; 577 } 578 579 public void setFetchSize(int rows) 580 throws SQLException 581 { 582 throw new NotImplementedException(); 583 } 584 585 public int getFetchSize() 586 throws SQLException 587 { 588 throw new NotImplementedException(); 589 } 590 591 public int getType() 592 throws SQLException 593 { 594 return TYPE_FORWARD_ONLY; 595 } 596 597 public int getConcurrency() 598 throws SQLException 599 { 600 return CONCUR_READ_ONLY; 601 } 602 603 607 public boolean rowUpdated() 608 throws SQLException 609 { 610 throw new NotImplementedException(); 611 } 612 613 public boolean rowInserted() 614 throws SQLException 615 { 616 throw new NotImplementedException(); 617 } 618 619 public boolean rowDeleted() 620 throws SQLException 621 { 622 throw new NotImplementedException(); 623 } 624 625 public void updateNull(int columnIndex) 626 throws SQLException 627 { 628 throw new NotImplementedException(); 629 } 630 631 public void updateBoolean(int columnIndex, boolean x) 632 throws SQLException 633 { 634 throw new NotImplementedException(); 635 } 636 637 public void updateByte(int columnIndex, byte x) 638 throws SQLException 639 { 640 throw new NotImplementedException(); 641 } 642 643 public void updateShort(int columnIndex, short x) 644 throws SQLException 645 { 646 throw new NotImplementedException(); 647 } 648 649 public void updateInt(int columnIndex, int x) 650 throws SQLException 651 { 652 throw new NotImplementedException(); 653 } 654 655 public void updateLong(int columnIndex, long x) 656 throws SQLException 657 { 658 throw new NotImplementedException(); 659 } 660 661 public void updateFloat(int columnIndex, float x) 662 throws SQLException 663 { 664 throw new NotImplementedException(); 665 } 666 667 public void updateDouble(int columnIndex, double x) 668 throws SQLException 669 { 670 throw new NotImplementedException(); 671 } 672 673 public void updateBigDecimal(int columnIndex, BigDecimal x) 674 throws SQLException 675 { 676 throw new NotImplementedException(); 677 } 678 679 public void updateString(int columnIndex, String x) 680 throws SQLException 681 { 682 throw new NotImplementedException(); 683 } 684 685 public void updateBytes(int columnIndex, byte x[]) 686 throws SQLException 687 { 688 throw new NotImplementedException(); 689 } 690 691 public void updateDate(int columnIndex, java.sql.Date x) 692 throws SQLException 693 { 694 throw new NotImplementedException(); 695 } 696 697 public void updateTime(int columnIndex, java.sql.Time x) 698 throws SQLException 699 { 700 throw new NotImplementedException(); 701 } 702 703 public void updateTimestamp(int columnIndex, java.sql.Timestamp x) 704 705 throws SQLException 706 { 707 throw new NotImplementedException(); 708 } 709 710 public void updateAsciiStream(int columnIndex, 711 java.io.InputStream x, 712 int length) 713 throws SQLException 714 { 715 throw new NotImplementedException(); 716 } 717 718 public void updateBinaryStream(int columnIndex, 719 java.io.InputStream x, 720 int length) 721 throws SQLException 722 { 723 throw new NotImplementedException(); 724 } 725 726 public void updateCharacterStream(int columnIndex, 727 java.io.Reader x, 728 int length) 729 throws SQLException 730 { 731 throw new NotImplementedException(); 732 } 733 734 public void updateObject(int columnIndex, Object x, int scale) 735 736 throws SQLException 737 { 738 throw new NotImplementedException(); 739 } 740 741 public void updateObject(int columnIndex, Object x) 742 throws SQLException 743 { 744 throw new NotImplementedException(); 745 } 746 747 public void updateNull(String columnName) 748 throws SQLException 749 { 750 throw new NotImplementedException(); 751 } 752 753 public void updateBoolean(String columnName, boolean x) 754 throws SQLException 755 { 756 throw new NotImplementedException(); 757 } 758 759 public void updateByte(String columnName, byte x) 760 throws SQLException 761 { 762 throw new NotImplementedException(); 763 } 764 765 public void updateShort(String columnName, short x) 766 throws SQLException 767 { 768 throw new NotImplementedException(); 769 } 770 771 public void updateInt(String columnName, int x) 772 throws SQLException 773 { 774 throw new NotImplementedException(); 775 } 776 777 public void updateLong(String columnName, long x) 778 throws SQLException 779 { 780 throw new NotImplementedException(); 781 } 782 783 public void updateFloat(String columnName, float x) 784 throws SQLException 785 { 786 throw new NotImplementedException(); 787 } 788 789 public void updateDouble(String columnName, double x) 790 throws SQLException 791 { 792 throw new NotImplementedException(); 793 } 794 795 public void updateBigDecimal(String columnName, BigDecimal x) 796 throws SQLException 797 { 798 throw new NotImplementedException(); 799 } 800 801 public void updateString(String columnName, String x) 802 throws SQLException 803 { 804 throw new NotImplementedException(); 805 } 806 807 public void updateBytes(String columnName, byte x[]) 808 throws SQLException 809 { 810 throw new NotImplementedException(); 811 } 812 813 public void updateDate(String columnName, java.sql.Date x) 814 throws SQLException 815 { 816 throw new NotImplementedException(); 817 } 818 819 public void updateTime(String columnName, java.sql.Time x) 820 throws SQLException 821 { 822 throw new NotImplementedException(); 823 } 824 825 public void updateTimestamp(String columnName, java.sql.Timestamp x) 826 827 throws SQLException 828 { 829 throw new NotImplementedException(); 830 } 831 832 public void updateAsciiStream(String columnName, 833 java.io.InputStream x, 834 int length) 835 throws SQLException 836 { 837 throw new NotImplementedException(); 838 } 839 840 public void updateBinaryStream(String columnName, 841 java.io.InputStream x, 842 int length) 843 throws SQLException 844 { 845 throw new NotImplementedException(); 846 } 847 848 public void updateCharacterStream(String columnName, 849 java.io.Reader reader, 850 int length) 851 throws SQLException 852 { 853 throw new NotImplementedException(); 854 } 855 856 public void updateObject(String columnName, Object x, int scale) 857 858 throws SQLException 859 { 860 throw new NotImplementedException(); 861 } 862 863 public void updateObject(String columnName, Object x) 864 throws SQLException 865 { 866 throw new NotImplementedException(); 867 } 868 869 public void insertRow() 870 throws SQLException 871 { 872 throw new NotImplementedException(); 873 } 874 875 public void updateRow() 876 throws SQLException 877 { 878 throw new NotImplementedException(); 879 } 880 881 public void deleteRow() 882 throws SQLException 883 { 884 throw new NotImplementedException(); 885 } 886 887 public void refreshRow() 888 throws SQLException 889 { 890 throw new NotImplementedException(); 891 } 892 893 public void cancelRowUpdates() 894 throws SQLException 895 { 896 throw new NotImplementedException(); 897 } 898 899 public void moveToInsertRow() 900 throws SQLException 901 { 902 throw new NotImplementedException(); 903 } 904 905 public void moveToCurrentRow() 906 throws SQLException 907 { 908 throw new NotImplementedException(); 909 } 910 911 public java.sql.Statement getStatement() 912 throws SQLException 913 { 914 throw new NotImplementedException(); 915 } 916 917 public Object getObject(int i, java.util.Map map) 918 throws SQLException 919 { 920 throw new NotImplementedException(); 921 } 922 923 public java.sql.Ref getRef(int i) 924 throws SQLException 925 { 926 throw new NotImplementedException(); 927 } 928 929 public java.sql.Blob getBlob(int i) 930 throws SQLException 931 { 932 throw new NotImplementedException(); 933 } 934 935 public java.sql.Clob getClob(int i) 936 throws SQLException 937 { 938 throw new NotImplementedException(); 939 } 940 941 public java.sql.Array getArray(int i) 942 throws SQLException 943 { 944 throw new NotImplementedException(); 945 } 946 947 public Object getObject(String colName, java.util.Map map) 948 throws SQLException 949 { 950 throw new NotImplementedException(); 951 } 952 953 public java.sql.Ref getRef(String colName) 954 throws SQLException 955 { 956 throw new NotImplementedException(); 957 } 958 959 public java.sql.Blob getBlob(String colName) 960 throws SQLException 961 { 962 throw new NotImplementedException(); 963 } 964 965 public java.sql.Clob getClob(String colName) 966 throws SQLException 967 { 968 throw new NotImplementedException(); 969 } 970 971 public java.sql.Array getArray(String colName) 972 throws SQLException 973 { 974 throw new NotImplementedException(); 975 } 976 977 public java.sql.Date getDate(int columnIndex, Calendar cal) 978 throws SQLException 979 { 980 throw new NotImplementedException(); 981 } 982 983 public java.sql.Date getDate(String columnName, Calendar cal) 984 throws SQLException 985 { 986 throw new NotImplementedException(); 987 } 988 989 public java.sql.Time getTime(int columnIndex, Calendar cal) 990 throws SQLException 991 { 992 throw new NotImplementedException(); 993 } 994 995 public java.sql.Time getTime(String columnName, Calendar cal) 996 throws SQLException 997 { 998 throw new NotImplementedException(); 999 } 1000 1001 public java.sql.Timestamp getTimestamp(int columnIndex, Calendar cal) 1002 1003 throws SQLException 1004 { 1005 throw new NotImplementedException(); 1006 } 1007 1008 public java.sql.Timestamp getTimestamp(String columnName, Calendar cal) 1009 1010 throws SQLException 1011 { 1012 throw new NotImplementedException(); 1013 } 1014} | Popular Tags |