List of usage examples for java.lang StringBuffer length
@Override public synchronized int length()
From source file:com.clican.pluto.cms.dao.hibernate.BaseDao.java
protected String getInString(Collection<? extends IPojo> collection) { StringBuffer str = new StringBuffer(); str.append("("); for (IPojo pojo : collection) { str.append(pojo.getId());/* w w w. j a v a2 s .c om*/ str.append(","); } return str.substring(0, str.length() - 1) + ")"; }
From source file:com.bjwg.back.util.PropertyFilter.java
public static String buildStringByPropertyFilter(final List<PropertyFilter> filters, final boolean ifAbs) { StringBuffer sb = new StringBuffer(); for (PropertyFilter filter : filters) { if (!filter.hasMultiProperties()) { //?,filter_EQS_account sb = toSqlString(filter.getPropertyName(), filter.getMatchValue(), filter.getMatchType(), filter.getPropertyClass(), sb, ifAbs); } else {//,filter_LIKES_realName_OR_email sb = toSqlString(filter.getPropertyNames(), filter.getMatchValue(), filter.getMatchType(), filter.getPropertyClass(), sb, ifAbs); }//www . j av a2 s . c o m } if (sb == null || sb.length() <= 0) { return ""; } return sb.toString(); }
From source file:eionet.transfer.controller.FileOpsController.java
/** * AJAX Upload file for transfer./*ww w .j a v a 2 s . c o m*/ */ @RequestMapping(value = "/fileupload", method = RequestMethod.POST, params = "ajaxupload=1") public void importFileWithAJAX(@RequestParam("file") MultipartFile myFile, @RequestParam("fileTTL") int fileTTL, HttpServletRequest request, HttpServletResponse response) throws IOException { if (myFile == null || myFile.getOriginalFilename() == null) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Select a file to upload"); return; } if (fileTTL > 90) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Invalid expiration date"); return; } String uuidName = storeFile(myFile, fileTTL); response.setContentType("text/xml"); PrintWriter printer = response.getWriter(); StringBuffer requestUrl = request.getRequestURL(); String url = requestUrl.substring(0, requestUrl.length() - "/fileupload".length()); printer.println("<?xml version='1.0'?>"); printer.println("<package>"); printer.println("<downloadLink>" + url + "/download/" + uuidName + "</downloadLink>"); printer.println("<deleteLink>" + url + "/delete/" + uuidName + "</deleteLink>"); printer.println("</package>"); printer.flush(); response.flushBuffer(); }
From source file:com.clustercontrol.HinemosManagerCli.java
private void printMBeanInfo(MBeanInfo mbeanInfo) { MBeanAttributeInfo[] attributeInfos = mbeanInfo.getAttributes(); System.out.println("Attributes:"); for (MBeanAttributeInfo attributeInfo : attributeInfos) { System.out.println(String.format("\t%s: %s", attributeInfo.getName(), attributeInfo.getType())); }/*w w w. j a va 2s . co m*/ MBeanOperationInfo[] operationInfos = mbeanInfo.getOperations(); System.out.println("Operations:"); for (MBeanOperationInfo operationInfo : operationInfos) { MBeanParameterInfo[] paramInfos = operationInfo.getSignature(); StringBuffer paramStr = new StringBuffer(); for (MBeanParameterInfo paramInfo : paramInfos) { paramStr.append(paramInfo.getType() + ","); } if (paramStr.length() != 0) { paramStr.append(paramStr.substring(0, paramStr.length() - 1)); } System.out.println( String.format("\t%s %s(%s)", operationInfo.getReturnType(), operationInfo.getName(), paramStr)); } }
From source file:com.hp.alm.ali.idea.model.type.PlainTextType.java
@Override public String translate(String value, ValueCallback callback) { try {//from w w w . ja va 2 s . co m final StringBuffer buf = new StringBuffer(); new ParserDelegator().parse(new StringReader(value), new HTMLEditorKit.ParserCallback() { @Override public void handleText(char[] data, int pos) { if (buf.length() > 0 && !StringUtils.isWhitespace(buf.substring(buf.length() - 1))) { buf.append(" "); } buf.append(data); } }, false); return buf.toString(); } catch (IOException e) { return StringEscapeUtils.escapeHtml(value); } }
From source file:com.threepillar.labs.meeting.email.EmailInviteImpl.java
@Override public void sendInvite(final String subject, final String description, final Participant from, final List<Participant> attendees, final Date startDate, final Date endDate, final String location) throws Exception { this.properties.put("mail.smtp.socketFactory.port", properties.get("mail.smtp.port")); this.properties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); this.properties.put("mail.smtp.socketFactory.fallback", "false"); validate();//from www.java 2 s. c o m LOG.info("Sending meeting invite"); LOG.debug("Mail Properties :: " + this.properties); Session session; if (password != null) { session = Session.getInstance(this.properties, new javax.mail.Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); } }); } else { session = Session.getInstance(this.properties); } ICal cal = new ICal(subject, description, from, attendees, startDate, endDate, location); cal.init(); StringBuffer sb = new StringBuffer(); sb.append(from.getEmail()); for (Participant bean : attendees) { if (sb.length() > 0) { sb.append(","); } sb.append(bean.getEmail()); } MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress(from.getEmail())); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(sb.toString())); message.setSubject(subject); Multipart multipart = new MimeMultipart(); MimeBodyPart iCal = new MimeBodyPart(); iCal.setDataHandler(new DataHandler(new ByteArrayDataSource(new ByteArrayInputStream(cal.toByteArray()), "text/calendar;method=REQUEST;charset=\"UTF-8\""))); LOG.debug("Calender Request :: \n" + cal.toString()); multipart.addBodyPart(iCal); message.setContent(multipart); Transport.send(message); }
From source file:eea.eprtr.cms.controller.FileOpsController.java
/** * Upload file for transfer.//from www . ja v a2 s. c om */ @RequestMapping(value = "/filecatalogue", method = RequestMethod.POST) public String importFile(@RequestParam("file") MultipartFile myFile, final RedirectAttributes redirectAttributes, final HttpServletRequest request) throws IOException { if (myFile == null || myFile.getOriginalFilename() == null) { redirectAttributes.addFlashAttribute("message", "Select a file to upload"); return "redirect:filecatalogue"; } String fileName = storeFile(myFile); redirectAttributes.addFlashAttribute("filename", fileName); StringBuffer requestUrl = request.getRequestURL(); redirectAttributes.addFlashAttribute("url", requestUrl.substring(0, requestUrl.length() - "/filecatalogue".length())); return "redirect:filecatalogue"; }
From source file:com.sfs.whichdoctor.formatter.ExpenseClaimFormatter.java
private static String getQuantity(final ExpenseClaimBean expenseClaim) { final StringBuffer value = new StringBuffer(); if (StringUtils.equals(expenseClaim.getExpenseClass(), "Travel") && StringUtils.equals(expenseClaim.getExpenseType(), "Petrol (Lump sum)")) { if (StringUtils.isNotBlank(expenseClaim.getCurrencyAbbreviation()) && !StringUtils.equals(expenseClaim.getCurrencyAbbreviation(), DEFAULT_CURRENCY_ABBR)) { value.append(expenseClaim.getCurrencyAbbreviation()); }/*from w w w .j a v a2s. c o m*/ value.append(Formatter.toCurrency(expenseClaim.getRate())); } if (StringUtils.equals(expenseClaim.getExpenseClass(), "Travel") && StringUtils.equals(expenseClaim.getExpenseType(), "Mileage Reimbursement")) { value.append(expenseClaim.getQuantity() + " kilometers @ "); value.append(Formatter.toCurrency(expenseClaim.getRate())); if (StringUtils.isNotBlank(expenseClaim.getCurrencyAbbreviation()) && !StringUtils.equals(expenseClaim.getCurrencyAbbreviation(), DEFAULT_CURRENCY_ABBR)) { value.append(expenseClaim.getCurrencyAbbreviation()); } value.append(" per kilometer"); } if (value.length() == 0) { value.append(expenseClaim.getQuantity() + " @ "); if (StringUtils.isNotBlank(expenseClaim.getCurrencyAbbreviation()) && !StringUtils.equals(expenseClaim.getCurrencyAbbreviation(), DEFAULT_CURRENCY_ABBR)) { value.append(expenseClaim.getCurrencyAbbreviation()); } value.append(Formatter.toCurrency(expenseClaim.getRate())); } if (StringUtils.isNotBlank(expenseClaim.getDescription())) { if (value.length() > 0) { value.append(" - "); } value.append(expenseClaim.getDescription()); } if (StringUtils.isNotBlank(expenseClaim.getCurrencyAbbreviation()) && !StringUtils.equals(expenseClaim.getCurrencyAbbreviation(), DEFAULT_CURRENCY_ABBR)) { if (value.length() > MAX_QUANTITY) { value.append("<br/>"); } value.append(" (Rate: " + expenseClaim.getCurrencyAbbreviation() + "$1 = " + DEFAULT_CURRENCY_ABBR + "$" + expenseClaim.getExchangeRate() + ")"); } return value.toString(); }
From source file:ProducerTool.java
private String createMessageText(int index) { StringBuffer buffer = new StringBuffer(messageSize); buffer.append("Message: " + index + " sent at: " + new Date()); if (buffer.length() > messageSize) { return buffer.substring(0, messageSize); }/*from ww w . j av a 2 s .co m*/ for (int i = buffer.length(); i < messageSize; i++) { buffer.append(' '); } return buffer.toString(); }
From source file:ISO8601DateTimeFormat.java
/** * Write an integer value with leading zeros. * @param buf The buffer to append the string. * @param value The value to write./*from w w w . j a va 2 s .c om*/ * @param length The length of the string to write. */ protected final void appendInt(StringBuffer buf, int value, int length) { int len1 = buf.length(); buf.append(value); int len2 = buf.length(); for (int i = len2; i < len1 + length; ++i) { buf.insert(len1, '0'); } }