Mercurial > dive4elements > gnv-client
view geo-backend/src/main/java/de/intevation/gnv/geobackend/base/DefaultResult.java @ 1142:12abbf15f18a
dummy merge for repo head
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:15:20 +0200 |
parents | ebeb56428409 |
children |
line wrap: on
line source
/* * Copyright (c) 2010 by Intevation GmbH * * This program is free software under the LGPL (>=v2.1) * Read the file LGPL.txt coming with the software for details * or visit http://www.gnu.org/licenses/ if it does not exist. */ package de.intevation.gnv.geobackend.base; import java.util.Date; import java.util.GregorianCalendar; import de.intevation.gnv.geobackend.util.DateUtils; /** * Defaultimplementation of the Interface Result. * This Class stores the Attributevalues of one Result. * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> * */ public class DefaultResult implements Result { /** * THE UID of this Classe */ private static final long serialVersionUID = -6886218808840982766L; /** * Array which stores the Columnvalues */ 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)); } /** * @see de.intevation.gnv.geobackend.base.Result#getDate(int) */ 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)); } /** * @see de.intevation.gnv.geobackend.base.Result#getDouble(int) */ 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)); } /** * @see de.intevation.gnv.geobackend.base.Result#getFloat(int) */ 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; } /** * @see de.intevation.gnv.geobackend.base.Result#getInteger(int) */ 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; } /** * @see de.intevation.gnv.geobackend.base.Result#getString(int) */ 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(int, 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)); } /** * @see de.intevation.gnv.geobackend.base.Result#getObject(int) */ public Object getObject(int column) { return values[column]; } }