1 9 package org.jboss.portal.common.value; 10 11 12 16 public class StringValue extends AbstractValue 17 { 18 19 private static final String [] EMPTY_STRING_ARRAY = new String [0]; 20 21 private String value; 22 23 public StringValue() 24 { 25 this.value = null; 26 } 27 28 public StringValue(String value) 29 { 30 if (value == null) 31 { 32 throw new IllegalArgumentException (); 33 } 34 this.value = value; 35 } 36 37 public String 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 asObject() 53 { 54 return value; 55 } 56 57 public Object [] asObjectArray() 58 { 59 if (isNull()) 60 { 61 return EMPTY_STRING_ARRAY; 62 } 63 return new String []{value}; 64 } 65 } 66 | Popular Tags |