1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.oness.common.webapp.controller.util;
17
18 import java.util.HashSet;
19 import java.util.Set;
20
21 import net.sf.oness.common.model.auditing.Auditable;
22
23 import org.apache.commons.beanutils.Converter;
24
25 /***
26 * Given a string array, converts it into an Auditable array with ids equal
27 * to that strings.
28 *
29 * @deprecated
30 *
31 * @author Carlos Sanchez
32 * @version $Revision: 1.2 $
33 */
34 public class StringArrayToAuditableConverter implements Converter {
35
36 private Auditable auditableValue;
37
38 /***
39 *
40 * @param auditableValue
41 * an object of the destination class
42 */
43 public StringArrayToAuditableConverter(Auditable auditableValue) {
44 this.auditableValue = auditableValue;
45 }
46
47 /***
48 * @return a Set with <code>Auditable</code> objects cloned from the
49 * provided at creation time with ids set to values or null if value
50 * has zero length
51 * @see org.apache.commons.beanutils.Converter#convert(java.lang.Class,
52 * java.lang.Object)
53 */
54 public Object convert(Class type, Object value) {
55 String values[] = (String[]) value;
56 if (values.length == 0)
57 return null;
58 Set auditableValues = new HashSet(values.length);
59 for (int i = 0; i < values.length; i++) {
60 Auditable av = (Auditable) auditableValue.clone();
61 av.setId(new Long(values[i]));
62 auditableValues.add(av);
63 }
64 return auditableValues;
65 }
66
67 }