org.entityfs.util.properties
Class PropertyValue

java.lang.Object
  extended by org.entityfs.util.properties.PropertyValue
All Implemented Interfaces:
Serializable, CharSequence

public class PropertyValue
extends Object
implements CharSequence, Serializable

This is the value for a property in a Properties object. This object has methods for interpreting the property value as different data types.

A value may not be null.

This object is immutable.

Since:
1.1
Author:
Karl Gustafsson
See Also:
Serialized Form

Constructor Summary
PropertyValue(String value)
          Create a new property value.
 
Method Summary
 char charAt(int index)
           
 boolean equals(Object o)
           
 boolean getBooleanValue()
          Get the property value converted to a boolean.
 double getDoubleValue()
          Get the property value converted to a double.
 float getFloatValue()
          Get the property value converted to a float.
 int getIntValue()
          Get the property value converted to an int.
 long getLongValue()
          Get the property value converted to a long.
 Serializable getObjectValue()
          Get the property value deserialized to an object.
 String[] getSplitStringArrayValue(String regexp)
          Get the property value split to a String array value using the supplied regular expression.
 String[] getStringArrayValue()
          Get the property value split to a String array value.
 String getStringValue()
          Get the property value.
 int hashCode()
           
 int length()
           
 CharSequence subSequence(int start, int end)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PropertyValue

public PropertyValue(String value)
              throws NullPointerException
Create a new property value.

Parameters:
value - The value. May not be null.
Throws:
NullPointerException - If the value is null.
Method Detail

charAt

public char charAt(int index)
Specified by:
charAt in interface CharSequence

length

public int length()
Specified by:
length in interface CharSequence

subSequence

public CharSequence subSequence(int start,
                                int end)
Specified by:
subSequence in interface CharSequence

getLongValue

public long getLongValue()
                  throws NumberFormatException
Get the property value converted to a long.

Returns:
The property value converted to a long.
Throws:
NumberFormatException - If the property value cannot be converted to a long.

getIntValue

public int getIntValue()
                throws NumberFormatException
Get the property value converted to an int.

Returns:
The property value converted to an int.
Throws:
NumberFormatException - If the property value cannot be converted to an int.

getFloatValue

public float getFloatValue()
                    throws NumberFormatException
Get the property value converted to a float.

Returns:
The property value converted to an float.
Throws:
NumberFormatException - If the property value cannot be converted to a float.

getDoubleValue

public double getDoubleValue()
                      throws NumberFormatException
Get the property value converted to a double.

Returns:
The property value converted to an double.
Throws:
NumberFormatException - If the property value cannot be converted to a double.

getBooleanValue

public boolean getBooleanValue()
Get the property value converted to a boolean. Boolean.valueOf(String) is used for the conversion.

Returns:
The property value converted to an boolean.

getObjectValue

public Serializable getObjectValue()
                            throws WrappedIOException
Get the property value deserialized to an object. This implementation assumes that the serialized data is stored as a base64 encoded string.

Returns:
The property value deserialized to an object.
Throws:
WrappedIOException - If the property value cannot be deserialized.

getStringValue

public String getStringValue()
Get the property value.

Returns:
The property value.

getStringArrayValue

public String[] getStringArrayValue()
Get the property value split to a String array value. The regular expression Properties.STRING_ARRAY_SPLIT_REGEXP is used for splitting the property value into the array.

Returns:
The property value split into a String array.
See Also:
getSplitStringArrayValue(String), String.split(String)

getSplitStringArrayValue

public String[] getSplitStringArrayValue(String regexp)
Get the property value split to a String array value using the supplied regular expression.

Parameters:
regexp - The regular expression used to split the value into a String array.
Returns:
The property value split into a String array.
See Also:
getStringArrayValue(), String.split(String)

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Specified by:
toString in interface CharSequence
Overrides:
toString in class Object