code: public static boolean containsEntity(String value)
      {
          assert (value != null) : "Parameter 'value' must not be null";
  
          int pos = value.indexOf('&');
          if (pos == -1)
              return false;
  
          int end = value.indexOf(';');
          if (end != -1 && pos < end) {
              // extract the entity and then verify it is
              // a valid unicode identifier.
              String entity = value.substring(pos + 1, end);
              if (entity.length() == 0)
                  return false;
              char[] chars = entity.toCharArray();
  
              // verify the start is an indentifier start
              // and the rest is a part.
              if (!Character.isUnicodeIdentifierStart(chars[0])) {
                  if (chars[0] == '#' && chars.length > 1) {
                      for (int i = 1; i < chars.length; i++) {
                          if (!Character.isDigit(chars[i]))
                              return false;
                      }
                      return true;
                  }
                  return false;
              }
              for (int i = 1; i < chars.length; i++) {
                  if (!Character.isUnicodeIdentifierPart(chars[i]))
                      return false;
              }
              // good indentifier
              return true;
          }
          return false;
      }
docs: Determine if the given <code>value</code> contains an HTML entity.
  @param value the value to check for an entity
  @return <code>true</code> if the value contains an entity; <code>false</code> otherwise.