Thermodynamics of ion exchange as an adsorption process