Maybe all those checks could be factored in a single private method? This would make the main listener method more readable IMHO.