public static Any set ( final int tangoType , final Object value ) throws DevFailed { final Any any = ORBManager . createAny ( ) ; if ( value != null ) { Object array = null ; if ( value . getClass ( ) . isArray ( ) ) { // convert to array of primitives if necessary array = org . tango . utils . ArrayUtils . toPrimitiveArray ( value ) ; } else { // put in an array before inserting for scalars array = Array . newInstance ( AttributeTangoType . getTypeFromTango ( tangoType ) . getType ( ) , 1 ) ; Array . set ( array , 0 , value ) ; } Method method = null ; try { final Class < ? > inserterClass = CLASS_MAP . get ( tangoType ) ; method = inserterClass . getMethod ( "insert" , Any . class , PARAM_MAP . get ( tangoType ) ) ; method . invoke ( null , any , array ) ; } catch ( final IllegalArgumentException e ) { throw DevFailedUtils . newDevFailed ( ExceptionMessages . ATTR_OPT_PROP , value . getClass ( ) . getCanonicalName ( ) + " is not of the good type, should be " + method ) ; } catch ( final IllegalAccessException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } catch ( final InvocationTargetException e ) { throw DevFailedUtils . newDevFailed ( e . getCause ( ) ) ; } catch ( final SecurityException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } catch ( final NoSuchMethodException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } } return any ; }
Set a value in an any