TreeElement (char ch, CharTable charTable) { CharSequence entityText = switch (ch) { case '<' -> "&lt;"; case '\'' -> "&apos;"; case '"' -> "&quot;"; case '>' -> "&gt;"; case '&' -> "&amp;"; case '\u00a0' -> "&nbsp;"; default -> { final String charEncoding = "&#" + (int)ch + ";"; yield charTable.intern(charEncoding); } }; return ASTFactory.leaf(XmlTokenType.XML_CHAR_ENTITY_REF, entityText); }