Mercurial > dive4elements > gnv-client
comparison geo-backend/src/main/java/de/intevation/gnv/geobackend/base/DefaultResult.java @ 271:8aad9d098b08
Integrated Patch of issue57 to get some Memoryusage-improvements
geo-backend/trunk@248 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Tue, 20 Oct 2009 09:57:52 +0000 |
parents | 1fe93e3c80c0 |
children | 05912f0304ac |
comparison
equal
deleted
inserted
replaced
270:1fe93e3c80c0 | 271:8aad9d098b08 |
---|---|
14 * This Class stores the Attributevalues of one Result. | 14 * This Class stores the Attributevalues of one Result. |
15 * @author Tim Englich <tim.englich@intevation.de> | 15 * @author Tim Englich <tim.englich@intevation.de> |
16 * | 16 * |
17 */ | 17 */ |
18 public class DefaultResult | 18 public class DefaultResult |
19 extends HashMap<String, Object> | |
20 implements Result | 19 implements Result |
21 { | 20 { |
22 /** | 21 /** |
23 * THE UID of this Classe | 22 * THE UID of this Classe |
24 */ | 23 */ |
26 | 25 |
27 | 26 |
28 /** | 27 /** |
29 * HashMap which stores the Columnvalues identified by the unique Columnname | 28 * HashMap which stores the Columnvalues identified by the unique Columnname |
30 */ | 29 */ |
30 | |
31 private Object [] values; | |
31 | 32 |
32 /** | 33 /** |
33 * The ResultDescriptor which describes the ColumnValues | 34 * The ResultDescriptor which describes the ColumnValues |
34 */ | 35 */ |
35 private ResultDescriptor resultDescriptor = null; | 36 private ResultDescriptor resultDescriptor = null; |
36 | 37 |
37 /** | 38 /** |
38 * Constructor | 39 * Constructor |
39 */ | 40 */ |
40 public DefaultResult(ResultDescriptor resultDescriptor) { | 41 public DefaultResult(ResultDescriptor resultDescriptor) { |
41 super(); | |
42 this.resultDescriptor = resultDescriptor; | 42 this.resultDescriptor = resultDescriptor; |
43 values = new Object[resultDescriptor.getColumnCount()]; | |
43 } | 44 } |
44 | 45 |
45 /** | 46 /** |
46 * @see de.intevation.gnv.geobackend.base.Result#getDate(java.lang.String) | 47 * @see de.intevation.gnv.geobackend.base.Result#getDate(java.lang.String) |
47 */ | 48 */ |
48 public Date getDate(String columnName) { | 49 public Date getDate(String columnName) { |
49 Object o = get(columnName); | 50 return getDate(resultDescriptor.getColumnIndex(columnName)); |
51 } | |
52 | |
53 public Date getDate(int column) { | |
54 Object o = values[column]; | |
50 Date d = null; | 55 Date d = null; |
51 if(o instanceof Date){ | 56 if(o instanceof Date){ |
52 d = (Date)o; | 57 d = (Date)o; |
53 }else if (o instanceof GregorianCalendar){ | 58 }else if (o instanceof GregorianCalendar){ |
54 d = ((GregorianCalendar)o).getTime(); | 59 d = ((GregorianCalendar)o).getTime(); |
58 | 63 |
59 /** | 64 /** |
60 * @see de.intevation.gnv.geobackend.base.Result#getDouble(java.lang.String) | 65 * @see de.intevation.gnv.geobackend.base.Result#getDouble(java.lang.String) |
61 */ | 66 */ |
62 public Double getDouble(String columnName) { | 67 public Double getDouble(String columnName) { |
63 return (Double)get(columnName); | 68 return getDouble(resultDescriptor.getColumnIndex(columnName)); |
69 } | |
70 | |
71 public Double getDouble(int column) { | |
72 return (Double)values[column]; | |
64 } | 73 } |
65 | 74 |
66 /** | 75 /** |
67 * @see de.intevation.gnv.geobackend.base.Result#getFloat(java.lang.String) | 76 * @see de.intevation.gnv.geobackend.base.Result#getFloat(java.lang.String) |
68 */ | 77 */ |
69 public Float getFloat(String columnName) { | 78 public Float getFloat(String columnName) { |
70 return (Float)get(columnName); | 79 return getFloat(resultDescriptor.getColumnIndex(columnName)); |
80 } | |
81 | |
82 public Float getFloat(int column) { | |
83 return (Float)values[column]; | |
71 } | 84 } |
72 | 85 |
73 /** | 86 /** |
74 * @see de.intevation.gnv.geobackend.base.Result#getInteger(java.lang.String) | 87 * @see de.intevation.gnv.geobackend.base.Result#getInteger(java.lang.String) |
75 */ | 88 */ |
76 public Integer getInteger(String columnName) { | 89 public Integer getInteger(String columnName) { |
77 return (Integer)get(columnName); | 90 return getInteger(resultDescriptor.getColumnIndex(columnName)); |
78 } | 91 } |
79 | 92 |
93 public Integer getInteger(int column) { | |
94 return (Integer)values[column]; | |
95 } | |
80 /** | 96 /** |
81 * @see de.intevation.gnv.geobackend.base.Result#getResultDescriptor() | 97 * @see de.intevation.gnv.geobackend.base.Result#getResultDescriptor() |
82 */ | 98 */ |
83 public ResultDescriptor getResultDescriptor() { | 99 public ResultDescriptor getResultDescriptor() { |
84 return this.resultDescriptor; | 100 return this.resultDescriptor; |
86 | 102 |
87 /** | 103 /** |
88 * @see de.intevation.gnv.geobackend.base.Result#getString(java.lang.String) | 104 * @see de.intevation.gnv.geobackend.base.Result#getString(java.lang.String) |
89 */ | 105 */ |
90 public String getString(String columnName) { | 106 public String getString(String columnName) { |
91 Object o = get(columnName); | 107 return getString(resultDescriptor.getColumnIndex(columnName)); |
108 } | |
109 | |
110 public String getString(int column) { | |
111 | |
112 Object o = values[column]; | |
113 | |
92 if (o instanceof Date){ | 114 if (o instanceof Date){ |
93 return DateUtils.getPatternedDateAmer((Date)o); | 115 return DateUtils.getPatternedDateAmer((Date)o); |
94 } | 116 } |
95 | 117 |
96 if (o instanceof GregorianCalendar){ | 118 if (o instanceof GregorianCalendar){ |
97 Date d = ((GregorianCalendar)o).getTime(); | 119 Date d = ((GregorianCalendar)o).getTime(); |
98 return DateUtils.getPatternedDateAmer(d); | 120 return DateUtils.getPatternedDateAmer(d); |
99 } | 121 } |
100 | 122 |
101 return o != null ? o.toString() : ""; | 123 return o != null ? o.toString() : null; |
102 } | 124 } |
103 | 125 |
104 /** | 126 /** |
105 * @see de.intevation.gnv.geobackend.base.Result#addColumnValue(java.lang.String, java.lang.Object) | 127 * @see de.intevation.gnv.geobackend.base.Result#addColumnValue(java.lang.String, java.lang.Object) |
106 */ | 128 */ |
107 public void addColumnValue(String columnName, Object value) { | 129 public void addColumnValue(int column, Object value) { |
108 put(columnName, value); | 130 values[column] = value; |
109 } | 131 } |
110 | 132 |
111 /** | 133 /** |
112 * @see de.intevation.gnv.geobackend.base.Result#getObject(java.lang.String) | 134 * @see de.intevation.gnv.geobackend.base.Result#getObject(java.lang.String) |
113 */ | 135 */ |
114 public Object getObject(String columnName) { | 136 public Object getObject(String columnName) { |
115 return get(columnName); | 137 return getObject(resultDescriptor.getColumnIndex(columnName)); |
138 } | |
139 | |
140 public Object getObject(int column) { | |
141 return values[column]; | |
116 } | 142 } |
117 | 143 |
118 } | 144 } |