Mercurial > dive4elements > gnv-client
comparison geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/Row.java @ 897:02cd2935b5fa
Removed trailing whitespace.
geo-backend/trunk@1013 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 28 Apr 2010 07:04:19 +0000 |
parents | d674cef2ca0d |
children | ebeb56428409 |
comparison
equal
deleted
inserted
replaced
896:c7756576044f | 897:02cd2935b5fa |
---|---|
47 public Row (String[] ArrayStr){ | 47 public Row (String[] ArrayStr){ |
48 this (ArrayStr.length); | 48 this (ArrayStr.length); |
49 int nLength = ArrayStr.length; | 49 int nLength = ArrayStr.length; |
50 for (int i=0; i < nLength; i++){ | 50 for (int i=0; i < nLength; i++){ |
51 addObject(ArrayStr[i], i); | 51 addObject(ArrayStr[i], i); |
52 | 52 |
53 } | 53 } |
54 | 54 |
55 } | 55 } |
56 | 56 |
57 /** | 57 /** |
58 * Adds an attribute value to a specific position of this row. | 58 * Adds an attribute value to a specific position of this row. |
59 * | 59 * |
71 * @return an Object! (not strongly typed) | 71 * @return an Object! (not strongly typed) |
72 * @throws TechnicalException | 72 * @throws TechnicalException |
73 */ | 73 */ |
74 public Object getValue(int pPos) throws TechnicalException { | 74 public Object getValue(int pPos) throws TechnicalException { |
75 if (pPos < mObjects.length) { | 75 if (pPos < mObjects.length) { |
76 | 76 |
77 Object o = mObjects[pPos]; | 77 Object o = mObjects[pPos]; |
78 if (o instanceof SeShape){ | 78 if (o instanceof SeShape){ |
79 return this.getPosValue(pPos); | 79 return this.getPosValue(pPos); |
80 }else{ | 80 }else{ |
81 return o; | 81 return o; |
98 public Date getDateValue(int pPos) throws TechnicalException { | 98 public Date getDateValue(int pPos) throws TechnicalException { |
99 Date date = null; | 99 Date date = null; |
100 try { | 100 try { |
101 Calendar lCalendar = (Calendar) getValue(pPos); | 101 Calendar lCalendar = (Calendar) getValue(pPos); |
102 date = lCalendar.getTime(); | 102 date = lCalendar.getTime(); |
103 } | 103 } |
104 catch (ClassCastException e) { | 104 catch (ClassCastException e) { |
105 try{ | 105 try{ |
106 //SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); | 106 //SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); |
107 date = DateUtils.getDateFromString ((String)getValue(pPos)); //(Date)formatter.parse((String)getValue(pPos)); | 107 date = DateUtils.getDateFromString ((String)getValue(pPos)); //(Date)formatter.parse((String)getValue(pPos)); |
108 | 108 |
109 | 109 |
110 } | 110 } |
111 catch (Exception ex){ | 111 catch (Exception ex){ |
112 sLogger.error(getValue(pPos) + " " + ex.getMessage(), ex); | 112 sLogger.error(getValue(pPos) + " " + ex.getMessage(), ex); |
113 throw new TechnicalException("Could not cast this value to the Date Type. Object is of value type: " + getValue(pPos).getClass().getName()); | 113 throw new TechnicalException("Could not cast this value to the Date Type. Object is of value type: " + getValue(pPos).getClass().getName()); |
114 } | 114 } |
115 } | 115 } |
116 | 116 |
117 return date; | 117 return date; |
118 } | 118 } |
119 | 119 |
120 /** | 120 /** |
121 * This is a covenient method for getting strongly typed objects out of the row. | 121 * This is a covenient method for getting strongly typed objects out of the row. |
208 * | 208 * |
209 * @param pPos the position of the object to be resolved. | 209 * @param pPos the position of the object to be resolved. |
210 * @return a strongly typed Float | 210 * @return a strongly typed Float |
211 * @throws TechnicalException | 211 * @throws TechnicalException |
212 * @see #getValue(int) | 212 * @see #getValue(int) |
213 */ | 213 */ |
214 public String getPosValue(int pPos)throws TechnicalException{ | 214 public String getPosValue(int pPos)throws TechnicalException{ |
215 StringBuffer returnValue = new StringBuffer(); | 215 StringBuffer returnValue = new StringBuffer(); |
216 synchronized (returnValue) { | 216 synchronized (returnValue) { |
217 try { | 217 try { |
218 SeShape val = (SeShape) this.mObjects[pPos]; | 218 SeShape val = (SeShape) this.mObjects[pPos]; |
219 if (val.isPoint()){ | 219 if (val.isPoint()){ |
220 // Cannot use val.asText() because the | 220 // Cannot use val.asText() because the |
221 // generated WKT is invalid. | 221 // generated WKT is invalid. |
222 ArrayList aList = val.getAllPoints(0,false); | 222 ArrayList aList = val.getAllPoints(0,false); |
223 SDEPoint[] mPoint = (SDEPoint[])aList.get(0); | 223 SDEPoint[] mPoint = (SDEPoint[])aList.get(0); |
224 returnValue.append("POINT(") | 224 returnValue.append("POINT(") |
225 .append(mPoint[0].getX()) | 225 .append(mPoint[0].getX()) |
228 if (mPoint[0].is3D()){ | 228 if (mPoint[0].is3D()){ |
229 returnValue.append(" ").append(mPoint[0].getZ()); | 229 returnValue.append(" ").append(mPoint[0].getZ()); |
230 } | 230 } |
231 returnValue.append(")"); | 231 returnValue.append(")"); |
232 }else if (val.isLine() || val.isSimpleLine()){ | 232 }else if (val.isLine() || val.isSimpleLine()){ |
233 // Cannot use val.asText() because the | 233 // Cannot use val.asText() because the |
234 // generated WKT is invalid. | 234 // generated WKT is invalid. |
235 ArrayList aList = val.getAllPoints(0,false); | 235 ArrayList aList = val.getAllPoints(0,false); |
236 SDEPoint[] mPoint = (SDEPoint[])aList.get(0); | 236 SDEPoint[] mPoint = (SDEPoint[])aList.get(0); |
237 boolean isMultiLineString = val.isMultiPart(); | 237 boolean isMultiLineString = val.isMultiPart(); |
238 int length = mPoint.length; | 238 int length = mPoint.length; |
239 int nextOffset = length; | 239 int nextOffset = length; |
240 int[] offsets = (int[])aList.get(1); | 240 int[] offsets = (int[])aList.get(1); |
241 int offsetPos = 1; | 241 int offsetPos = 1; |
242 | 242 |
243 if(isMultiLineString){ | 243 if(isMultiLineString){ |
244 returnValue.append("MULTILINESTRING(("); | 244 returnValue.append("MULTILINESTRING(("); |
245 nextOffset = offsets.length-1 >= offsetPos ? offsets[offsetPos++] : length; | 245 nextOffset = offsets.length-1 >= offsetPos ? offsets[offsetPos++] : length; |
246 }else{ | 246 }else{ |
247 returnValue.append("LINESTRING("); | 247 returnValue.append("LINESTRING("); |
248 } | 248 } |
249 | 249 |
250 for (int i = 0; i< length;i++){ | 250 for (int i = 0; i< length;i++){ |
251 | 251 |
252 if (i == nextOffset){ | 252 if (i == nextOffset){ |
253 returnValue.append("),("); | 253 returnValue.append("),("); |
254 nextOffset = offsets.length-1 >= offsetPos ? offsets[offsetPos++] : length; | 254 nextOffset = offsets.length-1 >= offsetPos ? offsets[offsetPos++] : length; |
255 } | 255 } |
256 | 256 |
257 returnValue.append(mPoint[i].getX()) | 257 returnValue.append(mPoint[i].getX()) |
258 .append(" ") | 258 .append(" ") |
259 .append(mPoint[i].getY()); | 259 .append(mPoint[i].getY()); |
260 if (mPoint[i].is3D()){ | 260 if (mPoint[i].is3D()){ |
261 returnValue.append(" ").append(mPoint[i].getZ()); | 261 returnValue.append(" ").append(mPoint[i].getZ()); |
268 if(isMultiLineString){ | 268 if(isMultiLineString){ |
269 returnValue.append("))"); | 269 returnValue.append("))"); |
270 }else{ | 270 }else{ |
271 returnValue.append(")"); | 271 returnValue.append(")"); |
272 } | 272 } |
273 | 273 |
274 } else{ | 274 } else{ |
275 returnValue.append(val.asText(val.getTextSize())); | 275 returnValue.append(val.asText(val.getTextSize())); |
276 } | 276 } |
277 } catch (SeException e) { | 277 } catch (SeException e) { |
278 throw new TechnicalException("Could not cast this value to the " + | 278 throw new TechnicalException("Could not cast this value to the " + |
279 "Float Type. Object is of value " + | 279 "Float Type. Object is of value " + |
280 "type: " + | 280 "type: " + |
281 getValue(pPos).getClass().getName()); | 281 getValue(pPos).getClass().getName()); |
282 } | 282 } |
283 } | 283 } |
284 return returnValue.toString(); | 284 return returnValue.toString(); |
285 } | 285 } |