List of usage examples for java.lang StringBuffer length
@Override public synchronized int length()
From source file:eionet.cr.web.util.columns.SubjectPredicateRefsColumn.java
public String format(Object object) { String result = null;/*from ww w . j a v a 2s .co m*/ if (object != null && object instanceof SubjectDTO && predicateUri != null) { SubjectDTO subjectDTO = (SubjectDTO) object; Collection<ObjectDTO> objects = subjectDTO.getObjectsForSearchResultsDisplay(predicateUri, getLanguages()); if (predicateUri.equals(Predicates.RDFS_LABEL)) { if (objects.isEmpty()) { result = URIUtil.extractURILabel(subjectDTO.getUri(), SubjectDTO.NO_LABEL); } else { result = objectValuesToCSV(objects); } String uriLabel = URIUtil.extractURILabel(subjectDTO.getUri(), SubjectDTO.NO_LABEL); result = uriLabel + " (" + result + ")"; result = buildFactsheetLink(subjectDTO.getUri(), result); } else if (!objects.isEmpty()) { StringBuffer buf = new StringBuffer(); for (ObjectDTO o : objects) { if (buf.length() > 0) { buf.append(", "); } if (o.isLiteral()) { buf.append(o.getValue()); } else { String label = o.getDerviedLiteralValue(); if (label == null) { label = URIUtil.extractURILabel(o.getValue(), SubjectDTO.NO_LABEL); } buf.append(buildFactsheetLink(o.getValue(), label)); } } result = buf.toString(); } } return StringUtils.isBlank(result) ? " " : result; }
From source file:oracle.custom.ui.servlet.LoginServlet.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./* ww w.j a v a 2 s. c o m*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); //System.out.println("User Agent " + request.getHeader("User-Agent")); try (PrintWriter out = response.getWriter()) { // if we come back here after the user is already authenticated it means // that we're looking for OAuth consent if (request.getSession().getAttribute("AUTHENTICATED") != null) { request.getRequestDispatcher("/oauthallowed.jsp").forward(request, response); } try { String tenantName = (String) DomainName.getDomainName(); String endpoint = OpenIdConfiguration.getInstance(tenantName).getAuthzEndpoint(); String clientId = CredentialsList.getCredentials().get(tenantName).getId(); StringBuffer url = request.getRequestURL(); String uri = request.getRequestURI(); String ctx = request.getContextPath(); String base = url.substring(0, url.length() - uri.length() + ctx.length()) + "/"; //String redirecturl = base + "atreturn/"; //String openIdConfig = endpoint + "?client_id=" + clientId + // "&response_type=code&redirect_uri=" + redirecturl + // "&scope=urn:opc:idm:t.user.me+openid+urn:opc:idm:__myscopes__&nonce=" + UUID.randomUUID().toString(); URIBuilder builder = new URIBuilder(endpoint); builder.addParameter("client_id", clientId); builder.addParameter("response_type", "code"); builder.addParameter("redirect_uri", base + "atreturn/"); builder.addParameter("scope", "urn:opc:idm:t.user.me openid urn:opc:idm:__myscopes__"); builder.addParameter("nonce", UUID.randomUUID().toString()); URI redirectUrl = builder.build(); System.out.println("Opend Id URL is " + redirectUrl.toString()); response.sendRedirect(redirectUrl.toString()); } catch (Exception ex) { ex.printStackTrace(); request.getRequestDispatcher("/error.jsp").forward(request, response); } } }
From source file:com.aw.core.db.support.WhereBuilder.java
public StringBuffer getSqlWithAnd() { StringBuffer sql = getSql(); if (sql.length() > 0) { return new StringBuffer(" AND ").append(sql); } else {//w w w .j a v a 2 s .co m return new StringBuffer(); } }
From source file:com.eryansky.common.utils.DateUtil.java
/** * /* w ww .j av a2 s. c om*/ * * @param canlendar * 2009080120090802080808 * @return 2009/08/012009/08/01 08:08:08 */ public static String toString(long canlendar) { try { StringBuffer sbCalendar = new StringBuffer(); sbCalendar.insert(0, canlendar); // ?? if (sbCalendar.length() == 8) { sbCalendar.insert(6, "/"); sbCalendar.insert(4, "/"); } else if (sbCalendar.length() == 14) { sbCalendar.insert(12, ":"); sbCalendar.insert(10, ":"); sbCalendar.insert(8, " "); sbCalendar.insert(6, "/"); sbCalendar.insert(4, "/"); } else { // ? return null; } // ?? return sbCalendar.toString(); } catch (Exception Exp) { // ? return null; } }
From source file:gov.nih.nci.caintegrator.domain.genomic.Platform.java
/** * @return the reporterLists//from ww w . j a va2s .com */ public String getReporterListListing() { StringBuffer listing = new StringBuffer(); for (ReporterList reporterList : getReporterLists()) { if (listing.length() > 0) { listing.append(", "); } listing.append(reporterList.getName()); } return listing.toString(); }
From source file:Main.java
/** * Adds the specified line to the output sequence, performing line wrapping if necessary. * * @param lines The sequence of display lines, must not be <code>null</code>. * @param line The line to add, must not be <code>null</code>. *//*from w w w.j a v a2s . c o m*/ private void toLines(List lines, String line) { int lineIndent = getIndentLevel(line); StringBuffer buf = new StringBuffer(256); String[] tokens = line.split(" +"); for (int i = 0; i < tokens.length; i++) { String token = tokens[i]; if (i > 0) { if (buf.length() + token.length() >= lineLength) { lines.add(buf.toString()); buf.setLength(0); buf.append(repeat(" ", lineIndent * indentSize)); } else { buf.append(' '); } } for (int j = 0; j < token.length(); j++) { char c = token.charAt(j); if (c == '\t') { buf.append(repeat(" ", indentSize - buf.length() % indentSize)); } else if (c == '\u00A0') { buf.append(' '); } else { buf.append(c); } } } lines.add(buf.toString()); }
From source file:com.rightscale.app.dashboard.ShowServerMonitoring.java
public void showGraph(String template, String size, String period) { URI uri = URI.create(template); Map<String, String> query = parseQueryParams(uri); query.put("size", size); query.put("period", period); StringBuffer qstr = new StringBuffer(); for (String key : query.keySet()) { if (qstr.length() > 0) qstr.append('&'); qstr.append(key);/*from w ww . j a v a 2s . c o m*/ qstr.append('='); qstr.append(query.get(key)); } int qmark = template.indexOf('?'); if (qmark < 0) { throw new IllegalArgumentException("URI does not contain query-string marker: " + template); } String prefix = template.substring(0, qmark); //TODO thread safety _selectedGraphUri = URI.create(prefix + '?' + qstr); ContentTransfer.loadImage(this, this, new Handler()); }
From source file:com.aw.core.dao.bean.sql.BeanSqlBuilderUpdateImpl.java
public void delete() { if (interceptor != null) bean = interceptor.onDelete(bean); StringBuffer sqlUpdate = new StringBuffer().append("DELETE FROM ").append(metaInfo.getMainTable()); ArrayList<Object> params = new ArrayList<Object>(); StringBuffer sqlWhere = new StringBuffer(); for (BeanMetaInfo.ColumnInfo columnInfo : metaInfo.getIdColumns()) { if (sqlWhere.length() > 0) sqlWhere.append(" AND "); buildColEqValue(columnInfo, sqlWhere, params); }//from www. j a va 2s . c o m String fullSql = sqlUpdate + " WHERE " + sqlWhere; int rows = execSqlUpdate(fullSql, params.toArray()); if (rows != 1) throw new AWBusinessException("Se esperaba actualizar un registro. Registros actualizados:" + rows); }
From source file:com.tasktop.internal.hp.qc.core.model.comments.mylyn3_8.HtmlStreamTokenizer_m3_8.java
/** * Replaces (in-place) HTML escapes in a StringBuffer with their corresponding characters. * // w w w . j av a2s.c o m * @deprecated use {@link StringEscapeUtils#unescapeHtml(String)} instead */ @Deprecated public static StringBuffer unescape(StringBuffer sb) { int i = 0; // index into the unprocessed section of the buffer int j = 0; // index into the processed section of the buffer while (i < sb.length()) { char ch = sb.charAt(i); if (ch == '&') { int start = i; String escape = null; for (i = i + 1; i < sb.length(); i++) { ch = sb.charAt(i); if (!Character.isLetterOrDigit(ch) && !(ch == '#' && i == (start + 1))) { escape = sb.substring(start + 1, i); break; } } if (i == sb.length() && i != (start + 1)) { escape = sb.substring(start + 1); } if (escape != null) { Character character = parseReference(escape); if (character != null && !((0x0A == character || 0x0D == character || 0x09 == ch) || (character >= 0x20 && character <= 0xD7FF) || (character >= 0xE000 && character <= 0xFFFD) || (character >= 0x10000 && character <= 0x10FFFF))) { // Character is an invalid xml character // http://www.w3.org/TR/REC-xml/#charsets character = null; } if (character != null) { ch = character.charValue(); } else { // not an HTML escape; rewind i = start; ch = '&'; } } } sb.setCharAt(j, ch); i++; j++; } sb.setLength(j); return sb; }
From source file:com.orange.cepheus.cep.controller.AdminController.java
@ExceptionHandler(MethodArgumentNotValidException.class) public ResponseEntity<StatusCode> validationExceptionHandler(HttpServletRequest req, MethodArgumentNotValidException exception) { StringBuffer sb = new StringBuffer(); for (ObjectError error : exception.getBindingResult().getAllErrors()) { if (sb.length() != 0) { sb.append(", "); }/*from w w w . j a v a 2 s.c o m*/ sb.append(error.getDefaultMessage()); } logger.error("Configuration validation error: {}", sb.toString()); StatusCode statusCode = new StatusCode(); statusCode.setCode("400"); statusCode.setReasonPhrase("Configuration validation error"); statusCode.setDetail(sb.toString()); return new ResponseEntity<>(statusCode, HttpStatus.BAD_REQUEST); }