public void setPropertyAsString( final String name, final String txt ) throws BeanException { if ( name == null ) { throw new NullPointerException( "Name must not be null" ); } if ( txt == null ) { throw new NullPointerException( "Text must not be null" ); } final PropertySpecification ps = new PropertySpecification( name ); final PropertyDescriptor pd = properties.get( ps.getName() ); if ( pd == null ) { throw new BeanException( bean.getClass() + ": No such property:" + name ); } setPropertyAsString( name, BeanUtility.getPropertyType( pd ), txt ); }
/** * Done parsing. * * @throws SAXException * if there is a parsing error. */ public void doneParsing() throws SAXException { super.doneParsing(); final String result = getResult(); if ( beanUtility == null ) { throw new SAXException( "No current beanUtility" ); } try { if ( propertyType != null ) { final ClassLoader cl = ObjectUtilities.getClassLoader( ExpressionPropertyReadHandler.class ); final Class c = Class.forName( propertyType, false, cl ); beanUtility.setPropertyAsString( propertyName, c, result ); } else { beanUtility.setPropertyAsString( propertyName, result ); } } catch ( BeanException e ) { throw new ParseException( "Unable to assign property '" + propertyName + "' to the specified Layout-PreProcessor", e, getLocator() ); } catch ( ClassNotFoundException e ) { throw new ParseException( "Unable to assign property '" + propertyName + "' to expression Layout-PreProcessor", e, getLocator() ); } }
final ClassLoader cl = ObjectUtilities.getClassLoader( ExpressionPropertyReadHandler.class ); final Class c = Class.forName( propertyType, false, cl ); beanUtility.setPropertyAsString( propertyName, c, result ); } else { beanUtility.setPropertyAsString( propertyName, result );
private void validateProperty( final BeanUtility bu, final String name, final Object value, final Object nullValue ) throws BeanException { bu.setProperty( name, nullValue ); assertValue( nullValue, bu.getProperty( name ) ); bu.setProperty( name, value ); assertValue( value, bu.getProperty( name ) ); final String valString = bu.getPropertyAsString( name ); assertNotNull( valString ); bu.setProperty( name, nullValue ); assertValue( nullValue, bu.getProperty( name ) ); bu.setPropertyAsString( name, valString ); assertValue( value, bu.getProperty( name ) ); bu.setProperty( name, nullValue ); assertValue( nullValue, bu.getProperty( name ) ); }