List of usage examples for org.apache.commons.lang StringUtils removeEnd
public static String removeEnd(String str, String remove)
Removes a substring only if it is at the end of a source string, otherwise returns the source string.
From source file:info.magnolia.cms.util.SimpleUrlPattern.java
/** * Compile a regexp pattern handling <code>*</code> and <code>?</code> chars. * @param string input string//from w w w . j a v a 2 s .co m * @return a RegExp pattern */ public SimpleUrlPattern(String string) { this.length = StringUtils.removeEnd(string, "*").length(); this.pattern = Pattern.compile(getEncodedString(string), Pattern.DOTALL); this.patternString = string; }
From source file:com.hangum.tadpole.rdb.core.editors.main.utils.SQLTextUtil.java
/** * ?? ? ./*w w w . jav a 2 s. com*/ * @param strWord * @return */ public static String removeSpecialChar(String strWord) { if (strWord == null) return ""; strWord = strWord.replace(";", ""); strWord = StringUtils.removeStart(strWord, ","); strWord = StringUtils.removeEnd(strWord, ","); strWord = StringUtils.removeStart(strWord, "("); strWord = StringUtils.removeEnd(strWord, ")"); return strWord; }
From source file:com.fortify.bugtracker.tgt.octane.connection.OctaneRestConnectionConfig.java
@Override protected void setBaseUrl(URI baseUrl) { String baseUrlString = baseUrl.toASCIIString(); baseUrlString = StringUtils.removeEnd(baseUrlString, "/"); baseUrlString = StringUtils.removeEnd(baseUrlString, "ui"); super.setBaseUrl(URI.create(baseUrlString)); }
From source file:info.magnolia.content2bean.impl.DescriptorFileBasedTypeMapping.java
protected void processFile(String fileName) { Properties props = new Properties(); InputStream stream = null;/*from w w w . j ava2 s . c o m*/ try { stream = ClasspathResourcesUtil.getStream(fileName); props.load(stream); } catch (IOException e) { log.error("can't read collection to bean information " + fileName, e); } IOUtils.closeQuietly(stream); String className = StringUtils.replaceChars(fileName, File.separatorChar, '.'); className = StringUtils.removeStart(className, "."); className = StringUtils.removeEnd(className, ".content2bean"); try { Class<?> typeClass = Classes.getClassFactory().forName(className); TypeDescriptor typeDescriptor = processProperties(typeClass, props); addTypeDescriptor(typeClass, typeDescriptor); } catch (Exception e) { log.error("can't instantiate type descriptor for " + className, e); } }
From source file:com.github.rnewson.couchdb.lucene.couchdb.View.java
private String trim(final String fun) { String result = fun; result = StringUtils.trim(result);//from w w w .ja va 2 s. c o m result = StringUtils.removeStart(result, "\""); result = StringUtils.removeEnd(result, "\""); return result; }
From source file:com.cognifide.actions.msg.replication.ReplicationMessageProducer.java
static String createPath(String relPath, String actionRoot, String randomPath) { final String path; if (StringUtils.startsWith(relPath, "/")) { path = relPath;/*w w w. j av a 2 s .com*/ } else { final DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); path = String.format("%s%s/%s", actionRoot, dateFormat.format(new Date()), relPath); } if (path.endsWith("/*")) { long now = new Date().getTime(); return String.format("%s%s/%s", StringUtils.removeEnd(path, "*"), generateRandomPathPart(randomPath), now); } else { return path; } }
From source file:com.sugaronrest.restapicalls.QueryBuilder.java
/** * Build the where clause part of a SugarCRM query. * * @param predicates The json predicates. * @return The formatted query./*from ww w . jav a 2s . c o m*/ */ public static String getWhereClause(List<JsonPredicate> predicates) { if ((predicates == null) || (predicates.size() == 0)) { return StringUtils.EMPTY; } StringBuilder queryBuilder = new StringBuilder(); String subQuery = StringUtils.EMPTY; for (JsonPredicate predicate : predicates) { switch (predicate.operator) { case Equal: subQuery = predicate.isNumeric ? String.format("%s = %s", predicate.jsonName, predicate.value) : String.format("%s = '%s'", predicate.jsonName, predicate.value); break; case GreaterThan: subQuery = predicate.isNumeric ? String.format("%s > %s", predicate.jsonName, predicate.value) : String.format("%s > '%s'", predicate.jsonName, predicate.value); break; case GreaterThanOrEqualTo: subQuery = predicate.isNumeric ? String.format("%s >= %s", predicate.jsonName, predicate.value) : String.format("%s >= '%s'", predicate.jsonName, predicate.value); break; case LessThan: subQuery = predicate.isNumeric ? String.format("%s < %s", predicate.jsonName, predicate.value) : String.format("%s < '%s'", predicate.jsonName, predicate.value); break; case LessThanOrEqualTo: subQuery = predicate.isNumeric ? String.format("%s <= %s", predicate.jsonName, predicate.value) : String.format("%s <= '%s'", predicate.jsonName, predicate.value); break; case Contains: subQuery = predicate.jsonName + " LIKE '%" + predicate.value + "%'"; break; case StartsWith: subQuery = predicate.jsonName + " LIKE '" + predicate.value + "%'"; break; case EndsWith: subQuery = predicate.jsonName + " LIKE '%" + predicate.value + "'"; break; case Between: subQuery = predicate.isNumeric ? String.format("%s BETWEEN %s AND %s", predicate.jsonName, predicate.fromValue, predicate.toValue) : String.format("%s BETWEEN '%s' AND '%s'", predicate.jsonName, predicate.fromValue, predicate.toValue); break; case WhereIn: subQuery = String.format("%s IN (%s)", predicate.jsonName, predicate.value); break; } queryBuilder.append(subQuery); queryBuilder.append(" AND "); } String query = queryBuilder.toString(); if (!StringUtils.isNotBlank(query)) { return StringUtils.EMPTY; } query = StringUtils.removeEnd(query.trim(), "AND"); query = " " + query.trim() + " "; return query; }
From source file:com.dp2345.plugin.oss.OssController.java
/** * /*from w ww . j a v a 2 s . c o m*/ */ @RequestMapping(value = "/update", method = RequestMethod.POST) public String update(String accessId, String accessKey, String bucketName, String urlPrefix, @RequestParam(defaultValue = "false") Boolean isEnabled, Integer order, RedirectAttributes redirectAttributes) { PluginConfig pluginConfig = ossPlugin.getPluginConfig(); pluginConfig.setAttribute("accessId", accessId); pluginConfig.setAttribute("accessKey", accessKey); pluginConfig.setAttribute("bucketName", bucketName); pluginConfig.setAttribute("urlPrefix", StringUtils.removeEnd(urlPrefix, "/")); pluginConfig.setIsEnabled(isEnabled); pluginConfig.setOrder(order); pluginConfigService.update(pluginConfig); addFlashMessage(redirectAttributes, SUCCESS_MESSAGE); return "redirect:/admin/storage_plugin/list.jhtml"; }
From source file:adalid.util.meta.CodeAnalyzerTreeVisitor.java
private void info(String string) { string = StringUtils.removeEnd(string, CM); // string = StringUtils.remove(string, NL); string = StringUtils.replace(string, EOL, SP); // "<n>" // string = StringUtils.remove(string, TB); string = StringUtils.replace(string, TAB, SP); // "<t>" string = StringUtils.remove(string, SP + SP); string = StringUtils.trimToEmpty(string); logger.info(tabs() + string);/*from w w w .j a va 2 s. c o m*/ }
From source file:com.seyren.core.service.notification.SlackNotificationService.java
@Override public void sendNotification(Check check, Subscription subscription, List<Alert> alerts) throws NotificationFailedException { String token = seyrenConfig.getSlackToken(); String channel = subscription.getTarget(); String username = seyrenConfig.getSlackUsername(); String iconUrl = seyrenConfig.getSlackIconUrl(); List<String> emojis = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults().split(seyrenConfig.getSlackEmojis())); String url = String.format("%s/api/chat.postMessage", baseUrl); HttpClient client = HttpClientBuilder.create().useSystemProperties().build(); HttpPost post = new HttpPost(url); post.addHeader("accept", "application/json"); List<BasicNameValuePair> parameters = new ArrayList<BasicNameValuePair>(); parameters.add(new BasicNameValuePair("token", token)); parameters.add(new BasicNameValuePair("channel", StringUtils.removeEnd(channel, "!"))); parameters.add(new BasicNameValuePair("text", formatContent(emojis, check, subscription, alerts))); parameters.add(new BasicNameValuePair("username", username)); parameters.add(new BasicNameValuePair("icon_url", iconUrl)); try {/*from w w w . j ava 2s . c o m*/ post.setEntity(new UrlEncodedFormEntity(parameters)); if (LOGGER.isDebugEnabled()) { LOGGER.info("> parameters: {}", parameters); } HttpResponse response = client.execute(post); if (LOGGER.isDebugEnabled()) { LOGGER.info("> parameters: {}", parameters); LOGGER.debug("Status: {}, Body: {}", response.getStatusLine(), new BasicResponseHandler().handleResponse(response)); } } catch (Exception e) { LOGGER.warn("Error posting to Slack", e); } finally { post.releaseConnection(); HttpClientUtils.closeQuietly(client); } }