code: String format(String field, long bits) {
              List<Setting> settings = cases.get(field);
              if (settings == null) {
                  return ""; //TODO error?
              }
              String format = null;
              for (int i = settings.size() - 1; i >= 0; --i) {
                  Setting ing = settings.get(i);
                  long mask = ing.enumBits;
                  if ((bits & mask) == bits) {
                      format = ing.format;
                      break;
                  }
              }
              if (format == null || format.isEmpty()) {
                  return "";
              }
              Matcher m = FIELD_PATTERN.matcher(format);
              StringBuffer sb = new StringBuffer(format.length());
              while (m.find()) {
                  String fieldName = m.group(1);
                  String sub = format(fieldName, bits);
                  m.appendReplacement(sb, Matcher.quoteReplacement(sub));
              }
              m.appendTail(sb);
              return sb.toString();
          }
docs: Lookup format Replace fields with context specific formats.
  
  @return format string