From b726cbf3bb8fa82b59fd985eaf194fb0b973aae4 Mon Sep 17 00:00:00 2001 From: bernd Date: Thu, 4 Aug 2011 02:11:38 +0200 Subject: [PATCH 14/16] Guard MapDataObjectBinding against setting a bad object type (can happen by providing MapDataObjectBinding as a custom resultSetBinding when it does not match the actual return type). --- .../eodsql/spi/util/MapDataObjectBinding.java | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/eodsql/src/net/lemnik/eodsql/spi/util/MapDataObjectBinding.java b/eodsql/src/net/lemnik/eodsql/spi/util/MapDataObjectBinding.java index 723ebf0..6883c84 100644 --- a/eodsql/src/net/lemnik/eodsql/spi/util/MapDataObjectBinding.java +++ b/eodsql/src/net/lemnik/eodsql/spi/util/MapDataObjectBinding.java @@ -14,6 +14,7 @@ import java.util.HashMap; import java.util.Map; import net.lemnik.eodsql.EoDException; +import net.lemnik.eodsql.InvalidDataTypeException; /** * A {@link DataObjectBinding} that stores the {@link ResultSet} in a @@ -23,6 +24,13 @@ import net.lemnik.eodsql.EoDException; */ public class MapDataObjectBinding extends DataObjectBinding> { @Override + protected void setObjectType(Class> objectType) { + if (Map.class.isAssignableFrom(objectType) == false) { + throw new InvalidDataTypeException(objectType); + } + } + + @Override public Class> getObjectType() { return getStringObjectMapObjectType(); } -- 1.7.6