Radiatively and shock excited H2 in Magellanic H II regions