|
| 1 | +/* |
| 2 | + * Copyright (c) 2007-2012 The Broad Institute, Inc. |
| 3 | + * SOFTWARE COPYRIGHT NOTICE |
| 4 | + * This software and its documentation are the copyright of the Broad Institute, Inc. All rights are reserved. |
| 5 | + * |
| 6 | + * This software is supplied without any warranty or guaranteed support whatsoever. The Broad Institute is not responsible for its use, misuse, or functionality. |
| 7 | + * |
| 8 | + * This software is licensed under the terms of the GNU Lesser General Public License (LGPL), |
| 9 | + * Version 2.1 which is available at http://www.opensource.org/licenses/lgpl-2.1.php. |
| 10 | + */ |
| 11 | + |
| 12 | +package org.broad.igv.dev; |
| 13 | + |
| 14 | +import java.sql.ResultSet; |
| 15 | +import java.sql.SQLException; |
| 16 | + |
| 17 | +/** |
| 18 | + * User: jacob |
| 19 | + * Date: 2012-Aug-30 |
| 20 | + */ |
| 21 | +public class GenDataParser { |
| 22 | + |
| 23 | + public final byte getByte(ResultSet rs, int index) throws SQLException { |
| 24 | + return rs.getByte(index + 1); |
| 25 | + } |
| 26 | + |
| 27 | + public final byte getByte(ResultSet rs, String label) throws SQLException { |
| 28 | + return rs.getByte(label); |
| 29 | + } |
| 30 | + |
| 31 | + public final byte getByte(String[] array, int index) throws NumberFormatException { |
| 32 | + return Byte.valueOf(array[index]); |
| 33 | + } |
| 34 | + |
| 35 | + public final short getShort(ResultSet rs, int index) throws SQLException { |
| 36 | + return rs.getShort(index + 1); |
| 37 | + } |
| 38 | + |
| 39 | + public final short getShort(ResultSet rs, String label) throws SQLException { |
| 40 | + return rs.getShort(label); |
| 41 | + } |
| 42 | + |
| 43 | + public final short getShort(String[] array, int index) throws NumberFormatException { |
| 44 | + return Short.valueOf(array[index]); |
| 45 | + } |
| 46 | + |
| 47 | + public final int getInt(ResultSet rs, int index) throws SQLException { |
| 48 | + return rs.getInt(index + 1); |
| 49 | + } |
| 50 | + |
| 51 | + public final int getInt(ResultSet rs, String label) throws SQLException { |
| 52 | + return rs.getInt(label); |
| 53 | + } |
| 54 | + |
| 55 | + public final int getInt(String[] array, int index) throws NumberFormatException { |
| 56 | + return Integer.valueOf(array[index]); |
| 57 | + } |
| 58 | + |
| 59 | + public final double getDouble(ResultSet rs, int index) throws SQLException { |
| 60 | + return rs.getDouble(index + 1); |
| 61 | + } |
| 62 | + |
| 63 | + public final double getDouble(ResultSet rs, String label) throws SQLException { |
| 64 | + return rs.getDouble(label); |
| 65 | + } |
| 66 | + |
| 67 | + public final double getDouble(String[] array, int index) throws NumberFormatException { |
| 68 | + return Double.valueOf(array[index]); |
| 69 | + } |
| 70 | + |
| 71 | + public final float getFloat(ResultSet rs, int index) throws SQLException { |
| 72 | + return rs.getFloat(index + 1); |
| 73 | + } |
| 74 | + |
| 75 | + public final float getFloat(ResultSet rs, String label) throws SQLException { |
| 76 | + return rs.getFloat(label); |
| 77 | + } |
| 78 | + |
| 79 | + public final float getFloat(String[] array, int index) throws NumberFormatException { |
| 80 | + return Float.valueOf(array[index]); |
| 81 | + } |
| 82 | + |
| 83 | + public final String getString(ResultSet rs, int index) throws SQLException { |
| 84 | + return rs.getString(index + 1); |
| 85 | + } |
| 86 | + |
| 87 | + public final String getString(ResultSet rs, String label) throws SQLException { |
| 88 | + return rs.getString(label); |
| 89 | + } |
| 90 | + |
| 91 | + public final String getString(String[] array, int index) throws NumberFormatException { |
| 92 | + return array[index]; |
| 93 | + } |
| 94 | + |
| 95 | +// public final byte getByte(Object obj, int index) throws SQLException{ |
| 96 | +// if(obj instanceof ResultSet){ |
| 97 | +// return ((ResultSet) obj).getByte(index + 1); |
| 98 | +// }else if(obj instanceof String[]){ |
| 99 | +// return Byte.valueOf(((String[]) obj)[index]); |
| 100 | +// }else{ |
| 101 | +// throw new IllegalArgumentException("Input must be a ResultSet or String[]"); |
| 102 | +// } |
| 103 | +// } |
| 104 | +// |
| 105 | +// public final short getShort(Object obj, int index) throws SQLException{ |
| 106 | +// if(obj instanceof ResultSet){ |
| 107 | +// return ((ResultSet) obj).getShort(index + 1); |
| 108 | +// }else if(obj instanceof String[]){ |
| 109 | +// return Short.valueOf(((String[]) obj)[index]); |
| 110 | +// }else{ |
| 111 | +// throw new IllegalArgumentException("Input must be a ResultSet or String[]"); |
| 112 | +// } |
| 113 | +// } |
| 114 | +// |
| 115 | +// public final int getInt(Object obj, int index) throws SQLException{ |
| 116 | +// if(obj instanceof ResultSet){ |
| 117 | +// return ((ResultSet) obj).getInt(index + 1); |
| 118 | +// }else if(obj instanceof String[]){ |
| 119 | +// return Integer.valueOf(((String[]) obj)[index]); |
| 120 | +// }else{ |
| 121 | +// throw new IllegalArgumentException("Input must be a ResultSet or String[]"); |
| 122 | +// } |
| 123 | +// } |
| 124 | +// |
| 125 | +// public final float getFloat(Object obj, int index) throws SQLException{ |
| 126 | +// if(obj instanceof ResultSet){ |
| 127 | +// return ((ResultSet) obj).getFloat(index + 1); |
| 128 | +// }else if(obj instanceof String[]){ |
| 129 | +// return Float.valueOf(((String[]) obj)[index]); |
| 130 | +// }else{ |
| 131 | +// throw new IllegalArgumentException("Input must be a ResultSet or String[]"); |
| 132 | +// } |
| 133 | +// } |
| 134 | +// |
| 135 | +// public final double getDouble(Object obj, int index) throws SQLException{ |
| 136 | +// if(obj instanceof ResultSet){ |
| 137 | +// return ((ResultSet) obj).getDouble(index + 1); |
| 138 | +// }else if(obj instanceof String[]){ |
| 139 | +// return Double.valueOf(((String[]) obj)[index]); |
| 140 | +// }else{ |
| 141 | +// throw new IllegalArgumentException("Input must be a ResultSet or String[]"); |
| 142 | +// } |
| 143 | +// } |
| 144 | +// |
| 145 | +// public final String getString(Object obj, int index) throws SQLException{ |
| 146 | +// if(obj instanceof ResultSet){ |
| 147 | +// return ((ResultSet) obj).getString(index + 1); |
| 148 | +// }else if(obj instanceof String[]){ |
| 149 | +// return ((String[]) obj)[index]; |
| 150 | +// }else{ |
| 151 | +// throw new IllegalArgumentException("Input must be a ResultSet or String[]"); |
| 152 | +// } |
| 153 | +// } |
| 154 | +// |
| 155 | +} |
0 commit comments