# HG changeset patch # User Sascha L. Teichmann # Date 1255948044 0 # Node ID 1fe93e3c80c004d8cfb1797193e3682348e78f75 # Parent db8920c5346db792593b72cced916ae1eebe0164 DefaultResult now directly inherits from HashMap. geo-backend/trunk@241 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r db8920c5346d -r 1fe93e3c80c0 geo-backend/ChangeLog --- a/geo-backend/ChangeLog Wed Oct 14 10:58:49 2009 +0000 +++ b/geo-backend/ChangeLog Mon Oct 19 10:27:24 2009 +0000 @@ -1,3 +1,12 @@ +2009-10-19 Sascha L. Teichmann + + * src/main/java/de/intevation/gnv/geobackend/base/DefaultResult.java: + Extends from HashMap directly to avoid one level of indirection and + do not create so much needless objects. + + TODO: The representation in form of HashMaps is not very efficent! + Use array with index instead. + 2009-10-14 Tim Englich * src/test/java/de/intevation/gnv/geobackend/base/query/QueryExecutorTestCase.java (testSpatialQueryWithoutIntersects), @@ -100,4 +109,4 @@ 2009-09-04 Tim Englich - * pom.xml: \ No newline at end of file + * pom.xml: diff -r db8920c5346d -r 1fe93e3c80c0 geo-backend/src/main/java/de/intevation/gnv/geobackend/base/DefaultResult.java --- a/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/DefaultResult.java Wed Oct 14 10:58:49 2009 +0000 +++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/DefaultResult.java Mon Oct 19 10:27:24 2009 +0000 @@ -15,8 +15,10 @@ * @author Tim Englich * */ -public class DefaultResult implements Result { - +public class DefaultResult +extends HashMap +implements Result +{ /** * THE UID of this Classe */ @@ -26,8 +28,6 @@ /** * HashMap which stores the Columnvalues identified by the unique Columnname */ - private HashMap columnValues = new HashMap(); - /** * The ResultDescriptor which describes the ColumnValues @@ -46,7 +46,7 @@ * @see de.intevation.gnv.geobackend.base.Result#getDate(java.lang.String) */ public Date getDate(String columnName) { - Object o = this.columnValues.get(columnName); + Object o = get(columnName); Date d = null; if(o instanceof Date){ d = (Date)o; @@ -60,21 +60,21 @@ * @see de.intevation.gnv.geobackend.base.Result#getDouble(java.lang.String) */ public Double getDouble(String columnName) { - return (Double)this.columnValues.get(columnName); + return (Double)get(columnName); } /** * @see de.intevation.gnv.geobackend.base.Result#getFloat(java.lang.String) */ public Float getFloat(String columnName) { - return (Float)this.columnValues.get(columnName); + return (Float)get(columnName); } /** * @see de.intevation.gnv.geobackend.base.Result#getInteger(java.lang.String) */ public Integer getInteger(String columnName) { - return (Integer)this.columnValues.get(columnName); + return (Integer)get(columnName); } /** @@ -88,29 +88,31 @@ * @see de.intevation.gnv.geobackend.base.Result#getString(java.lang.String) */ public String getString(String columnName) { - Object o = this.columnValues.get(columnName); - if(o instanceof Date){ + Object o = get(columnName); + if (o instanceof Date){ return DateUtils.getPatternedDateAmer((Date)o); - }else if (o instanceof GregorianCalendar){ + } + + if (o instanceof GregorianCalendar){ Date d = ((GregorianCalendar)o).getTime(); return DateUtils.getPatternedDateAmer(d); - }else{ - return this.columnValues.get(columnName).toString(); } + + return o != null ? o.toString() : ""; } /** * @see de.intevation.gnv.geobackend.base.Result#addColumnValue(java.lang.String, java.lang.Object) */ public void addColumnValue(String columnName, Object value) { - this.columnValues.put(columnName, value); + put(columnName, value); } /** * @see de.intevation.gnv.geobackend.base.Result#getObject(java.lang.String) */ public Object getObject(String columnName) { - return this.columnValues.get(columnName); + return get(columnName); } }