Analysis of spectral Hamiltonian boundary value methods (SHBVMs) for the numerical solution of ODE problems