Characterization of pattern languages