package lx.easydb;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * {@link ValueExtractor} for {@link Map} types,
 * extracts fields and puts them in a case-insensitive {@link LinkedHashMap}.
 * 
 * @author Long
 *
 */
public class MapExtractor extends ObjectExtractor {

	public void extract(ResultSet rs, Object item, int index,
			String field) throws SQLException {
		Map map = (Map) item;
		map.put(field, rs.getObject(index));
	}

	protected Object newInstance() {
		return new LinkedHashMap() {
			private static final long serialVersionUID = -5300859616547090379L;

			public Object put(Object key, Object value) {
				return key == null ? super.put(key, value) :
					super.put(key.toString().toUpperCase(), value);
			}
			
			public Object get(Object key) {
				return key == null ? super.get(key) :
					super.get(key.toString().toUpperCase());
			}
		};
	}
}

@@ -334,16 +334,265 @@
 ractor %7B
+%0A%09public static final int ORIGIN = 0;%0A%09public static final int LOWERCASE = -1;%0A%09public static final int UPPERCASE = 1;%0A%09private int casing;%0A%09%0A%09public MapExtractor() %7B%0A%09%09this(ORIGIN);%0A%09%7D%0A%09%0A%09public MapExtractor(int casing) %7B%0A%09%09this.casing = casing;%0A%09%7D
 %0A%0A%09publi
@@ -1000,16 +1000,23 @@
 per.put(
+casing(
 key.toSt
@@ -1021,29 +1021,16 @@
 String()
-.toUpperCase(
 ), value
@@ -1133,16 +1133,23 @@
 per.get(
+casing(
 key.toSt
@@ -1154,16 +1154,170 @@
 String()
+));%0A%09%09%09%7D%0A%09%09%7D;%0A%09%7D%0A%09%0A%09private String casing(String key) %7B%0A%09%09switch (casing) %7B%0A%09%09case LOWERCASE:%0A%09%09%09return key.toLowerCase();%0A%09%09case UPPERCASE:%0A%09%09%09return key
 .toUpper
@@ -1322,26 +1322,157 @@
 erCase()
-)
 ;%0A%09%09
-%09%7D%0A%09%09%7D
+default:%0A%09%09%09return key;%0A%09%09%7D%0A%09%7D%0A%0A%09public int getCasing() %7B%0A%09%09return casing;%0A%09%7D%0A%0A%09public void setCasing(int casing) %7B%0A%09%09this.casing = casing
 ;%0A%09%7D%0A%7D%0A

allow uppercase/lowercase or keep the original column name from db in MapExtractor