001package com.avaje.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 Object remove(Object name); 043 044 /** 045 * Return a property value by its name. 046 */ 047 Object get(Object name); 048 049 /** 050 * Set a value to a property. 051 */ 052 Object put(String name, Object value); 053 054 /** 055 * Exactly the same as the put method. 056 * <p> 057 * I added this method because it seems more bean like to have get and set 058 * methods. 059 * </p> 060 */ 061 Object set(String name, Object value); 062 063 /** 064 * Return a property as a Boolean. 065 */ 066 Boolean getBoolean(String name); 067 068 /** 069 * Return a property as a UUID. 070 */ 071 UUID getUUID(String name); 072 073 /** 074 * Return a property as an Integer. 075 */ 076 Integer getInteger(String name); 077 078 /** 079 * Return a property value as a BigDecimal. 080 */ 081 BigDecimal getBigDecimal(String name); 082 083 /** 084 * Return a property value as a Long. 085 */ 086 Long getLong(String name); 087 088 /** 089 * Return the property value as a Double. 090 */ 091 Double getDouble(String name); 092 093 /** 094 * Return the property value as a Float. 095 */ 096 Float getFloat(String name); 097 098 /** 099 * Return a property as a String. 100 */ 101 String getString(String name); 102 103 /** 104 * Return the property as a java.util.Date. 105 */ 106 java.util.Date getUtilDate(String name); 107 108 /** 109 * Return the property as a sql date. 110 */ 111 Date getDate(String name); 112 113 /** 114 * Return the property as a sql timestamp. 115 */ 116 Timestamp getTimestamp(String name); 117 118 /** 119 * String description of the underlying map. 120 */ 121 String toString(); 122 123 /** 124 * Clear the map. 125 */ 126 void clear(); 127 128 /** 129 * Returns true if the map contains the property. 130 */ 131 boolean containsKey(Object key); 132 133 /** 134 * Returns true if the map contains the value. 135 */ 136 boolean containsValue(Object value); 137 138 /** 139 * Returns the entrySet of the map. 140 */ 141 Set<Map.Entry<String, Object>> entrySet(); 142 143 /** 144 * Returns true if the map is empty. 145 */ 146 boolean isEmpty(); 147 148 /** 149 * Returns the key set of the map. 150 */ 151 Set<String> keySet(); 152 153 /** 154 * Put all the values from t into this map. 155 */ 156 void putAll(Map<? extends String, ?> t); 157 158 /** 159 * Return the size of the map. 160 */ 161 int size(); 162 163 /** 164 * Return the values from this map. 165 */ 166 Collection<Object> values(); 167 168}