Mercurial > dive4elements > gnv-client
view geo-backend/src/main/java/de/intevation/gnv/geobackend/base/DefaultResult.java @ 145:92faade399e4 0.1
merged geo-backend/0.1
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:13:42 +0200 |
parents | b02310d7ffee |
children | 1fe93e3c80c0 |
line wrap: on
line source
/** * */ package de.intevation.gnv.geobackend.base; import java.util.Date; import java.util.GregorianCalendar; import java.util.HashMap; import de.intevation.gnv.geobackend.util.DateUtils; /** * Defaultimplementation of the Interface Result. * This Class stores the Attributevalues of one Result. * @author Tim Englich <tim.englich@intevation.de> * */ public class DefaultResult implements Result { /** * THE UID of this Classe */ private static final long serialVersionUID = -6886218808840982766L; /** * 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 */ private ResultDescriptor resultDescriptor = null; /** * Constructor */ public DefaultResult(ResultDescriptor resultDescriptor) { super(); this.resultDescriptor = resultDescriptor; } /** * @see de.intevation.gnv.geobackend.base.Result#getDate(java.lang.String) */ public Date getDate(String columnName) { Object o = this.columnValues.get(columnName); Date d = null; if(o instanceof Date){ d = (Date)o; }else if (o instanceof GregorianCalendar){ d = ((GregorianCalendar)o).getTime(); } return d; } /** * @see de.intevation.gnv.geobackend.base.Result#getDouble(java.lang.String) */ public Double getDouble(String columnName) { return (Double)this.columnValues.get(columnName); } /** * @see de.intevation.gnv.geobackend.base.Result#getFloat(java.lang.String) */ public Float getFloat(String columnName) { return (Float)this.columnValues.get(columnName); } /** * @see de.intevation.gnv.geobackend.base.Result#getInteger(java.lang.String) */ public Integer getInteger(String columnName) { return (Integer)this.columnValues.get(columnName); } /** * @see de.intevation.gnv.geobackend.base.Result#getResultDescriptor() */ public ResultDescriptor getResultDescriptor() { return this.resultDescriptor; } /** * @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){ return DateUtils.getPatternedDateAmer((Date)o); }else if (o instanceof GregorianCalendar){ Date d = ((GregorianCalendar)o).getTime(); return DateUtils.getPatternedDateAmer(d); }else{ return this.columnValues.get(columnName).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); } /** * @see de.intevation.gnv.geobackend.base.Result#getObject(java.lang.String) */ public Object getObject(String columnName) { return this.columnValues.get(columnName); } }