A characterization of weighted Peetre K -functionals