List of usage examples for org.apache.commons.lang StringUtils lastIndexOf
public static int lastIndexOf(String str, String searchStr)
Finds the last index within a String, handling null
.
From source file:org.vulpe.controller.commons.VulpeBaseControllerConfig.java
/** * * @param detail/*from w ww . j av a 2s . c om*/ * @return */ public VulpeBaseDetailConfig getDetailConfig(final String detail) { VulpeBaseDetailConfig detailConfig = getDetail(detail); if (detailConfig != null) { return detailConfig; } final String name = Functions.clearChars(Functions.replaceSequence(detail, "[", "]", ""), "."); detailConfig = getDetail(name); if (detailConfig != null) { return detailConfig; } String propertyName = detail; if (StringUtils.lastIndexOf(detail, '.') >= 0) { propertyName = detail.substring(StringUtils.lastIndexOf(detail, '.') + 1); } return getDetail(propertyName); }
From source file:org.vulpe.controller.commons.VulpeBaseControllerConfig.java
public String getParentName(final String detail) { final int position = StringUtils.lastIndexOf(detail, "."); return position == -1 ? detail : StringUtils.substring(detail, 0, position); }
From source file:org.vulpe.controller.commons.VulpeBaseDetailConfig.java
public void setupDetail(final VulpeBaseControllerConfig config, final DetailConfig detail) { if (detail == null) { return;/*w w w. jav a 2 s . co m*/ } if (!detail.name().equals("")) { this.name = detail.name(); this.propertyName = detail.name(); setSimpleName(); } if (!detail.propertyName().equals("")) { this.propertyName = detail.propertyName(); setSimpleName(); } this.viewPath = config.getViewPath().substring(0, StringUtils.lastIndexOf(config.getViewPath(), '/')) .concat("/").concat(getBaseName()).concat(Layout.SUFFIX_JSP_DETAIL); if (StringUtils.isEmpty(getTitleKey()) && StringUtils.isNotEmpty(getPropertyName())) { setTitleKey(config.getTitleKey().concat(".").concat(getBaseName())); } if (detail.despiseFields().length > 0) { this.despiseFields = detail.despiseFields(); } if (detail.startNewDetails() > 0) { this.setStartNewDetails(detail.startNewDetails()); } if (detail.newDetails() > 0) { this.setNewDetails(detail.newDetails()); } this.quantiity = detail.quantity(); if (!detail.parentDetailName().equals("")) { if (config.getDetail(detail.parentDetailName()) == null) { config.getDetails().add(new VulpeBaseDetailConfig(detail.parentDetailName())); } this.parentDetailConfig = (VulpeBaseDetailConfig) config.getDetail(detail.parentDetailName()); this.parentDetailConfig.getSubDetails().add(this); } final VulpeView view = VulpeConfigHelper.getApplicationConfiguration().view(); this.addNewDetailsOnTop = detail.reverse() ? !view.addNewDetailsOnTop() : view.addNewDetailsOnTop(); this.notControlView = detail.notControlView(); this.showAsAccordion = detail.showAsArccodion(); this.pageSize = detail.pageSize(); }
From source file:org.vulpe.controller.commons.VulpeBaseDetailConfig.java
private void setSimpleName() { if (StringUtils.isNotEmpty(this.propertyName)) { if (StringUtils.lastIndexOf(this.propertyName, '.') >= 0) { this.simpleName = this.propertyName.substring(StringUtils.lastIndexOf(this.propertyName, '.') + 1); } else {/*from w w w. j a v a 2s .c om*/ this.simpleName = this.propertyName; } } }
From source file:org.vulpe.fox.dao.DecoratedDAO.java
public String getSuperclassSimpleName() { return StringUtils.substring(superclassName, StringUtils.lastIndexOf(superclassName, ".") + 1); }
From source file:org.vulpe.fox.dao.DecoratedDAO.java
public String getDaoSuperclassSimpleName() { return StringUtils.substring(daoSuperclassName, StringUtils.lastIndexOf(daoSuperclassName, ".") + 1); }
From source file:org.wso2.carbon.appfactory.core.registry.AppFacRegistryResourceService.java
/** * Remove the cache of the given path from registry * This method is copied from governance component in location "https://github.com/wso2-dev/carbon-governance/blob/ * master/components/governance/org.wso2.carbon.governance.custom.lifecycles.checklist/src/main/java/org/wso2/carbon/ * governance/custom/lifecycles/checklist/util/LifecycleBeanPopulator.java" * * @param resourcePath the resource path to be cleared from the cache * @throws AppFactoryException/*from w ww . j a v a 2 s. com*/ */ public void removeRegistryCache(String resourcePath) throws AppFactoryException { Registry registry = getRegistry(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); Cache<RegistryCacheKey, GhostResource> cache = RegistryUtils .getResourceCache(RegistryConstants.REGISTRY_CACHE_BACKED_ID); RegistryCacheKey cacheKey; if (registry.getRegistryContext().getRemoteInstances().size() > 0) { for (Mount mount : registry.getRegistryContext().getMounts()) { if (resourcePath.startsWith(mount.getPath())) { for (RemoteConfiguration configuration : registry.getRegistryContext().getRemoteInstances()) { DataBaseConfiguration databaseConfiguration = registry.getRegistryContext() .getDBConfig(configuration.getDbConfig()); String connectionId = (databaseConfiguration.getUserName() != null ? databaseConfiguration.getUserName().split("@")[0] : databaseConfiguration.getUserName()) + "@" + databaseConfiguration.getDbUrl(); cacheKey = RegistryUtils.buildRegistryCacheKey(connectionId, tenantId, resourcePath); if (cache.containsKey(cacheKey)) { cache.remove(cacheKey); if (log.isDebugEnabled()) { log.debug("Cache cleared for resource path " + resourcePath); } } else { // delete parent path String parentPath = StringUtils.substring(resourcePath, 0, StringUtils.lastIndexOf(resourcePath, "/")); cacheKey = RegistryUtils.buildRegistryCacheKey(connectionId, tenantId, parentPath); if (cache.containsKey(cacheKey)) { cache.remove(cacheKey); if (log.isDebugEnabled()) { log.debug("Cache cleared for parent path " + parentPath); } } } } } } } }
From source file:pl.otros.logview.importer.UtilLoggingXmlLogImporter.java
String extractFileName(String clazz) { int clazzStart = StringUtils.lastIndexOf(clazz, '.') + 1; clazzStart = Math.max(0, clazzStart); int clazzEnd = StringUtils.indexOf(clazz, '$'); if (clazzEnd < 0) { clazzEnd = clazz.length();/*from w w w.j a v a 2s . co m*/ } String fileName = StringUtils.substring(clazz, clazzStart, clazzEnd); return fileName; }
From source file:pt.ist.maidSyncher.api.activeCollab.ACTask.java
public ACCategory getCategory() throws IOException { if (this._categoryId == -1 || this._categoryId == 0) return null; String decodedUrl = URLDecoder.decode(getUrl(), "UTF-8"); int lastIndexOfSlash = StringUtils.lastIndexOf(decodedUrl, "/"); String urlToUse = StringUtils.substring(decodedUrl, 0, lastIndexOfSlash); return new ACCategory( (JSONObject) getRequestProcessor().processGet(urlToUse + "/categories/" + _categoryId)); }
From source file:pt.webdetails.cda.utils.FormulaEvaluator.java
public static String replaceFormula(String text, FormulaContext context) throws InvalidParameterException { int startIdx = StringUtils.indexOf(text, FORMULA_BEGIN); int contentStartIdx = startIdx + FORMULA_BEGIN.length(); if (startIdx > -1) { int contentEndIdx = StringUtils.lastIndexOf(text, FORMULA_END); int endIdx = contentEndIdx + FORMULA_END.length(); if (contentEndIdx >= contentStartIdx) { String contents = StringUtils.substring(text, contentStartIdx, contentEndIdx); StringBuilder result = new StringBuilder(); result.append(StringUtils.substring(text, 0, startIdx)); result.append(processFormula(contents, context)); result.append(StringUtils.substring(text, endIdx, text.length())); return result.toString(); }/*from w w w . j ava 2 s. co m*/ //TODO: else throw something } return text; }