annotate geo-backend/src/main/java/de/intevation/gnv/geobackend/base/DefaultResult.java @ 141:b02310d7ffee

Make Classes Serializable for Storing in ArtifactDatabase geo-backend/trunk@131 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Thu, 24 Sep 2009 15:24:11 +0000
parents 2f1b87e1a40c
children 1fe93e3c80c0
rev   line source
132
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 /**
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2 *
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
3 */
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
4 package de.intevation.gnv.geobackend.base;
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
5
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
6 import java.util.Date;
137
d43ff60acda4 Some little performanceimprofments and Bugfixes
Tim Englich <tim.englich@intevation.de>
parents: 132
diff changeset
7 import java.util.GregorianCalendar;
132
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
8 import java.util.HashMap;
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9
140
2f1b87e1a40c Added formatted Date Handling in getString Method
Tim Englich <tim.englich@intevation.de>
parents: 137
diff changeset
10 import de.intevation.gnv.geobackend.util.DateUtils;
2f1b87e1a40c Added formatted Date Handling in getString Method
Tim Englich <tim.englich@intevation.de>
parents: 137
diff changeset
11
132
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
12 /**
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
13 * Defaultimplementation of the Interface Result.
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
14 * This Class stores the Attributevalues of one Result.
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
15 * @author Tim Englich <tim.englich@intevation.de>
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
16 *
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
17 */
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18 public class DefaultResult implements Result {
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20 /**
141
b02310d7ffee Make Classes Serializable for Storing in ArtifactDatabase
Tim Englich <tim.englich@intevation.de>
parents: 140
diff changeset
21 * THE UID of this Classe
b02310d7ffee Make Classes Serializable for Storing in ArtifactDatabase
Tim Englich <tim.englich@intevation.de>
parents: 140
diff changeset
22 */
b02310d7ffee Make Classes Serializable for Storing in ArtifactDatabase
Tim Englich <tim.englich@intevation.de>
parents: 140
diff changeset
23 private static final long serialVersionUID = -6886218808840982766L;
b02310d7ffee Make Classes Serializable for Storing in ArtifactDatabase
Tim Englich <tim.englich@intevation.de>
parents: 140
diff changeset
24
b02310d7ffee Make Classes Serializable for Storing in ArtifactDatabase
Tim Englich <tim.englich@intevation.de>
parents: 140
diff changeset
25
b02310d7ffee Make Classes Serializable for Storing in ArtifactDatabase
Tim Englich <tim.englich@intevation.de>
parents: 140
diff changeset
26 /**
132
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27 * HashMap which stores the Columnvalues identified by the unique Columnname
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28 */
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29 private HashMap<String, Object> columnValues = new HashMap<String, Object>();
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 /**
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 * The ResultDescriptor which describes the ColumnValues
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 */
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 private ResultDescriptor resultDescriptor = null;
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
36
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
37 /**
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38 * Constructor
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 */
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40 public DefaultResult(ResultDescriptor resultDescriptor) {
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41 super();
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
42 this.resultDescriptor = resultDescriptor;
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 }
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
45 /**
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
46 * @see de.intevation.gnv.geobackend.base.Result#getDate(java.lang.String)
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47 */
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 public Date getDate(String columnName) {
137
d43ff60acda4 Some little performanceimprofments and Bugfixes
Tim Englich <tim.englich@intevation.de>
parents: 132
diff changeset
49 Object o = this.columnValues.get(columnName);
141
b02310d7ffee Make Classes Serializable for Storing in ArtifactDatabase
Tim Englich <tim.englich@intevation.de>
parents: 140
diff changeset
50 Date d = null;
137
d43ff60acda4 Some little performanceimprofments and Bugfixes
Tim Englich <tim.englich@intevation.de>
parents: 132
diff changeset
51 if(o instanceof Date){
141
b02310d7ffee Make Classes Serializable for Storing in ArtifactDatabase
Tim Englich <tim.englich@intevation.de>
parents: 140
diff changeset
52 d = (Date)o;
137
d43ff60acda4 Some little performanceimprofments and Bugfixes
Tim Englich <tim.englich@intevation.de>
parents: 132
diff changeset
53 }else if (o instanceof GregorianCalendar){
141
b02310d7ffee Make Classes Serializable for Storing in ArtifactDatabase
Tim Englich <tim.englich@intevation.de>
parents: 140
diff changeset
54 d = ((GregorianCalendar)o).getTime();
137
d43ff60acda4 Some little performanceimprofments and Bugfixes
Tim Englich <tim.englich@intevation.de>
parents: 132
diff changeset
55 }
141
b02310d7ffee Make Classes Serializable for Storing in ArtifactDatabase
Tim Englich <tim.englich@intevation.de>
parents: 140
diff changeset
56 return d;
132
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
57 }
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
58
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
59 /**
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
60 * @see de.intevation.gnv.geobackend.base.Result#getDouble(java.lang.String)
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
61 */
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
62 public Double getDouble(String columnName) {
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
63 return (Double)this.columnValues.get(columnName);
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
64 }
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
65
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
66 /**
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
67 * @see de.intevation.gnv.geobackend.base.Result#getFloat(java.lang.String)
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
68 */
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
69 public Float getFloat(String columnName) {
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
70 return (Float)this.columnValues.get(columnName);
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
71 }
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
72
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
73 /**
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
74 * @see de.intevation.gnv.geobackend.base.Result#getInteger(java.lang.String)
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
75 */
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
76 public Integer getInteger(String columnName) {
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
77 return (Integer)this.columnValues.get(columnName);
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
78 }
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
79
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
80 /**
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
81 * @see de.intevation.gnv.geobackend.base.Result#getResultDescriptor()
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
82 */
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
83 public ResultDescriptor getResultDescriptor() {
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
84 return this.resultDescriptor;
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
85 }
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
86
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
87 /**
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
88 * @see de.intevation.gnv.geobackend.base.Result#getString(java.lang.String)
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
89 */
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
90 public String getString(String columnName) {
140
2f1b87e1a40c Added formatted Date Handling in getString Method
Tim Englich <tim.englich@intevation.de>
parents: 137
diff changeset
91 Object o = this.columnValues.get(columnName);
2f1b87e1a40c Added formatted Date Handling in getString Method
Tim Englich <tim.englich@intevation.de>
parents: 137
diff changeset
92 if(o instanceof Date){
2f1b87e1a40c Added formatted Date Handling in getString Method
Tim Englich <tim.englich@intevation.de>
parents: 137
diff changeset
93 return DateUtils.getPatternedDateAmer((Date)o);
2f1b87e1a40c Added formatted Date Handling in getString Method
Tim Englich <tim.englich@intevation.de>
parents: 137
diff changeset
94 }else if (o instanceof GregorianCalendar){
2f1b87e1a40c Added formatted Date Handling in getString Method
Tim Englich <tim.englich@intevation.de>
parents: 137
diff changeset
95 Date d = ((GregorianCalendar)o).getTime();
2f1b87e1a40c Added formatted Date Handling in getString Method
Tim Englich <tim.englich@intevation.de>
parents: 137
diff changeset
96 return DateUtils.getPatternedDateAmer(d);
2f1b87e1a40c Added formatted Date Handling in getString Method
Tim Englich <tim.englich@intevation.de>
parents: 137
diff changeset
97 }else{
2f1b87e1a40c Added formatted Date Handling in getString Method
Tim Englich <tim.englich@intevation.de>
parents: 137
diff changeset
98 return this.columnValues.get(columnName).toString();
2f1b87e1a40c Added formatted Date Handling in getString Method
Tim Englich <tim.englich@intevation.de>
parents: 137
diff changeset
99 }
132
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
100 }
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
101
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
102 /**
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
103 * @see de.intevation.gnv.geobackend.base.Result#addColumnValue(java.lang.String, java.lang.Object)
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
104 */
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
105 public void addColumnValue(String columnName, Object value) {
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
106 this.columnValues.put(columnName, value);
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
107 }
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
108
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
109 /**
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
110 * @see de.intevation.gnv.geobackend.base.Result#getObject(java.lang.String)
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
111 */
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
112 public Object getObject(String columnName) {
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
113 return this.columnValues.get(columnName);
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
114 }
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
115
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
116 }

http://dive4elements.wald.intevation.org