KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > common > value > StringValue


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.common.value;
10
11
12 /**
13  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
14  * @version $Revision: 1.1.1.1 $
15  */

16 public class StringValue extends AbstractValue
17 {
18
19    private static final String JavaDoc[] EMPTY_STRING_ARRAY = new String JavaDoc[0];
20
21    private String JavaDoc value;
22
23    public StringValue()
24    {
25       this.value = null;
26    }
27
28    public StringValue(String JavaDoc value)
29    {
30       if (value == null)
31       {
32          throw new IllegalArgumentException JavaDoc();
33       }
34       this.value = value;
35    }
36
37    public String JavaDoc asString()
38    {
39       return value;
40    }
41
42    public int asInt() throws NullConversionException, FormatConversionException
43    {
44       return Helper.toInt(value);
45    }
46
47    public boolean asBoolean() throws NullConversionException, FormatConversionException
48    {
49       return Helper.toBoolean(value);
50    }
51
52    public Object JavaDoc asObject()
53    {
54       return value;
55    }
56
57    public Object JavaDoc[] asObjectArray()
58    {
59       if (isNull())
60       {
61          return EMPTY_STRING_ARRAY;
62       }
63       return new String JavaDoc[]{value};
64    }
65 }
66
Popular Tags