private int findMaximumIndex( final PropertyDescriptor id ) { try { final Object o = getPropertyForSpecification( new PropertySpecification( id.getName() ) ); return Array.getLength( o ); } catch ( Exception e ) { // ignore, we run 'til we encounter an index out of bounds Ex. } return 0; }
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 ); }
public Class getPropertyType( final String name ) throws BeanException { if ( name == null ) { throw new NullPointerException( "Name must not be null" ); } final PropertySpecification ps = new PropertySpecification( name ); final PropertyDescriptor pd = properties.get( ps.getName() ); if ( pd == null ) { throw new BeanException( "No such property:" + name ); } return BeanUtility.getPropertyType( pd ); }
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 ); }
public String getPropertyAsString( final String name ) throws BeanException { final PropertySpecification ps = new PropertySpecification( name ); final PropertyDescriptor pd = properties.get( ps.getName() ); if ( pd == null ) { throw new BeanException( "No such property:" + name ); } final Object o = getPropertyForSpecification( ps ); if ( o == null ) { return null; } final ValueConverter vc = ConverterRegistry.getInstance().getValueConverter( o.getClass() ); if ( vc == null ) { throw new BeanException( "Unable to handle property of type " + o.getClass().getName() ); } return vc.toAttributeValue( o ); }
public Object getProperty( final String name ) throws BeanException { return getPropertyForSpecification( new PropertySpecification( name ) ); }
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 ); }