1 16 19 20 21 22 package org.apache.xalan.lib.sql; 23 24 import java.util.Hashtable ; 25 import java.sql.PreparedStatement ; 26 import java.sql.CallableStatement ; 27 import java.sql.Statement ; 28 29 public class QueryParameter 30 { 31 private int m_type; 32 private String m_name; 33 private String m_value; 34 private boolean m_output; 35 private String m_typeName; 36 private static Hashtable m_Typetable = null; 37 38 public QueryParameter() 39 { 40 m_type = -1; 41 m_name = null; 42 m_value = null; 43 m_output = false; 44 m_typeName = null; 45 } 46 47 51 public QueryParameter( String v, String t ) 52 { 53 m_name = null; 54 m_value = v; 55 m_output = false; 56 setTypeName(t); 57 } 58 59 public QueryParameter( String name, String value, String type, boolean out_flag ) 60 { 61 m_name = name; 62 m_value = value; 63 m_output = out_flag; 64 setTypeName(type); 65 } 66 67 70 public String getValue( ) { 71 return m_value; 72 } 73 74 78 public void setValue( String newValue ) { 79 m_value = newValue; 80 } 81 82 86 public void setTypeName( String newType ) 87 { 88 m_type = map_type(newType); 89 m_typeName = newType; 90 } 91 92 95 public String getTypeName( ) 96 { 97 return m_typeName; 98 } 99 100 103 public int getType( ) 104 { 105 return m_type; 106 } 107 108 111 public String getName() 112 { 113 return m_name; 114 } 115 116 121 public void setName(String n) 122 { 123 m_name = n; 124 } 125 126 129 public boolean isOutput() 130 { 131 return m_output; 132 } 133 134 139 public void setIsOutput(boolean flag) 140 { 141 m_output = flag; 142 } 143 144 private static int map_type(String typename) 145 { 146 if ( m_Typetable == null ) 147 { 148 m_Typetable = new Hashtable (); 150 m_Typetable.put("BIGINT", new Integer (java.sql.Types.BIGINT)); 151 m_Typetable.put("BINARY", new Integer (java.sql.Types.BINARY)); 152 m_Typetable.put("BIT", new Integer (java.sql.Types.BIT)); 153 m_Typetable.put("CHAR", new Integer (java.sql.Types.CHAR)); 154 m_Typetable.put("DATE", new Integer (java.sql.Types.DATE)); 155 m_Typetable.put("DECIMAL", new Integer (java.sql.Types.DECIMAL)); 156 m_Typetable.put("DOUBLE", new Integer (java.sql.Types.DOUBLE)); 157 m_Typetable.put("FLOAT", new Integer (java.sql.Types.FLOAT)); 158 m_Typetable.put("INTEGER", new Integer (java.sql.Types.INTEGER)); 159 m_Typetable.put("LONGVARBINARY", new Integer (java.sql.Types.LONGVARBINARY)); 160 m_Typetable.put("LONGVARCHAR", new Integer (java.sql.Types.LONGVARCHAR)); 161 m_Typetable.put("NULL", new Integer (java.sql.Types.NULL)); 162 m_Typetable.put("NUMERIC", new Integer (java.sql.Types.NUMERIC)); 163 m_Typetable.put("OTHER", new Integer (java.sql.Types.OTHER)); 164 m_Typetable.put("REAL", new Integer (java.sql.Types.REAL)); 165 m_Typetable.put("SMALLINT", new Integer (java.sql.Types.SMALLINT)); 166 m_Typetable.put("TIME", new Integer (java.sql.Types.TIME)); 167 m_Typetable.put("TIMESTAMP", new Integer (java.sql.Types.TIMESTAMP)); 168 m_Typetable.put("TINYINT", new Integer (java.sql.Types.TINYINT)); 169 m_Typetable.put("VARBINARY", new Integer (java.sql.Types.VARBINARY)); 170 m_Typetable.put("VARCHAR", new Integer (java.sql.Types.VARCHAR)); 171 172 m_Typetable.put("STRING", new Integer (java.sql.Types.VARCHAR)); 174 m_Typetable.put("BIGDECIMAL", new Integer (java.sql.Types.NUMERIC)); 175 m_Typetable.put("BOOLEAN", new Integer (java.sql.Types.BIT)); 176 m_Typetable.put("BYTES", new Integer (java.sql.Types.LONGVARBINARY)); 177 m_Typetable.put("LONG", new Integer (java.sql.Types.BIGINT)); 178 m_Typetable.put("SHORT", new Integer (java.sql.Types.SMALLINT)); 179 } 180 181 Integer type = (Integer ) m_Typetable.get(typename.toUpperCase()); 182 int rtype; 183 if ( type == null ) 184 rtype = java.sql.Types.OTHER; 185 else 186 rtype = type.intValue(); 187 188 return(rtype); 189 } 190 191 198 206 274 275 } 276 277 278 | Popular Tags |