org.springframework.beans.factory.config
Class TypedStringValue

java.lang.Object
  extended by org.springframework.beans.factory.config.TypedStringValue
All Implemented Interfaces:
BeanMetadataElement

public class TypedStringValue
extends java.lang.Object
implements BeanMetadataElement

Holder for a typed String value. Can be added to bean definitions in order to explicitly specify a target type for a String value, for example for collection elements.

This holder will just store the String value and the target type. The actual conversion will be performed by the bean factory.

Since:
1.2
Author:
Juergen Hoeller
See Also:
BeanDefinition.getPropertyValues(), MutablePropertyValues.addPropertyValue(org.springframework.beans.PropertyValue)

Field Summary
private  boolean dynamic
           
private  java.lang.Object source
           
private  java.lang.String specifiedTypeName
           
private  java.lang.Object targetType
           
private  java.lang.String value
           
 
Constructor Summary
TypedStringValue(java.lang.String value)
          Create a new TypedStringValue for the given String value.
TypedStringValue(java.lang.String value, java.lang.Class targetType)
          Create a new TypedStringValue for the given String value and target type.
TypedStringValue(java.lang.String value, java.lang.String targetTypeName)
          Create a new TypedStringValue for the given String value and target type.
 
Method Summary
 boolean equals(java.lang.Object other)
           
 java.lang.Object getSource()
          Return the configuration source Object for this metadata element (may be null).
 java.lang.String getSpecifiedTypeName()
          Return the type name as actually specified for this particular value, if any.
 java.lang.Class getTargetType()
          Return the type to convert to.
 java.lang.String getTargetTypeName()
          Return the type to convert to.
 java.lang.String getValue()
          Return the String value.
 int hashCode()
           
 boolean hasTargetType()
          Return whether this typed String value carries a target type .
 boolean isDynamic()
          Return whether this value has been marked as dynamic.
 java.lang.Class resolveTargetType(java.lang.ClassLoader classLoader)
          Determine the type to convert to, resolving it from a specified class name if necessary.
 void setDynamic()
          Mark this value as dynamic, i.e.
 void setSource(java.lang.Object source)
          Set the configuration source Object for this metadata element.
 void setSpecifiedTypeName(java.lang.String specifiedTypeName)
          Set the type name as actually specified for this particular value, if any.
 void setTargetType(java.lang.Class targetType)
          Set the type to convert to.
 void setTargetTypeName(java.lang.String targetTypeName)
          Specify the type to convert to.
 void setValue(java.lang.String value)
          Set the String value.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

value

private java.lang.String value

targetType

private volatile java.lang.Object targetType

source

private java.lang.Object source

specifiedTypeName

private java.lang.String specifiedTypeName

dynamic

private volatile boolean dynamic
Constructor Detail

TypedStringValue

public TypedStringValue(java.lang.String value)
Create a new TypedStringValue for the given String value.

Parameters:
value - the String value

TypedStringValue

public TypedStringValue(java.lang.String value,
                        java.lang.Class targetType)
Create a new TypedStringValue for the given String value and target type.

Parameters:
value - the String value
targetType - the type to convert to

TypedStringValue

public TypedStringValue(java.lang.String value,
                        java.lang.String targetTypeName)
Create a new TypedStringValue for the given String value and target type.

Parameters:
value - the String value
targetTypeName - the type to convert to
Method Detail

setValue

public void setValue(java.lang.String value)
Set the String value.

Only necessary for manipulating a registered value, for example in BeanFactoryPostProcessors.

See Also:
PropertyPlaceholderConfigurer

getValue

public java.lang.String getValue()
Return the String value.


setTargetType

public void setTargetType(java.lang.Class targetType)
Set the type to convert to.

Only necessary for manipulating a registered value, for example in BeanFactoryPostProcessors.

See Also:
PropertyPlaceholderConfigurer

getTargetType

public java.lang.Class getTargetType()
Return the type to convert to.


setTargetTypeName

public void setTargetTypeName(java.lang.String targetTypeName)
Specify the type to convert to.


getTargetTypeName

public java.lang.String getTargetTypeName()
Return the type to convert to.


hasTargetType

public boolean hasTargetType()
Return whether this typed String value carries a target type .


resolveTargetType

public java.lang.Class resolveTargetType(java.lang.ClassLoader classLoader)
                                  throws java.lang.ClassNotFoundException
Determine the type to convert to, resolving it from a specified class name if necessary. Will also reload a specified Class from its name when called with the target type already resolved.

Parameters:
classLoader - the ClassLoader to use for resolving a (potential) class name
Returns:
the resolved type to convert to
Throws:
java.lang.ClassNotFoundException - if the type cannot be resolved

setSource

public void setSource(java.lang.Object source)
Set the configuration source Object for this metadata element.

The exact type of the object will depend on the configuration mechanism used.


getSource

public java.lang.Object getSource()
Description copied from interface: BeanMetadataElement
Return the configuration source Object for this metadata element (may be null).

Specified by:
getSource in interface BeanMetadataElement

setSpecifiedTypeName

public void setSpecifiedTypeName(java.lang.String specifiedTypeName)
Set the type name as actually specified for this particular value, if any.


getSpecifiedTypeName

public java.lang.String getSpecifiedTypeName()
Return the type name as actually specified for this particular value, if any.


setDynamic

public void setDynamic()
Mark this value as dynamic, i.e. as containing an expression and hence not being subject to caching.


isDynamic

public boolean isDynamic()
Return whether this value has been marked as dynamic.


equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object