Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/shared/model/IntegerProperty.java @ 5373:3f8e5dd2935c
Doc.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 22 Mar 2013 09:12:23 +0100 |
parents | c21d14e48040 |
children |
rev | line source |
---|---|
1461
83ed39d1083d
Added new classes for output setting types.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.shared.model; |
83ed39d1083d
Added new classes for output setting types.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 |
1503
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
3 import java.util.HashMap; |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
4 |
1461
83ed39d1083d
Added new classes for output setting types.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
5 /** |
83ed39d1083d
Added new classes for output setting types.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
83ed39d1083d
Added new classes for output setting types.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 */ |
83ed39d1083d
Added new classes for output setting types.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 public class IntegerProperty extends PropertySetting { |
83ed39d1083d
Added new classes for output setting types.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 |
1503
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
10 /** |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
11 * Create a new IntegerProperty for settings. |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
12 */ |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
13 public IntegerProperty() { |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
14 this.attributes = new HashMap<String, String>(); |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
15 } |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
16 |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
17 |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
18 /** |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
19 * Create a new IntegerProperty. |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
20 * @param name The attribute name. |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
21 * @param value The current value. |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
22 */ |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
23 public IntegerProperty( |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
24 String name, |
1507
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1503
diff
changeset
|
25 Integer value) |
1503
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
26 { |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
27 this.name = name; |
1507
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1503
diff
changeset
|
28 this.value = value.toString(); |
1503
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
29 this.attributes = new HashMap<String, String>(); |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
30 } |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
31 |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
32 |
1507
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1503
diff
changeset
|
33 @Override |
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1503
diff
changeset
|
34 public Integer getValue() { |
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1503
diff
changeset
|
35 try { |
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1503
diff
changeset
|
36 return Integer.valueOf(this.value); |
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1503
diff
changeset
|
37 } |
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1503
diff
changeset
|
38 catch(NumberFormatException nfe) { |
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1503
diff
changeset
|
39 return null; |
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1503
diff
changeset
|
40 } |
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1503
diff
changeset
|
41 } |
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1503
diff
changeset
|
42 |
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1503
diff
changeset
|
43 |
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1503
diff
changeset
|
44 public void setValue(Integer value) { |
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1503
diff
changeset
|
45 this.value = value.toString(); |
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1503
diff
changeset
|
46 } |
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1503
diff
changeset
|
47 |
1503
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
48 public Object clone() { |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
49 IntegerProperty clone = new IntegerProperty(this.getName(), |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
50 this.getValue()); |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
51 for(String s: this.getAttributeList()) { |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
52 clone.setAttribute(s, this.getAttribute(s)); |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
53 } |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
54 return clone; |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
55 } |
3304608baf35
Issue 433.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1461
diff
changeset
|
56 |
1461
83ed39d1083d
Added new classes for output setting types.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 } |