Mercurial > dive4elements > gnv-client
view geo-backend/src/main/java/de/intevation/gnv/geobackend/base/DefaultResult.java @ 543:fac02bf1c685
Added Rasterdatasupport to the ARCSDE-Statement
geo-backend/trunk@504 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Mon, 04 Jan 2010 15:22:09 +0000 |
parents | da2da7bb1aa1 |
children | 12f88239fb33 |
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 Object [] values; /** * The ResultDescriptor which describes the ColumnValues */ private ResultDescriptor resultDescriptor = null; /** * Constructor */ public DefaultResult(ResultDescriptor resultDescriptor) { this.resultDescriptor = resultDescriptor; values = new Object[resultDescriptor.getColumnCount()]; } /** * @see de.intevation.gnv.geobackend.base.Result#getDate(java.lang.String) */ public Date getDate(String columnName) { return getDate(resultDescriptor.getColumnIndex(columnName)); } public Date getDate(int column) { Object o = values[column]; 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 getDouble(resultDescriptor.getColumnIndex(columnName)); } public Double getDouble(int column) { return (Double)values[column]; } /** * @see de.intevation.gnv.geobackend.base.Result#getFloat(java.lang.String) */ public Float getFloat(String columnName) { return getFloat(resultDescriptor.getColumnIndex(columnName)); } public Float getFloat(int column) { return (Float)values[column]; } /** * @see de.intevation.gnv.geobackend.base.Result#getInteger(java.lang.String) */ public Integer getInteger(String columnName) { int idx = resultDescriptor.getColumnIndex(columnName); return idx > -1 ? getInteger(idx) : -1; //return getInteger(resultDescriptor.getColumnIndex(columnName)); } public Integer getInteger(int column) { Object value = values[column]; if (value instanceof Double){ value = new Integer(((Double)value).intValue()); } return (Integer)value; } /** * @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) { int idx = resultDescriptor.getColumnIndex(columnName); return idx > -1 ? getString(idx) : null; } public String getString(int column) { Object o = values[column]; if (o instanceof Date){ return DateUtils.getPatternedDateAmer((Date)o); } if (o instanceof GregorianCalendar){ Date d = ((GregorianCalendar)o).getTime(); return DateUtils.getPatternedDateAmer(d); } return o != null ? o.toString() : null; } /** * @see de.intevation.gnv.geobackend.base.Result#addColumnValue(java.lang.String, java.lang.Object) */ public void addColumnValue(int column, Object value) { values[column] = value; } /** * @see de.intevation.gnv.geobackend.base.Result#getObject(java.lang.String) */ public Object getObject(String columnName) { return getObject(resultDescriptor.getColumnIndex(columnName)); } public Object getObject(int column) { return values[column]; } }