comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultInputData.java @ 796:a5526908f92f

Added javadoc in state package. gnv-artifacts/trunk@878 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 01 Apr 2010 09:15:36 +0000
parents e764cab8c885
children feae2f9d6c6f
comparison
equal deleted inserted replaced
795:cdade5005cba 796:a5526908f92f
4 import java.util.Map; 4 import java.util.Map;
5 5
6 import org.apache.log4j.Logger; 6 import org.apache.log4j.Logger;
7 7
8 /** 8 /**
9 * The default implementation of <code>InputData</code>. This object stores
10 * multiple values separated by {@link #VALUE_SEPARATOR} for a specific key.
11 *
9 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> 12 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
10 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> 13 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
11 */ 14 */
12 public class DefaultInputData implements InputData { 15 public class DefaultInputData implements InputData {
13 16
16 */ 19 */
17 private static final long serialVersionUID = 4308041648698108066L; 20 private static final long serialVersionUID = 4308041648698108066L;
18 21
19 private static final Logger logger = Logger.getLogger(DefaultInputData.class); 22 private static final Logger logger = Logger.getLogger(DefaultInputData.class);
20 23
24 /**
25 * The character used to separate the different values.
26 */
21 public final static String VALUE_SEPARATOR = " , "; 27 public final static String VALUE_SEPARATOR = " , ";
22 28
29 /**
30 * The key/name of this object.
31 */
23 protected String name; 32 protected String name;
33
34 /**
35 * Values separated by {@link #VALUE_SEPARATOR}.
36 */
24 protected String value; 37 protected String value;
38
39 /**
40 * Descriptions for values used for user interface creation. Each value
41 * should have an own description in this map.
42 */
25 protected Map description; 43 protected Map description;
44
45 /**
46 * An extra object. Might be everything.
47 */
26 protected Object object; 48 protected Object object;
27 49
28 50
29 /** 51 /**
30 * Constructor 52 * Constructor
53 * @param name
54 * @param value
31 */ 55 */
32 public DefaultInputData(String name, String value) { 56 public DefaultInputData(String name, String value) {
33 this.name = name; 57 this.name = name;
34 this.value = value; 58 this.value = value;
35 } 59 }
36 60
61 /**
62 *
63 * @param name
64 * @param object
65 */
37 public DefaultInputData(String name, Object object) { 66 public DefaultInputData(String name, Object object) {
38 this.name = name; 67 this.name = name;
39 this.object = object; 68 this.object = object;
40 } 69 }
41 70
71 /**
72 *
73 * @param name
74 * @param value
75 * @param object
76 */
42 public DefaultInputData( 77 public DefaultInputData(
43 String name, 78 String name,
44 String value, 79 String value,
45 Object object) 80 Object object)
46 { 81 {
48 this.object = object; 83 this.object = object;
49 this.value = value; 84 this.value = value;
50 } 85 }
51 86
52 /** 87 /**
53 * @see de.intevation.gnv.state.InputData#getName() 88 * @return
54 */ 89 */
55 public String getName() { 90 public String getName() {
56 return this.name; 91 return this.name;
57 } 92 }
58 93
59 /** 94 /**
60 * @see de.intevation.gnv.state.InputData#getValue() 95 * @return
61 */ 96 */
62 public String getValue() { 97 public String getValue() {
63 return this.value; 98 return this.value;
64 } 99 }
65 100
101 /**
102 *
103 * @param object
104 */
66 public void setObject(Object object) { 105 public void setObject(Object object) {
67 this.object = object; 106 this.object = object;
68 } 107 }
69 108
109 /**
110 *
111 * @return
112 */
70 public Object getObject() { 113 public Object getObject() {
71 return object; 114 return object;
72 } 115 }
73 116
117 /**
118 *
119 * @param key Key needs to be a single value of {@link #value}.
120 * @return the description.
121 */
74 public String getDescription(String key) { 122 public String getDescription(String key) {
75 if (description == null) 123 if (description == null)
76 return null; 124 return null;
77 125
78 return (String) description.get(key); 126 return (String) description.get(key);
79 } 127 }
80 128
129 /**
130 * Return all descriptions as array.
131 *
132 * @return descriptions as array.
133 */
81 public String[] getDescription() { 134 public String[] getDescription() {
82 String[] values = splitValue(); 135 String[] values = splitValue();
83 int length = values.length; 136 int length = values.length;
84 137
85 String[] description = new String[length]; 138 String[] description = new String[length];
88 } 141 }
89 142
90 return description; 143 return description;
91 } 144 }
92 145
146 /**
147 *
148 * @param description
149 */
93 public void setDescription(String[] description) { 150 public void setDescription(String[] description) {
94 if (this.description == null) 151 if (this.description == null)
95 this.description = new HashMap(); 152 this.description = new HashMap();
96 153
97 String[] values = splitValue(); 154 String[] values = splitValue();
108 } 165 }
109 } 166 }
110 } 167 }
111 168
112 /** 169 /**
113 * @see java.lang.Object#toString() 170 * @return
114 */ 171 */
115 @Override 172 @Override
116 public String toString() { 173 public String toString() {
117 return this.name + "==> " + this.value; 174 return this.name + "==> " + this.value;
118 } 175 }
119 176
120 /** 177 /**
121 * @see de.intevation.gnv.state.InputData#concartValue(java.lang.String) 178 * @param value
122 */ 179 */
123 public void concartValue(String value) { 180 public void concartValue(String value) {
124 this.value = this.value + VALUE_SEPARATOR + value; 181 this.value = this.value + VALUE_SEPARATOR + value;
125 } 182 }
126 183
127 /** 184 /**
128 * @see de.intevation.gnv.state.InputData#splitValue() 185 * @return
129 */ 186 */
130 public String[] splitValue() { 187 public String[] splitValue() {
131 if (this.value != null){ 188 if (this.value != null){
132 return this.value.split(VALUE_SEPARATOR); 189 return this.value.split(VALUE_SEPARATOR);
133 } 190 }
134 return null; 191 return null;
135 } 192 }
136 193
137 } 194 }
195 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org