tim@132: /** tim@132: * tim@132: */ tim@132: package de.intevation.gnv.geobackend.base; tim@132: tim@132: import java.util.Date; tim@137: import java.util.GregorianCalendar; tim@132: import java.util.HashMap; tim@132: tim@140: import de.intevation.gnv.geobackend.util.DateUtils; tim@140: tim@132: /** tim@132: * Defaultimplementation of the Interface Result. tim@132: * This Class stores the Attributevalues of one Result. tim@132: * @author Tim Englich tim@132: * tim@132: */ sascha@270: public class DefaultResult sascha@270: implements Result sascha@270: { tim@132: /** tim@141: * THE UID of this Classe tim@141: */ tim@141: private static final long serialVersionUID = -6886218808840982766L; tim@141: tim@141: tim@141: /** tim@132: * HashMap which stores the Columnvalues identified by the unique Columnname tim@132: */ tim@271: tim@271: private Object [] values; tim@132: tim@132: /** tim@132: * The ResultDescriptor which describes the ColumnValues tim@132: */ tim@132: private ResultDescriptor resultDescriptor = null; tim@132: tim@132: /** tim@132: * Constructor tim@132: */ tim@132: public DefaultResult(ResultDescriptor resultDescriptor) { tim@132: this.resultDescriptor = resultDescriptor; tim@271: values = new Object[resultDescriptor.getColumnCount()]; tim@132: } tim@132: tim@132: /** tim@132: * @see de.intevation.gnv.geobackend.base.Result#getDate(java.lang.String) tim@132: */ tim@132: public Date getDate(String columnName) { tim@271: return getDate(resultDescriptor.getColumnIndex(columnName)); tim@271: } tim@271: tim@271: public Date getDate(int column) { tim@271: Object o = values[column]; tim@141: Date d = null; tim@137: if(o instanceof Date){ tim@141: d = (Date)o; tim@137: }else if (o instanceof GregorianCalendar){ tim@141: d = ((GregorianCalendar)o).getTime(); tim@137: } tim@141: return d; tim@132: } tim@132: tim@132: /** tim@132: * @see de.intevation.gnv.geobackend.base.Result#getDouble(java.lang.String) tim@132: */ tim@132: public Double getDouble(String columnName) { tim@271: return getDouble(resultDescriptor.getColumnIndex(columnName)); tim@271: } tim@271: tim@271: public Double getDouble(int column) { tim@271: return (Double)values[column]; tim@132: } tim@132: tim@132: /** tim@132: * @see de.intevation.gnv.geobackend.base.Result#getFloat(java.lang.String) tim@132: */ tim@132: public Float getFloat(String columnName) { tim@271: return getFloat(resultDescriptor.getColumnIndex(columnName)); tim@271: } tim@271: tim@271: public Float getFloat(int column) { tim@271: return (Float)values[column]; tim@132: } tim@132: tim@132: /** tim@132: * @see de.intevation.gnv.geobackend.base.Result#getInteger(java.lang.String) tim@132: */ tim@132: public Integer getInteger(String columnName) { tim@271: return getInteger(resultDescriptor.getColumnIndex(columnName)); tim@132: } tim@132: tim@271: public Integer getInteger(int column) { tim@271: return (Integer)values[column]; tim@271: } tim@132: /** tim@132: * @see de.intevation.gnv.geobackend.base.Result#getResultDescriptor() tim@132: */ tim@132: public ResultDescriptor getResultDescriptor() { tim@132: return this.resultDescriptor; tim@132: } tim@132: tim@132: /** tim@132: * @see de.intevation.gnv.geobackend.base.Result#getString(java.lang.String) tim@132: */ tim@132: public String getString(String columnName) { tim@271: return getString(resultDescriptor.getColumnIndex(columnName)); tim@271: } tim@271: tim@271: public String getString(int column) { tim@271: tim@271: Object o = values[column]; tim@271: sascha@270: if (o instanceof Date){ tim@140: return DateUtils.getPatternedDateAmer((Date)o); sascha@270: } sascha@270: sascha@270: if (o instanceof GregorianCalendar){ tim@140: Date d = ((GregorianCalendar)o).getTime(); tim@140: return DateUtils.getPatternedDateAmer(d); tim@140: } sascha@270: tim@271: return o != null ? o.toString() : null; tim@132: } tim@132: tim@132: /** tim@132: * @see de.intevation.gnv.geobackend.base.Result#addColumnValue(java.lang.String, java.lang.Object) tim@132: */ tim@271: public void addColumnValue(int column, Object value) { tim@271: values[column] = value; tim@132: } tim@132: tim@132: /** tim@132: * @see de.intevation.gnv.geobackend.base.Result#getObject(java.lang.String) tim@132: */ tim@132: public Object getObject(String columnName) { tim@271: return getObject(resultDescriptor.getColumnIndex(columnName)); tim@271: } tim@271: tim@271: public Object getObject(int column) { tim@271: return values[column]; tim@132: } tim@132: tim@132: }