Java StringBuilder.append Examples

Java StringBuilder.append - 30 examples found. These are the top rated real world Java examples of StringBuilder.append extracted from open source projects. You can rate examples to help us improve the quality of examples.
  public void addSetterComment(Method method, FullyQualifiedTable table, String columnName) {
    StringBuilder sb = new StringBuilder();

    method.addJavaDocLine("/**"); // $NON-NLS-1$
    method.addJavaDocLine(" * This method was generated by Apache iBATIS ibator."); // $NON-NLS-1$

    sb.append(" * This method sets the value of the database column "); // $NON-NLS-1$
    sb.append(table);
    sb.append('.');
    sb.append(columnName);
    method.addJavaDocLine(sb.toString());

    method.addJavaDocLine(" *"); // $NON-NLS-1$

    Parameter parm = method.getParameters().get(0);
    sb.setLength(0);
    sb.append(" * @param "); // $NON-NLS-1$
    sb.append(parm.getName());
    sb.append(" the value for "); // $NON-NLS-1$
    sb.append(table);
    sb.append('.');
    sb.append(columnName);
    method.addJavaDocLine(sb.toString());

    addIbatorJavadocTag(method);

    method.addJavaDocLine(" */"); // $NON-NLS-1$
  }
  private static void generateNameByString(
      Set<String> possibleNames,
      String value,
      NameValidator validator,
      boolean forStaticVariable,
      Project project) {
    if (!JavaPsiFacade.getInstance(project).getNameHelper().isIdentifier(value)) return;
    if (forStaticVariable) {
      StringBuilder buffer = new StringBuilder(value.length() + 10);
      char[] chars = new char[value.length()];
      value.getChars(0, value.length(), chars, 0);
      boolean wasLow = Character.isLowerCase(chars[0]);

      buffer.append(Character.toUpperCase(chars[0]));
      for (int i = 1; i < chars.length; i++) {
        if (Character.isUpperCase(chars[i])) {
          if (wasLow) {
            buffer.append('_');
            wasLow = false;
          }
        } else {
          wasLow = true;
        }

        buffer.append(Character.toUpperCase(chars[i]));
      }
      possibleNames.add(validator.validateName(buffer.toString(), true));
    } else {
      possibleNames.add(validator.validateName(value, true));
    }
  }
Example #3
0
 public String getPrimaryDisplay() {
   StringBuilder sb = new StringBuilder();
   sb.append("");
   sb.append(
       (user.getPrimaryDisplay().toString() == null ? " " : user.getPrimaryDisplay().toString()));
   return sb.toString();
 }
  public static String reformatQuery(String query, String matchingSensors, String unionElement) {

    String lower_query = query.toLowerCase();

    String listSensors[] = matchingSensors.split(",");
    for (int i = 0; i < listSensors.length; i++) logger.warn(i + " : " + listSensors[i]);

    // replace "sensors"
    String ref_query =
        new StringBuilder(lower_query.replaceAll(LIST_SENSORS_RESERVED_WORD_REGEX, matchingSensors))
            .toString();

    // check for aggregates, containing reserved word $union
    if (ref_query.indexOf(UNION_RESERVED_WORD) > 0) {
      StringBuilder unionOfAll = new StringBuilder();
      if (unionElement != "") {
        System.out.println("what_to_repeat => " + unionElement);
        for (int i = 0; i < listSensors.length; i++) {
          unionOfAll.append(unionElement.replaceAll(SENSOR_RESERVED_WORD_REGEX, listSensors[i]));
          if (i < listSensors.length - 1) unionOfAll.append("\n union \n");
        }
      }
      System.out.println("unionofAll => " + unionOfAll);
      ref_query = ref_query.replaceAll(UNION_RESERVED_WORD_REGEX, unionOfAll.toString());
    }

    return ref_query;
  }
  @LargeTest
  public void testManyRowsTxt() throws Exception {
    mDatabase.execSQL("CREATE TABLE test (_id INTEGER PRIMARY KEY, data TEXT);");
    StringBuilder sql = new StringBuilder(2100);
    sql.append("INSERT INTO test (data) VALUES ('");
    Random random = new Random(System.currentTimeMillis());
    StringBuilder randomString = new StringBuilder(1979);
    for (int i = 0; i < 1979; i++) {
      randomString.append((random.nextInt() & 0xf) % 10);
    }
    sql.append(randomString);
    sql.append("');");

    // if cursor window size changed, adjust this value too
    final int count = 600; // more than two fillWindow needed
    for (int i = 0; i < count; i++) {
      mDatabase.execSQL(sql.toString());
    }

    Cursor c = mDatabase.query("test", new String[] {"data"}, null, null, null, null, null);
    assertNotNull(c);

    int i = 0;
    while (c.moveToNext()) {
      assertEquals(randomString.toString(), c.getString(0));
      i++;
    }
    assertEquals(count, i);
    assertEquals(count, c.getCount());
    c.close();
  }
Example #6
0
 private void readFromParcel(Parcel in) {
   // fieldToAccept = in.readInt();
   title.append(in.readString());
   date.append(in.readString());
   description.append(in.readString());
   setImageURL(in.readString());
 }