code: public static String unStudlyName (String name)
      {
          boolean seenLower = false;
          StringBuilder nname = new StringBuilder();
          int nlen = name.length();
          for (int i = 0; i < nlen; i++) {
              char c = name.charAt(i);
              // if we see an upper case character and we've seen a lower case character since the
              // last time we did so, slip in an _
              if (Character.isUpperCase(c)) {
                  if (seenLower) {
                      nname.append("_");
                  }
                  seenLower = false;
                  nname.append(c);
              } else {
                  seenLower = true;
                  nname.append(Character.toUpperCase(c));
              }
          }
          return nname.toString();
      }
docs: Converts a name of the form <code>weAreSoCool</code> to a name of the form
  <code>WE_ARE_SO_COOL</code>.