Java StringBuilder.trimToSize Examples

Java StringBuilder.trimToSize - 21 examples found. These are the top rated real world Java examples of StringBuilder.trimToSize extracted from open source projects. You can rate examples to help us improve the quality of examples.
  private static ORMSQLContext buildCreateColumnList(
      Object obj, com.corm.mapping.generated.Class clazz, String action, String ignoreFor) {

    //		String catalog = clazz.getKeyspace();
    String table = clazz.getColumnFamily();
    StringBuilder builder = new StringBuilder();
    builder.append(action + " ").append(table + " (");
    Set<String> columns = ORMPropertyListBuilder.build(obj, clazz.getName(), ignoreFor);
    Set<com.corm.mapping.generated.Column> refined =
        new LinkedHashSet<com.corm.mapping.generated.Column>();

    for (String column : columns) {
      //			String name = column.getName();
      builder.append(column + ',');
    }

    builder.trimToSize();
    builder = new StringBuilder(builder.substring(0, builder.length() - 1));
    builder.append(") VALUES (");

    for (int i = 0; i < columns.size(); i++) {
      //			if(column.isInject() && !canIgnore(column,ignoreFor)){
      //				builder.append(column.getHint()+",");
      //			}else{
      //				refined.add(column);
      builder.append("?,");
      //			}
    }

    String sql = builder.substring(0, builder.length() - 1) + ")";
    builder.setLength(0);
    builder = null;
    return new ORMSQLContext(sql, refined);
  }
Example #2
0
  @Override
  public void writeXml2ResultFileBody(
      final File file, final List<Defect> allDefectList, final String sourceFileFullPath)
      throws IOException {
    int size = allDefectList.size() * 1024;
    StringBuilder m;
    if (size < Integer.MAX_VALUE) m = new StringBuilder(size);
    else m = new StringBuilder(Integer.MAX_VALUE);

    m.append("\t<error filename=\"").append(sourceFileFullPath).append("\">\n");

    for (Defect defect : allDefectList) {
      m.append("\t\t<defect checker=\"").append(defect.getCheckerCode()).append("\">\n");
      for (Occurence o : defect.getOccurences()) {
        m.append("\t\t\t<occurence startLine=\"")
            .append(o.getStartLine())
            .append("\" ")
            .append("endLine=\"")
            .append(o.getEndLine())
            .append("\" ")
            .append(" message=\"")
            .append(o.getMessage())
            .append("\" />\n");
      }
      m.append("\t\t</defect>\n");
    }

    m.append("\t</error>\n");

    m.trimToSize();
    Files.append(m.toString(), file, Charsets.UTF_8);
  }
 public static void __getNotes(String url, String token, Long[] ids)
     throws MoodleRestNotesException, MoodleRestException, UnsupportedEncodingException {
   if (MoodleCallRestWebService.isLegacy())
     throw new MoodleRestNotesException(MoodleRestException.NO_LEGACY);
   // MoodleWarning[] warnings=null;
   String functionCall = MoodleServices.CORE_NOTES_GET_NOTES.toString();
   StringBuilder data = new StringBuilder();
   data.append(URLEncoder.encode("wstoken", MoodleServices.ENCODING.toString()))
       .append("=")
       .append(URLEncoder.encode(token, MoodleServices.ENCODING.toString()));
   data.append("&")
       .append(URLEncoder.encode("wsfunction", MoodleServices.ENCODING.toString()))
       .append("=")
       .append(URLEncoder.encode(functionCall, MoodleServices.ENCODING.toString()));
   for (int i = 0; i < ids.length; i++) {
     if (ids[i] == null) throw new MoodleRestNotesException();
     else
       data.append("&")
           .append(URLEncoder.encode("notes[" + i + "]", MoodleServices.ENCODING.toString()))
           .append("=")
           .append(ids[i]);
   }
   data.trimToSize();
   NodeList elements = (new MoodleCallRestWebService()).__call(url, data.toString());
   // return warnings;
 }
 @Override
 public CharSequence getDisplayContents() {
   EmailAddressParsedResult result = (EmailAddressParsedResult) getResult();
   StringBuilder contents = new StringBuilder(100);
   ParsedResult.maybeAppend(result.getEmailAddress(), contents);
   contents.trimToSize();
   return contents.toString();
 }
Example #5
0
 private String getSharedIntentData() {
   StringBuilder sb = new StringBuilder();
   sb.append(String.format("%s - Dmesg Log Capture\n", getString(R.string.app_name)));
   for (DmesgLine dmesgEntry : this.mListDmesgs) {
     sb.append(dmesgEntry.toString() + "\n");
   }
   sb.trimToSize();
   return sb.toString();
 }
Example #6
0
  @Override
  public void analyze(Document doc, InputStream in) throws IOException {
    content.setLength(0);

    TarInputStream zis = new TarInputStream(in);
    TarEntry entry;
    while ((entry = zis.getNextEntry()) != null) {
      content.append(entry.getName()).append('\n');
    }
    content.trimToSize();
    doc.add(new TextField("full", content.toString(), Store.NO));
  }