changeset 270:1fe93e3c80c0

DefaultResult now directly inherits from HashMap. geo-backend/trunk@241 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 19 Oct 2009 10:27:24 +0000
parents db8920c5346d
children 8aad9d098b08
files geo-backend/ChangeLog geo-backend/src/main/java/de/intevation/gnv/geobackend/base/DefaultResult.java
diffstat 2 files changed, 27 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- 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	<sascha.teichmann@intevation.de>
+
+	* 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  <tim.englich@intevation.de>
 
 	* src/test/java/de/intevation/gnv/geobackend/base/query/QueryExecutorTestCase.java (testSpatialQueryWithoutIntersects), 
@@ -100,4 +109,4 @@
 
 2009-09-04  Tim Englich  <tim.englich@intevation.de>
 
-	* pom.xml: 
\ No newline at end of file
+	* pom.xml: 
--- 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 <tim.englich@intevation.de>
  *
  */
-public class DefaultResult implements Result {
-
+public class DefaultResult 
+extends      HashMap<String, Object>
+implements   Result 
+{
     /**
      * THE UID of this Classe
      */
@@ -26,8 +28,6 @@
     /**
      * HashMap which stores the Columnvalues identified by the unique Columnname
      */
-    private HashMap<String, Object> columnValues = new HashMap<String, Object>();
-    
     
     /**
      * 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);
     }
 
 }

http://dive4elements.wald.intevation.org