add ToText class.
Generalize FromText.