View Javadoc

1   package net.sf.chainedoptions.support;
2   
3   import net.sf.chainedoptions.AbstractBeanConverter;
4   import net.sf.chainedoptions.LabelValueBean;
5   
6   /***
7    * BeanConverter for String objects. Constructs LabelValueBeans with label and
8    * value as the supplied String.
9    * 
10   * @author Mattias Arthursson
11   */
12  public class StringBeanConverter extends AbstractBeanConverter {
13  
14      /***
15       * Create a <code>LabelValueBean</code> with name and value as the
16       * supplied String.
17       * 
18       * @param object
19       *            <code>String</code> to convert.
20       * @return a new <code>LabelValueBean</code>
21       * @throws ClassCastException
22       *             if the supplied <code>object</code> is not a
23       *             <code>String</code>.
24       */
25      protected LabelValueBean convertBean(Object object) {
26          String string = (String) object;
27          return new LabelValueBean(string, string);
28      }
29  }