List of usage examples for org.apache.commons.lang StringUtils substringBeforeLast
public static String substringBeforeLast(String str, String separator)
Gets the substring before the last occurrence of a separator.
From source file:edu.mayo.cts2.framework.plugin.service.bprdf.util.UriUtils.java
/** * Gets the namespace name tuple./* w w w. ja v a2s . co m*/ * The first element in the array will be the name * The seconed element in the array wil be the namespace uri * * @param uri the uri * @return the namespace name tuple */ public static String[] getNamespaceNameTuple(String uri) { String name; String namespace; int splitPoint = Util.splitNamespace(uri); if (splitPoint == uri.length()) { name = StringUtils.substringAfterLast(uri, "/"); namespace = StringUtils.substringBeforeLast(uri, "/") + "/"; } else { namespace = uri.substring(0, splitPoint); name = uri.substring(splitPoint); } if (StringUtils.isBlank(name) || StringUtils.isBlank(namespace)) { throw new UriParseException(uri); } else { return new String[] { name, namespace }; } }
From source file:com.example.NoJcrPropertyModel.java
private String createLabel(final String path) { String result = StringUtils.substringAfterLast(path, "/"); result = StringUtils.substringBeforeLast(result, "."); return WordUtils.capitalize(result); }
From source file:info.magnolia.cms.util.PathUtil.java
public static String getFolder(String path) { String res;//from ww w. j av a 2 s. c om res = StringUtils.substringBeforeLast(path, "/"); //$NON-NLS-1$ if (StringUtils.isEmpty(res)) { return "/"; //$NON-NLS-1$ } return res; }
From source file:hudson.plugins.sonar.client.HttpClient.java
public String getHttp(String url, String usernameOrToken, String password) throws Exception { String baseUrl = StringUtils.substringBeforeLast(url, "/"); String path = StringUtils.substringAfterLast(url, "/"); HttpConnector httpConnector = HttpConnector.newBuilder().userAgent("Scanner for Jenkins").url(baseUrl) .credentials(usernameOrToken, password).build(); WsResponse response = httpConnector.call(new GetRequest(path)); return response.content(); }
From source file:com.alibaba.cobar.client.router.rules.ibatis.IBatisNamespaceRule.java
public boolean isDefinedAt(IBatisRoutingFact routingFact) { Validate.notNull(routingFact);// www . j a v a 2s.c om String namespace = StringUtils.substringBeforeLast(routingFact.getAction(), "."); return StringUtils.equals(namespace, getTypePattern()); }
From source file:com.haulmont.cuba.core.sys.dbupdate.ScriptResource.java
public ScriptResource(Resource resource) { try {/*from ww w . jav a2 s .c o m*/ this.resource = resource; this.name = resource.getFilename(); this.path = URLEncodeUtils.decodeUtf8(resource.getURL().getPath()); this.dir = StringUtils.substringBeforeLast(this.path, "/"); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:ips1ap101.lib.base.BaseBundle.java
public static String getLimiteFilasFuncionExport(String key) { String string = getString(key, LIMITE_FILAS_FUNCION_EXPORT); if (string == null) { String dominio = StringUtils.substringBeforeLast(key, "."); if (key.equals(dominio)) { } else {/*w ww .j av a2 s . co m*/ string = getString(dominio, LIMITE_FILAS_FUNCION_EXPORT); } } if (string == null) { string = getString(DEFAULT, LIMITE_FILAS_FUNCION_EXPORT); } return string; }
From source file:com.alibaba.cobar.client.router.rules.ibatis.IBatisNamespaceShardingRule.java
public boolean isDefinedAt(IBatisRoutingFact routingFact) { Validate.notNull(routingFact);//from w ww . java 2 s . c om String namespace = StringUtils.substringBeforeLast(routingFact.getAction(), "."); boolean matches = StringUtils.equals(namespace, getTypePattern()); if (matches) { try { Map<String, Object> vrs = new HashMap<String, Object>(); vrs.putAll(getFunctionMap()); vrs.put("$ROOT", routingFact.getArgument()); // add top object reference for expression VariableResolverFactory vrfactory = new MapVariableResolverFactory(vrs); if (MVEL.evalToBoolean(getAttributePattern(), routingFact.getArgument(), vrfactory)) { return true; } } catch (Throwable t) { logger.info("failed to evaluate attribute expression:'{}' with context object:'{}'\n{}", new Object[] { getAttributePattern(), routingFact.getArgument(), t }); } } return false; }
From source file:com.adobe.ac.pmd.rules.style.ImportFromSamePackageRule.java
@Override protected final void findViolations(final IPackage packageNode) { final String packageName = packageNode.getName(); for (final IParserNode importNode : packageNode.getImports()) { if (StringUtils.substringBeforeLast(importNode.toString(), ".").equals(packageName)) { addViolation(importNode);/*from ww w . j av a2 s .c om*/ } } }
From source file:com.github.ipaas.ideploy.agent.util.ZipUtil.java
/** * /*w ww . jav a2 s . c o m*/ * @param srcFile ? * @param targetDir * @throws Exception */ public static void unZip(String zipFile, String targetDir) throws Exception { ZipFile zipfile = new ZipFile(zipFile); try { Enumeration<ZipEntry> entries = zipfile.getEntries(); if (entries == null || !entries.hasMoreElements()) { return; } // FileUtils.forceMkdir(new File(targetDir)); // ?? while (entries.hasMoreElements()) { ZipEntry zipEntry = entries.nextElement(); String fname = zipEntry.getName(); // if (zipEntry.isDirectory()) { String fpath = FilenameUtils.normalize(targetDir + "/" + fname); FileUtils.forceMkdir(new File(fpath)); continue; } // ? if (StringUtils.contains(fname, "/")) { String tpath = StringUtils.substringBeforeLast(fname, "/"); String fpath = FilenameUtils.normalize(targetDir + "/" + tpath); FileUtils.forceMkdir(new File(fpath)); } // ? InputStream input = null; OutputStream output = null; try { input = zipfile.getInputStream(zipEntry); String file = FilenameUtils.normalize(targetDir + "/" + fname); output = new FileOutputStream(file); IOUtils.copy(input, output); } finally { IOUtils.closeQuietly(input); IOUtils.closeQuietly(output); } } } finally { ZipFile.closeQuietly(zipfile); } }