[LANG-102] [lang] Refactor Entities methods. http://issues.apache.org/jira/browse/LANG-102. Refactored escape and unescape methods to remove code duplication.