* 2. If this tag has a value attribute together with either a property
* or type attribute.
*/
public void begin(String name, String namespace, Attributes attributes) throws SAXException {
TextDescriptor descriptor = new TextDescriptor();
String value = attributes.getValue( "value" );
String propertyName = attributes.getValue( "property" );
String propertyType = attributes.getValue( "type" );
if ( value != null) {
if ( propertyName != null || propertyType != null ) {
// not allowed
throw new SAXException(
"You cannot specify attribute 'value' together with either "
+ " the 'property' or 'type' attributes");
}
// fixed value text
descriptor.setTextExpression( new ConstantExpression( value ) );
} else {
// property based text
descriptor.setPropertyName( propertyName );
Class beanClass = getBeanClass();
// set the property type using reflection
descriptor.setPropertyType(
getPropertyType( propertyType, beanClass, propertyName )
);
if ( beanClass != null ) {
String descriptorPropertyName = descriptor.getPropertyName();
PropertyDescriptor propertyDescriptor =
getPropertyDescriptor( beanClass, descriptorPropertyName );
if ( propertyDescriptor != null ) {
Method readMethod = propertyDescriptor.getReadMethod();
descriptor.setTextExpression( new MethodExpression( readMethod ) );
Method writeMethod = propertyDescriptor.getWriteMethod();
if (writeMethod != null) {
descriptor.setUpdater( new MethodUpdater(writeMethod));
}
getProcessedPropertyNameSet().add( descriptorPropertyName );
}
}
}