001package io.ebean; 002 003import java.io.Serializable; 004import java.math.BigDecimal; 005import java.sql.Date; 006import java.sql.Timestamp; 007import java.util.Collection; 008import java.util.Iterator; 009import java.util.Map; 010import java.util.Set; 011import java.util.UUID; 012 013/** 014 * Used to return raw SQL query results. 015 * <p> 016 * Refer to {@link SqlQuery} for examples. 017 * </p> 018 * <p> 019 * There are convenience methods such as getInteger(), getBigDecimal() etc. The 020 * reason for these methods is that the values put into this map often come 021 * straight from the JDBC resultSet. Depending on the JDBC driver it may put a 022 * different type into a given property. For example an Integer, BigDecimal, 023 * Double could all be put into a property depending on the JDBC driver used. 024 * These convenience methods automatically convert the value as required 025 * returning the type you expect. 026 * </p> 027 */ 028public interface SqlRow extends Serializable, Map<String, Object> { 029 030 /** 031 * Return the property names (String). 032 * <p> 033 * Internally this uses LinkedHashMap and so the order of the property names 034 * should be predictable and ordered by the use of LinkedHashMap. 035 * </p> 036 */ 037 Iterator<String> keys(); 038 039 /** 040 * Remove a property from the map. Returns the value of the removed property. 041 */ 042 @Override 043 Object remove(Object name); 044 045 /** 046 * Return a property value by its name. 047 */ 048 @Override 049 Object get(Object name); 050 051 /** 052 * Set a value to a property. 053 */ 054 @Override 055 Object put(String name, Object value); 056 057 /** 058 * Exactly the same as the put method. 059 * <p> 060 * I added this method because it seems more bean like to have get and set 061 * methods. 062 * </p> 063 */ 064 Object set(String name, Object value); 065 066 /** 067 * Return a property as a Boolean. 068 */ 069 Boolean getBoolean(String name); 070 071 /** 072 * Return a property as a UUID. 073 */ 074 UUID getUUID(String name); 075 076 /** 077 * Return a property as an Integer. 078 */ 079 Integer getInteger(String name); 080 081 /** 082 * Return a property value as a BigDecimal. 083 */ 084 BigDecimal getBigDecimal(String name); 085 086 /** 087 * Return a property value as a Long. 088 */ 089 Long getLong(String name); 090 091 /** 092 * Return the property value as a Double. 093 */ 094 Double getDouble(String name); 095 096 /** 097 * Return the property value as a Float. 098 */ 099 Float getFloat(String name); 100 101 /** 102 * Return a property as a String. 103 */ 104 String getString(String name); 105 106 /** 107 * Return the property as a java.util.Date. 108 */ 109 java.util.Date getUtilDate(String name); 110 111 /** 112 * Return the property as a sql date. 113 */ 114 Date getDate(String name); 115 116 /** 117 * Return the property as a sql timestamp. 118 */ 119 Timestamp getTimestamp(String name); 120 121 /** 122 * String description of the underlying map. 123 */ 124 @Override 125 String toString(); 126 127 /** 128 * Clear the map. 129 */ 130 @Override 131 void clear(); 132 133 /** 134 * Returns true if the map contains the property. 135 */ 136 @Override 137 boolean containsKey(Object key); 138 139 /** 140 * Returns true if the map contains the value. 141 */ 142 @Override 143 boolean containsValue(Object value); 144 145 /** 146 * Returns the entrySet of the map. 147 */ 148 @Override 149 Set<Map.Entry<String, Object>> entrySet(); 150 151 /** 152 * Returns true if the map is empty. 153 */ 154 @Override 155 boolean isEmpty(); 156 157 /** 158 * Returns the key set of the map. 159 */ 160 @Override 161 Set<String> keySet(); 162 163 /** 164 * Put all the values from t into this map. 165 */ 166 @Override 167 void putAll(Map<? extends String, ?> t); 168 169 /** 170 * Return the size of the map. 171 */ 172 @Override 173 int size(); 174 175 /** 176 * Return the values from this map. 177 */ 178 @Override 179 Collection<Object> values(); 180 181}