List of usage examples for java.lang StringBuffer substring
@Override public synchronized String substring(int start, int end)
From source file:org.squale.squalix.tools.clearcase.task.ClearCaseTask.java
/** * Cette mthode modifie le paramtre <code>view_path</code> de la <code> * HashMap</code> des paramtres/*from www .j a v a 2s.c o m*/ * temporaires de l'objet <code> * ProjectBO</code>. * * @throws Exception exception lors du traitement. */ private void modifyTempMap() throws Exception { /* * on rcupre le chemin du dossier dans lequel ont t mis les fichiers de la vue, et on met cette valeur dans * la hashmap de paramtres. */ StringBuffer buf = new StringBuffer(mConfiguration.getUmountViewCommand().trim()); int length = buf.length(); String viewPath = buf.substring(buf.lastIndexOf(ClearCaseConfiguration.SPACE) + 1, length); getData().putData(TaskData.VIEW_PATH, viewPath); }
From source file:org.dataone.proto.trove.mn.rest.base.AbstractWebController.java
protected String getRequestPID(HttpServletRequest request, String delimiter) throws DecoderException { StringBuffer urlBuffer = request.getRequestURL(); int objectStart = urlBuffer.indexOf(delimiter); String pid = urlBuffer.substring(objectStart + delimiter.length(), urlBuffer.length()); String decodedPID = null;//from w ww . j a v a2 s. co m try { decodedPID = urlCodec.decode(pid, "UTF-8"); } catch (UnsupportedEncodingException e) { decodedPID = urlCodec.decode(pid); } logger.info("decoding GUID/PID: " + pid + " to " + decodedPID); return decodedPID; }
From source file:org.dspace.app.cris.configuration.ColumnVisualizationConfiguration.java
public String getHTMLContent(BrowsableDSpaceObject dso) { StringBuffer sb = new StringBuffer(); for (String md : metadata) { String[] split = md.split("\\."); DCValue[] values = dso.getMetadata(split[0], split[1], split.length > 2 ? split[2] : null, Item.ANY); for (DCValue v : values) { sb.append(v.value).append(", "); }/*w w w .j a v a 2 s. c o m*/ } return sb.length() > 0 ? sb.substring(0, sb.length() - 2) : null; }
From source file:com.springsource.hq.plugin.tcserver.plugin.serverconfig.FileUtility.java
private void printArray(String[] array) { StringBuffer buffer = new StringBuffer(); buffer.append("["); for (String element : array) { buffer.append(element + ", "); }/*from w w w. j a va 2 s.c o m*/ buffer.append("]"); buffer.substring(0, buffer.length() - 3); LOGGER.debug(buffer.toString()); }
From source file:com.all.backend.web.controller.LoginServerController.java
@RequestMapping(method = POST, value = "/password") @ResponseBody//from w w w . j a v a 2s .c om public String resetRequest(@RequestBody String mail, HttpServletRequest request) { log.info("\nACTION:ForgotPasswordRequest"); StringBuffer requestURL = request.getRequestURL(); String url = requestURL.substring(0, requestURL.lastIndexOf("/") + 1) + "reset/"; String forgotPasswordResult = userService.createPasswordResetRequest(mail, url); log.debug("forgotPasswordResult: " + forgotPasswordResult); String result = ""; String[] resultAsarray = forgotPasswordResult.split(";"); if (resultAsarray.length == 2) { result = resultAsarray[0]; url = resultAsarray[1]; PendingEmail pendingEmail = createPasswordPendingEmail(url, mail); BackendServiceHelper.queue(emailService, BackendConstants.SEND_RESET_PASSWORD_EMAIL_REQUEST_TYPE, pendingEmail); } else { result = forgotPasswordResult; } return result; }
From source file:hydrograph.ui.graph.command.ComponentPasteCommand.java
private String getPrefix(Object node) { String currentName = ((Component) node).getComponentLabel().getLabelContents(); String prefix = currentName;/*from www . j a v a 2 s . c om*/ StringBuffer buffer = new StringBuffer(currentName); try { if (buffer.lastIndexOf(UNDERSCORE) != -1 && (buffer.lastIndexOf(UNDERSCORE) != buffer.length())) { String substring = StringUtils .trim(buffer.substring(buffer.lastIndexOf(UNDERSCORE) + 1, buffer.length())); if (StringUtils.isNumeric(substring)) { prefix = buffer.substring(0, buffer.lastIndexOf(UNDERSCORE)); } } } catch (Exception exception) { LOGGER.warn("Cannot process component name for detecting prefix : ", exception.getMessage()); } return prefix; }
From source file:net.alchemiestick.katana.winehqappdb.WineSearch.java
@Override protected void onPostExecute(StringBuffer res) { String str = "Processing responce! (" + Long.valueOf(res.length()).toString() + " bytes)"; tvlist.clear();// w w w . j a v a 2s . c o m // tvlist.add(str); int istart = res.indexOf("<table"); int iend = res.indexOf("</table>", istart); String tab; try { tab = res.substring(istart, iend); } catch (StringIndexOutOfBoundsException e) { tvlist.add(new str_link("No Match Found", "")); return; } iend = 0; String link; for (int i = 1; iend < tab.lastIndexOf("</td>"); i++) { istart = tab.indexOf("<tr class=\"color" + Long.valueOf(i % 2).toString() + "\">", iend); istart = tab.indexOf("<td>", istart) + 6; istart = tab.indexOf("href=", istart) + 6; iend = tab.indexOf("\"", istart); link = tab.substring(istart, iend); istart = tab.indexOf(">", istart) + 1; iend = tab.indexOf("</a>", istart); str = tab.substring(istart, iend); iend = tab.indexOf("</tr>", istart); tvlist.add(new str_link(str, link)); } }
From source file:org.apache.lucene.analysis.de.GermanStemmer.java
/** * suffix stripping (stemming) on the current term. The stripping is reduced * to the seven "base" suffixes "e", "s", "n", "t", "em", "er" and * "nd", * from which all regular suffixes are build of. The simplification causes * some overstemming, and way more irregular stems, but still provides * unique. discriminators in the most of those cases. The algorithm is * context free, except of the length restrictions. *///from w ww. j a va2s . com private void strip(StringBuffer buffer) { boolean doMore = true; while (doMore && buffer.length() > 3) { if ((buffer.length() + substCount > 5) && buffer.substring(buffer.length() - 2, buffer.length()).equals("nd")) { buffer.delete(buffer.length() - 2, buffer.length()); } else if ((buffer.length() + substCount > 4) && buffer.substring(buffer.length() - 2, buffer.length()).equals("em")) { buffer.delete(buffer.length() - 2, buffer.length()); } else if ((buffer.length() + substCount > 4) && buffer.substring(buffer.length() - 2, buffer.length()).equals("er")) { buffer.delete(buffer.length() - 2, buffer.length()); } else if (buffer.charAt(buffer.length() - 1) == 'e') { buffer.deleteCharAt(buffer.length() - 1); } else if (buffer.charAt(buffer.length() - 1) == 's') { buffer.deleteCharAt(buffer.length() - 1); } else if (buffer.charAt(buffer.length() - 1) == 'n') { buffer.deleteCharAt(buffer.length() - 1); } // "t" occurs only as suffix of verbs. else if (buffer.charAt(buffer.length() - 1) == 't') { buffer.deleteCharAt(buffer.length() - 1); } else { doMore = false; } } }
From source file:gtu._work.ui.LoadJspFetchJavascriptUI.java
private String writeScript(File file) throws IOException { StringBuffer sb = new StringBuffer(FileUtils.readFileToString(file, "utf8")); StringBuffer sb2 = new StringBuffer(); for (;;) {/* w w w. java 2 s . com*/ Matcher m1 = javascriptStart.matcher(sb.toString()); Matcher m2 = javascriptEnd.matcher(sb.toString()); if (m1.find() && m2.find()) { sb2.append(sb.substring(m1.start(), m2.end()) + "\n\n"); sb.delete(m1.start(), m2.end()); } else { break; } } return sb2.toString(); }
From source file:com.acc.conv.Oauth2AccessTokenConverter.java
@Override public void marshal(final Object source, final HierarchicalStreamWriter writerOrig, final MarshallingContext context) { final OAuth2AccessToken token = (OAuth2AccessToken) source; final ExtendedHierarchicalStreamWriter writer = (ExtendedHierarchicalStreamWriter) writerOrig .underlyingWriter();/*from w w w .j ava 2 s . c o m*/ writer.startNode(OAuth2AccessToken.ACCESS_TOKEN, String.class); writer.setValue(formattedValue(token.getValue())); writer.endNode(); writer.startNode(OAuth2AccessToken.TOKEN_TYPE, String.class); writer.setValue(formattedValue(token.getTokenType())); writer.endNode(); final OAuth2RefreshToken refreshToken = token.getRefreshToken(); if (refreshToken != null) { writer.startNode(OAuth2AccessToken.REFRESH_TOKEN, String.class); writer.setValue(formattedValue(refreshToken.getValue())); writer.endNode(); } final Date expiration = token.getExpiration(); if (expiration != null) { final long now = System.currentTimeMillis(); writer.startNode(OAuth2AccessToken.EXPIRES_IN, Integer.class); writer.setValue(String.valueOf((expiration.getTime() - now) / 1000)); writer.endNode(); } final Set<String> scope = token.getScope(); if (scope != null && !scope.isEmpty()) { final StringBuffer scopes = new StringBuffer(); for (final String s : scope) { Assert.hasLength(s, "Scopes cannot be null or empty. Got " + scope); scopes.append(s); scopes.append(' '); } writer.startNode(OAuth2AccessToken.SCOPE, String.class); writer.setValue(formattedValue(scopes.substring(0, scopes.length() - 1))); writer.endNode(); } final Map<String, Object> additionalInformation = token.getAdditionalInformation(); for (final String key : additionalInformation.keySet()) { writer.startNode(key, String.class); writer.setValue(formattedValue(String.valueOf(additionalInformation.get(key)))); writer.endNode(); } }