code: public static String entify (String text)
      {
          // this could perhaps be done more efficiently, but this function
          // is not likely to be called on large quantities of text
          // (first we turn the entified versions normal so that if text is
          // repeatedly run through this it doesn't keep changing successive
          // &'s into "&amp;".
          text = text.replace("&quot;", "\"");
          text = text.replace("&gt;", ">");
          text = text.replace("&lt;", "<");
          text = text.replace("&amp;", "&");
          text = text.replace("&", "&amp;");
          text = text.replace("<", "&lt;");
          text = text.replace(">", "&gt;");
          text = text.replace("\"", "&quot;");
          return text;
      }
docs: Converts instances of {@code <, >, & and "} into their
  entified equivalents: {@code &lt;, &gt;, &amp; and &quot;}.
  These characters are mentioned in the HTML spec as being common
  candidates for entification.
  
  @return the entified string.