Пример #1
0
  public String getColumns() {
    String pluralizedName = mInflector.pluralize(name);
    String underscorePlural = mInflector.underscore(pluralizedName);
    String underscore = mInflector.underscore(name);

    StringBuilder sb = new StringBuilder();
    sb.append("public static class ").append(name).append(" implements BaseColumns {\n");

    // Content mime types
    sb.append(ONE_TAB)
        .append(PUBLIC_STATIC_FINAL)
        .append(
            "String CONTENT_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE + /vnd.contentrovider.");
    sb.append(mInflector.pluralize(underscore.toLowerCase())).append(";\n\n");
    sb.append(ONE_TAB)
        .append(PUBLIC_STATIC_FINAL)
        .append(
            "String CONTENT_ITEM_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE + /vnd.contentrovider.");
    sb.append(underscore.toLowerCase()).append(";\n\n");

    // Content URIs

    sb.append(ONE_TAB)
        .append(PUBLIC_STATIC_FINAL)
        .append("Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH_")
        .append(underscorePlural.toUpperCase())
        .append(").build();\n\n");
    if (members.contains("mId") || members.contains("mUniqueId")) {
      sb.append(ONE_TAB)
          .append(PUBLIC_STATIC_FINAL)
          .append("Uri CONTENT_BY_ID = BASE_CONTENT_URI.buildUpon().appendPath(PATH_")
          .append(underscorePlural.toUpperCase())
          .append("_BY_ID).build();\n\n");
    }

    // Table name
    sb.append(ONE_TAB)
        .append(PUBLIC_STATIC_FINAL)
        .append("String TABLE_NAME = \"")
        .append(underscore.toLowerCase())
        .append("\";\n\n");

    // column names
    for (Member member : members) {
      String simpleName = StringUtils.removeStart(member.getName(), "m");
      String underscoreMember = mInflector.underscore(simpleName);
      sb.append(ONE_TAB)
          .append(PUBLIC_STATIC_FINAL)
          .append("String COLUMN_NAME_")
          .append(underscoreMember.toUpperCase())
          .append(" = \"")
          .append(underscoreMember.toLowerCase())
          .append("\";\n\n");
    }

    sb.append("}\n");
    return sb.toString();
  }
Пример #2
0
 @Override
 public String toString() {
   int count = this.getCount();
   String samples = Inflector.getInstance().pluralize("sample", count);
   return StringUtil.createString(
       "{0} {1}: min={2}; avg={3}; max={4}",
       count, samples, this.minimum, this.mean, this.maximum);
 }