Generation and measurement of nonclassical states by quantum Fock filter