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:ips1ap101.lib.core.db.util.DBUtils.java
/** * Busca el nombre del constraint en el mensaje que envia el RDBMS cuando se produce un conflicto * * @param message Cadena correspondiente al mensaje que envia el RDBMS * @param status Entero correspondiente al tipo de conflicto (cualquiera de las constantes ROW_CONFLICT de SyncResolver) * @return Si se consigue, el nombre del constraint; de lo contratio retorna null *///from w ww .j a va2 s . com public static String getConstraintMessageKey(String message, int status) { String trimmed = StringUtils.trimToNull(message); if (trimmed != null) { trimmed = trimmed.replaceAll("[^a-zA-Z0-9_]", " "); trimmed = trimmed.trim().toLowerCase(); String[] tokens = StringUtils.split(trimmed); if (tokens != null && tokens.length > 0) { String key, string; for (int i = 0; i < tokens.length; i++) { key = tokens[i]; if (key.endsWith(SUFIJO) && StringUtils.indexOfAny(key, INFIJOS) > 0) { key = StringUtils.removeEnd(key, SUFIJO); if (key.contains("_fk_")) { key += status == 1 ? ".1" : ".2"; } string = BundleMensajes.getString(key); return isKey(string) ? string : "<" + key + ">"; } } } } return null; }
From source file:de.fhg.iais.asc.transformer.jdom.handler.XmlFieldStripper.java
private static String stripText(final String input) { String result = input;/*www .ja v a 2 s . c o m*/ result = StringUtils.replace(result, "\\s", " "); result = StringUtils.replace(result, " {2,}", " "); result = StringUtils.replace(result, " .", "."); result = StringUtils.replace(result, " ,", ","); result = StringUtils.replace(result, " ;", ";"); result = StringUtils.removeEnd(result, ","); result = StringUtils.removeEnd(result, ";"); result = result.trim(); return result; }
From source file:com.microsoft.alm.plugin.external.commands.TfVersionCommand.java
@Override public ToolVersion parseOutput(final String stdout, final String stderr) { throwIfError(stderr);//from w w w . j ava 2 s .c o m final String[] lines = getLines(stdout); for (final String line : lines) { if (StringUtils.isNotEmpty(line)) { final int start = line.toLowerCase().indexOf(VERSION_PREFIX); if (start >= 0) { return new ToolVersion( StringUtils.removeEnd(line.substring(start + VERSION_PREFIX.length()), ")")); } } } return ToolVersion.UNKNOWN; }
From source file:com.canoo.webtest.util.WebtestEmbeddingUtil.java
/** * Copies WebTest resources (ie webtest.xml, tools/*, the XSLs, CSSs and pictures, ...) package in WebTest jar file * into the provide folder. Indeed different Ant tasks can't work with resources in a jar file. * @param targetFolder the folder in which resources should be copied to * @throws java.io.IOException if the resources can be accessed or copied *//*from w w w . j a v a 2 s .com*/ static void copyWebTestResources(final File targetFolder) throws IOException { final String resourcesPrefix = "com/canoo/webtest/resources/"; final URL webtestXmlUrl = WebtestEmbeddingUtil.class.getClassLoader() .getResource(resourcesPrefix + "webtest.xml"); if (webtestXmlUrl == null) { throw new IllegalStateException("Can't find resource " + resourcesPrefix + "webtest.xml"); } else if (webtestXmlUrl.toString().startsWith("jar:file")) { final String urlJarFileName = webtestXmlUrl.toString().replaceFirst("^jar:file:([^\\!]*).*$", "$1"); final String jarFileName = URLDecoder.decode(urlJarFileName, Charset.defaultCharset().name()); final JarFile jarFile = new JarFile(jarFileName); final String urlPrefix = StringUtils.removeEnd(webtestXmlUrl.toString(), "webtest.xml"); for (final Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements();) { final JarEntry jarEntry = entries.nextElement(); if (jarEntry.getName().startsWith(resourcesPrefix)) { final String relativeName = StringUtils.removeStart(jarEntry.getName(), resourcesPrefix); final URL url = new URL(urlPrefix + relativeName); final File targetFile = new File(targetFolder, relativeName); FileUtils.forceMkdir(targetFile.getParentFile()); FileUtils.copyURLToFile(url, targetFile); } } } else if (webtestXmlUrl.toString().startsWith("file:")) { // we're probably developing and/or have a custom version of the resources in classpath final File webtestXmlFile = FileUtils.toFile(webtestXmlUrl); final File resourceFolder = webtestXmlFile.getParentFile(); FileUtils.copyDirectory(resourceFolder, targetFolder); } else { throw new IllegalStateException( "Resource " + resourcesPrefix + "webtest.xml is not in a jar file: " + webtestXmlUrl); } }
From source file:com.jayway.jaxrs.hateoas.web.RequestContextFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { final HttpServletRequest servletRequest = (HttpServletRequest) request; String requestURI = servletRequest.getRequestURI(); requestURI = StringUtils.removeStart(requestURI, servletRequest.getContextPath() + servletRequest.getServletPath()); String baseURL = StringUtils.removeEnd(servletRequest.getRequestURL().toString(), requestURI); UriBuilder uriBuilder = UriBuilder.fromUri(baseURL); RequestContext ctx = new RequestContext(uriBuilder, servletRequest.getHeader(RequestContext.HATEOAS_OPTIONS_HEADER)); RequestContext.setRequestContext(ctx); try {// w w w .j ava2 s . c o m chain.doFilter(request, response); } finally { RequestContext.clearRequestContext(); } }
From source file:com.intel.cosbench.driver.iterator.NumericNameIterator.java
@Override public String next(String curr) { int value;//from w w w .ja va 2 s.co m if (StringUtils.isEmpty(curr)) { if ((value = iterator.next(0)) <= 0) return null; return StringUtils.join(new Object[] { prefix, value, suffix }); } curr = StringUtils.removeStart(curr, prefix); curr = StringUtils.removeEnd(curr, suffix); if ((value = iterator.next(Integer.parseInt(curr))) <= 0) return null; return StringUtils.join(new Object[] { prefix, value, suffix }); }
From source file:com.intuit.tank.vm.common.util.ValidationUtil.java
public static final String removeAllVariableIdentifier(String key) { key = removeIdentifier(key, identifierChar); key = StringUtils.removeStart(key, "#"); key = StringUtils.removeStart(key, "{"); return StringUtils.removeEnd(key, "}"); }
From source file:com.yoncabt.ebr.executor.sql.SQLReport.java
@Override public ReportDefinition loadDefinition(File file) throws IOException { setFile(file);//from w w w . jav a 2 s. c o m String jsonFilePath = StringUtils.removeEnd(file.getAbsolutePath(), ".sql") + ".ebr.json"; File jsonFile = new File(jsonFilePath); return super.loadDefinition(file, jsonFile); }
From source file:com.antsdb.saltedfish.sql.mysql.Load_data_infile_stmtGenerator.java
@Override public Instruction gen(GeneratorContext ctx, Load_data_infile_stmtContext rule) throws OrcaException { String filename = rule.file_name().getText(); filename = StringUtils.removeStart(filename, "\'"); filename = StringUtils.removeEnd(filename, "\'"); ObjectName tableName = TableName.parse(ctx, rule.table_name_()); LoadCsv instru = new LoadCsv(new File(filename), tableName); return instru; }
From source file:com.bluexml.xforms.generator.forms.renderable.common.association.AbstractRenderable.java
/** * Compute node set actions.//from ww w. ja va 2 s . com * * @param path * the path * * @return the string */ protected String computeNodeSetActions(String path) { return StringUtils.removeEnd(path, "/"); }