public void setProperty( final String name, final Object o ) throws BeanException { if ( name == null ) { throw new NullPointerException( "Name must not be null" ); } setProperty( new PropertySpecification( name ), o ); }
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 ) ); }
@Override public void doneParsing() throws SAXException { try { LinkedHashMap<String, Expression> map = new LinkedHashMap<>(); for ( ExpressionReadHandler handler : expressionHandlers ) { final Expression object = handler.getObject(); if ( object != null ) { final String name = object.getName(); // Style/attribute expressions have no explicit name. // The parser sets the name because we have a name-attribute in the XML. if ( name != null ) { object.setName( null ); map.put( name, object ); } } } expression.setProperty( propertyName, map ); } catch ( BeanException e ) { throw new ParseException( "Unable to set property" , e, getLocator()); } } }
public void setPropertyAsString( final String name, final Class type, final String txt ) throws BeanException { if ( name == null ) { throw new NullPointerException( "Name must not be null" ); } if ( type == null ) { throw new NullPointerException( "Type must not be null" ); } if ( txt == null ) { throw new NullPointerException( "Text must not be null" ); } final PropertySpecification ps = new PropertySpecification( name ); final ValueConverter vc; if ( ps.getIndex() != null && type.isArray() ) { vc = ConverterRegistry.getInstance().getValueConverter( type.getComponentType() ); } else { vc = ConverterRegistry.getInstance().getValueConverter( type ); } if ( vc == null ) { throw new BeanException( "Unable to handle '" + type + "' for property '" + name + '\'' ); } final Object o = vc.toPropertyValue( txt ); setProperty( ps, o ); }
@Override public void doneParsing() throws SAXException { try { LinkedHashMap<String, Expression> map = new LinkedHashMap<>(); for ( ExpressionReadHandler handler : expressionHandlers ) { final Expression object = handler.getObject(); if ( object != null ) { final String name = object.getName(); // Style/attribute expressions have no explicit name. // The parser sets the name because we have a name-attribute in the XML. if ( name != null ) { object.setName( null ); map.put( name, object ); } } } expression.setProperty( propertyName, map ); } catch ( BeanException e ) { throw new ParseException( "Unable to set property" , e, getLocator()); } } }