comparison geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/Row.java @ 884:12f88239fb33

Updated Javadocs to the Listed Classes. Also done some Codecleanup and removed unused Methods from the Code. geo-backend/trunk@842 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Fri, 26 Mar 2010 15:23:03 +0000
parents 203f95af5b2c
children 8b442223741c
comparison
equal deleted inserted replaced
883:6d568397740c 884:12f88239fb33
1 /** 1 /**
2 * Title: Row, $Header: /share/gdi/SDI-Suite/Repository/projekte/BSH-GDI/genericViewer/src/main/java/de/conterra/bsh/gdi/gnviewer/datasources/Row.java,v 1.4 2008/01/30 12:38:34 blume Exp $
3 * Source: $Source: /share/gdi/SDI-Suite/Repository/projekte/BSH-GDI/genericViewer/src/main/java/de/conterra/bsh/gdi/gnviewer/datasources/Row.java,v $
4 * created by: Stefan Blume (blume)
5 * erstellt am: 21.11.2007
6 * Copyright: con terra GmbH, 2005
7 * 2 *
8 * modified by: $Author: blume $
9 * modified on: $Date: 2008/01/30 12:38:34 $
10 * Version: $Revision: 1.4 $
11 * TAG: $Name: $
12 * locked from: $Locker: $
13 * CVS State: $State: Exp $
14 * Project: $ProjectName$
15 */ 3 */
16 package de.intevation.gnv.geobackend.sde.datasources; 4 package de.intevation.gnv.geobackend.sde.datasources;
17 5
18 import java.util.ArrayList; 6 import java.util.ArrayList;
19 import java.util.Calendar; 7 import java.util.Calendar;
31 /** 19 /**
32 * A Row represents a set of values. 20 * A Row represents a set of values.
33 * In a technical manner (e.g. database manner) a row contains all attributes of a single "hit". 21 * In a technical manner (e.g. database manner) a row contains all attributes of a single "hit".
34 * 22 *
35 * @author blume 23 * @author blume
36 * @version 1.0 24 * @author Tim Englich <tim.englich@intevation.de>
37 * @serial 1.0
38 * @see
39 * @since 21.11.2007 11:00:54
40 */ 25 */
41 public class Row { 26 public class Row {
42 /** 27 /**
43 * Default Logging instance 28 * Default Logging instance
44 */ 29 */
49 */ 34 */
50 private Object[] mObjects; 35 private Object[] mObjects;
51 36
52 /** 37 /**
53 * Constructor. 38 * Constructor.
54 *
55 * @param pRowSize the number of attributes contained by this row. 39 * @param pRowSize the number of attributes contained by this row.
56 */ 40 */
57 public Row(int pRowSize) { 41 public Row(int pRowSize) {
58 mObjects = new Object[pRowSize]; 42 mObjects = new Object[pRowSize];
59 } 43 }
60 44
61 /** 45 /**
62 * Constructor. 46 * Constructor.
63 *
64 * @param ArrayStr a line from CSV-File. 47 * @param ArrayStr a line from CSV-File.
65 */ 48 */
66 public Row (String[] ArrayStr){ 49 public Row (String[] ArrayStr){
67 this (ArrayStr.length); 50 this (ArrayStr.length);
68 int nLength = ArrayStr.length; 51 int nLength = ArrayStr.length;
69 for (int i=0; i < nLength; i++){ 52 for (int i=0; i < nLength; i++){
70 addObject(ArrayStr[i], i); 53 addObject(ArrayStr[i], i);
71 54
72 } 55 }
73 56
74 } 57 }
75 58
76
77 /** 59 /**
78 * Adds an attribute value to a specific position of this row. 60 * Adds an attribute value to a specific position of this row.
79 * 61 *
80 * @param pObject the object to be stored. 62 * @param pObject the object to be stored.
81 * @param pPos the postion the value to be saved 63 * @param pPos the postion the value to be saved
103 } else { 85 } else {
104 throw new TechnicalException("Cannot access this field position. Size is: " + mObjects.length); 86 throw new TechnicalException("Cannot access this field position. Size is: " + mObjects.length);
105 } 87 }
106 } 88 }
107 89
108
109 /** 90 /**
110 * This is a covenient method for getting strongly typed objects out of the row. 91 * This is a covenient method for getting strongly typed objects out of the row.
111 * It has to be ensured, that the type of the requested row position has been resolved out of the ColumnDefinition ({@link ResultSet#getColumnDefinitions()}). 92 * It has to be ensured, that the type of the requested row position has been resolved out of the ColumnDefinition ({@link ResultSet#getColumnDefinitions()}).
112 * In fact, this method executes a simple cast to the desired type. 93 * In fact, this method executes a simple cast to the desired type.
113 * 94 *
115 * @return a strongly typed Date 96 * @return a strongly typed Date
116 * @throws TechnicalException 97 * @throws TechnicalException
117 * @see #getValue(int) 98 * @see #getValue(int)
118 */ 99 */
119 public Date getDateValue(int pPos) throws TechnicalException { 100 public Date getDateValue(int pPos) throws TechnicalException {
120 Date date = null; 101 Date date = null;
121 try { 102 try {
122 Calendar lCalendar = (Calendar) getValue(pPos); 103 Calendar lCalendar = (Calendar) getValue(pPos);
123 date = lCalendar.getTime(); 104 date = lCalendar.getTime();
124 } 105 }
125 catch (ClassCastException e) { 106 catch (ClassCastException e) {
126 try{ 107 try{
127 //SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); 108 //SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss");
128 date = DateUtils.getDateFromString ((String)getValue(pPos)); //(Date)formatter.parse((String)getValue(pPos)); 109 date = DateUtils.getDateFromString ((String)getValue(pPos)); //(Date)formatter.parse((String)getValue(pPos));
129 110
130 111
131 } 112 }
132 catch (Exception ex){ 113 catch (Exception ex){
133 sLogger.error(getValue(pPos) + " " + ex.getMessage(), ex); 114 sLogger.error(getValue(pPos) + " " + ex.getMessage(), ex);
134 throw new TechnicalException("Could not cast this value to the Date Type. Object is of value type: " + getValue(pPos).getClass().getName()); 115 throw new TechnicalException("Could not cast this value to the Date Type. Object is of value type: " + getValue(pPos).getClass().getName());
135 } 116 }
136 } 117 }
137 118
138 return date; 119 return date;
139 } 120 }
140 121
141 /** 122 /**
193 */ 174 */
194 public Double getDoubleValue(int pPos) throws TechnicalException { 175 public Double getDoubleValue(int pPos) throws TechnicalException {
195 try { 176 try {
196 return (Double) getValue(pPos); 177 return (Double) getValue(pPos);
197 } catch (ClassCastException e) { 178 } catch (ClassCastException e) {
198 try{ 179 try{
199 return new Double ((String)getValue(pPos)); 180 return new Double ((String)getValue(pPos));
200 } 181 }
201 catch(Exception ex){ 182 catch(Exception ex){
202 sLogger.error(getValue(pPos) + " " + ex.getMessage(), ex); 183 sLogger.error(getValue(pPos) + " " + ex.getMessage(), ex);
203 throw new TechnicalException("Could not cast this value to the Double Type. Object is of value type: " + getValue(pPos).getClass().getName()); 184 throw new TechnicalException("Could not cast this value to the Double Type. Object is of value type: " + getValue(pPos).getClass().getName());
204 } 185 }
205 } 186 }
206 } 187 }
207 188
208 /** 189 /**
209 * This is a covenient method for getting strongly typed objects out of the row. 190 * This is a covenient method for getting strongly typed objects out of the row.
265 returnValue.append("MULTILINESTRING(("); 246 returnValue.append("MULTILINESTRING((");
266 nextOffset = offsets.length-1 >= offsetPos ? offsets[offsetPos++] : length; 247 nextOffset = offsets.length-1 >= offsetPos ? offsets[offsetPos++] : length;
267 }else{ 248 }else{
268 returnValue.append("LINESTRING("); 249 returnValue.append("LINESTRING(");
269 } 250 }
270
271
272 251
273 for (int i = 0; i< length;i++){ 252 for (int i = 0; i< length;i++){
274 253
275 if (i == nextOffset){ 254 if (i == nextOffset){
276 returnValue.append("),("); 255 returnValue.append("),(");
285 } 264 }
286 if (i < length-1 && i < nextOffset -1){ 265 if (i < length-1 && i < nextOffset -1){
287 returnValue.append(" , "); 266 returnValue.append(" , ");
288 } 267 }
289 } 268 }
290 269
291 if(isMultiLineString){ 270 if(isMultiLineString){
292 returnValue.append("))"); 271 returnValue.append("))");
293 }else{ 272 }else{
294 returnValue.append(")"); 273 returnValue.append(")");
295 } 274 }

http://dive4elements.wald.intevation.org