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 net.sf.oness.common.model.auditing.Auditable;
19
20 import org.apache.commons.beanutils.Converter;
21
22 /***
23 * Given a string, converts it into an Auditable with id equal to that
24 * string.
25 *
26 * @deprecated
27 *
28 * @author Carlos Sanchez
29 * @version $Revision: 1.2 $
30 */
31 public class StringToAuditableConverter implements Converter {
32
33 private Auditable auditableValue;
34
35 /***
36 *
37 * @param auditableValue
38 * an object of the destination class
39 */
40 public StringToAuditableConverter(Auditable auditableValue) {
41 this.auditableValue = auditableValue;
42 }
43
44 /***
45 * @return an <code>Auditable</code> object cloned from the provided
46 * at creation time with id set to value or null if value can't be
47 * parsed as a Long
48 * @see org.apache.commons.beanutils.Converter#convert(java.lang.Class,
49 * java.lang.Object)
50 */
51 public Object convert(Class type, Object value) {
52 try {
53 Long id = new Long(value.toString());
54 Auditable av = (Auditable) auditableValue.clone();
55 av.setId(id);
56 return av;
57 } catch (NumberFormatException e) {
58 return null;
59 }
60 }
61
62 }