List of usage examples for org.apache.commons.lang StringUtils removeStart
public static String removeStart(String str, String remove)
Removes a substring only if it is at the begining of a source string, otherwise returns the source string.
From source file:com.hangum.tadpole.manager.core.editor.restfulapi.RESTFulAPIManagerEditor.java
/** * Initialize UI //ww w . j a v a 2 s .c o m */ private void initUI() { listRestfulDao.clear(); try { List<ResourceManagerDAO> listAPIList = TadpoleSystem_UserDBResource.getRESTFulAPIList(); Map<String, RESTFulAPIDAO> mapFirstApi = new HashMap<String, RESTFulAPIDAO>(); // ?? ? . for (ResourceManagerDAO resourceManagerDAO : listAPIList) { String strURL = StringUtils.removeStart(resourceManagerDAO.getRestapi_uri(), "/"); //$NON-NLS-1$ // ? ? ?? . String[] strArrySlash = StringUtils.split(strURL, '/'); String strTreeKey = strArrySlash[0]; if (!mapFirstApi.containsKey(strTreeKey)) { if (strArrySlash.length == 1) mapFirstApi.put(strTreeKey, new RESTFulAPIDAO(strTreeKey, resourceManagerDAO)); else mapFirstApi.put(strTreeKey, new RESTFulAPIDAO(strTreeKey)); } } // ? ? . for (ResourceManagerDAO resourceManagerDAO : listAPIList) { String strURL = StringUtils.removeStart(resourceManagerDAO.getRestapi_uri(), "/"); //$NON-NLS-1$ // ? ? ?? . String[] strArrySlash = StringUtils.split(strURL, '/'); if (strArrySlash.length == 1) continue; String strTreeKey = strArrySlash[1]; RESTFulAPIDAO rootDAO = mapFirstApi.get(strArrySlash[0]); if (strArrySlash.length == 2) { List<RESTFulAPIDAO> listChildren = rootDAO.getListChildren(); RESTFulAPIDAO existRestDAO = null; for (RESTFulAPIDAO restFulAPIDAO : listChildren) { if (strTreeKey.equals(restFulAPIDAO.getStrURL())) existRestDAO = restFulAPIDAO; } if (existRestDAO != null) listChildren.remove(existRestDAO); listChildren.add(new RESTFulAPIDAO(strTreeKey, resourceManagerDAO)); } else { List<RESTFulAPIDAO> listChildren = rootDAO.getListChildren(); boolean boolExist = false; for (RESTFulAPIDAO restFulAPIDAO : listChildren) { if (strTreeKey.equals(restFulAPIDAO.getStrURL())) boolExist = true; } if (!boolExist) { listChildren.add(new RESTFulAPIDAO(strTreeKey)); } } } // ? . for (ResourceManagerDAO resourceManagerDAO : listAPIList) { String strURL = StringUtils.removeStart(resourceManagerDAO.getRestapi_uri(), "/"); //$NON-NLS-1$ // ? ? ?? . String[] strArrySlash = StringUtils.split(strURL, '/'); if (strArrySlash.length == 3) { String strTreeKey = strArrySlash[2]; RESTFulAPIDAO rootDAO = mapFirstApi.get(strArrySlash[0]); String searchKey = strArrySlash[1]; for (RESTFulAPIDAO restFulAPIDAO : rootDAO.getListChildren()) { if (searchKey.equals(restFulAPIDAO.getStrURL())) { restFulAPIDAO.getListChildren().add(new RESTFulAPIDAO(strTreeKey, resourceManagerDAO)); } } } } listRestfulDao.addAll(mapFirstApi.values()); tvAPIList.setInput(listRestfulDao); } catch (Exception e) { logger.error("RESTFulAPI List", e); //$NON-NLS-1$ } // google analytic AnalyticCaller.track(RESTFulAPIManagerEditor.ID); }
From source file:adalid.commons.velocity.Writer.java
private boolean accept(File templatePropertiesFile, String[] pathfilters) { if (templatePropertiesFile == null) { return false; }//from w w w . j a va 2 s . c o m if (pathfilters == null || pathfilters.length == 0) { return true; } String name = StringUtils.removeEndIgnoreCase(templatePropertiesFile.getName(), PROPERTIES_SUFFIX); String lowerName = name.toLowerCase(); String fileFilter; String anything = ".*"; String delimiters = "[\\W]"; String word = "[\\w\\-]*"; for (String pathfilter : pathfilters) { fileFilter = pathfilter.replace(FILE_SEPARATOR, SLASH); fileFilter = fileFilter.toLowerCase(); fileFilter = StringUtils.removeStart(fileFilter, SLASH); fileFilter = StringUtils.removeEnd(fileFilter, SLASH); if (fileFilter.isEmpty()) { continue; } if (fileFilter.matches(word)) { if (lowerName .matches(CARET + anything + delimiters + fileFilter + delimiters + anything + DOLLAR)) { logger.debug("filter " + ASTERISK + pathfilter + ASTERISK + " excludes " + name); return false; } if (lowerName.matches(CARET + fileFilter + delimiters + anything)) { logger.debug("filter " + pathfilter + ASTERISK + " excludes " + name); return false; } if (lowerName.matches(anything + delimiters + fileFilter + DOLLAR)) { logger.debug("filter " + ASTERISK + pathfilter + " excludes " + name); return false; } if (lowerName.matches(CARET + fileFilter + DOLLAR)) { logger.debug("filter " + pathfilter + " excludes " + name); return false; } } } return true; }
From source file:info.magnolia.link.LinkUtil.java
/** * Parses provided URI to the link.// w ww.j a v a2s.c o m * @param link URI representing path to piece of content * @return Link pointing to the content represented by provided URI */ public static Link parseLink(String link) throws LinkException { // ignore context handle if existing link = StringUtils.removeStart(link, MgnlContext.getContextPath()); Matcher matcher = LINK_PATTERN.matcher(link); if (matcher.matches()) { String orgHandle = matcher.group(1); orgHandle = Components.getComponent(I18nContentSupport.class).toRawURI(orgHandle); String workspaceName = getURI2RepositoryManager().getRepository(orgHandle); String handle = getURI2RepositoryManager().getHandle(orgHandle); return createLinkInstance(workspaceName, handle, matcher.group(3), matcher.group(5), matcher.group(7)); } throw new LinkException("can't parse [ " + link + "]"); }
From source file:adalid.commons.util.StrUtils.java
public static String getUnqualifiedName(String name, String qualifier) { String n, q;/*from www . j a v a 2 s .c o m*/ if (StringUtils.isNotBlank(name)) { n = name.trim(); if (StringUtils.isNotBlank(qualifier)) { q = qualifier.trim(); n = StringUtils.removeStart(n, q + "."); } return n; } return null; }
From source file:adalid.commons.util.StrUtils.java
public static String getQualifiedShortName(String name, String qualifier) { String n, q;// w w w . ja v a 2 s . c om if (StringUtils.isNotBlank(name)) { n = name.trim(); if (StringUtils.isNotBlank(qualifier)) { q = qualifier.trim(); n = StringUtils.removeStart(n, q + "."); n = StringUtils.removeStart(n, q + "_"); n = StringUtils.removeEnd(n, "_" + q); return q + "." + n; } return n; } return null; }
From source file:adalid.commons.util.StrUtils.java
public static String getUnqualifiedShortName(String name, String qualifier) { String n, q;/*from w ww . ja va2 s . c o m*/ if (StringUtils.isNotBlank(name)) { n = name.trim(); if (StringUtils.isNotBlank(qualifier)) { q = qualifier.trim(); n = StringUtils.removeStart(n, q + "."); n = StringUtils.removeStart(n, q + "_"); n = StringUtils.removeEnd(n, "_" + q); } return n; } return null; }
From source file:adalid.core.programmers.AbstractSqlProgrammer.java
/** * @param artifact/* ww w . j a va 2 s.com*/ * @return the SQL qualified name */ @Override public String getSqlQualifiedName(Artifact artifact) { String p; if (artifact.getDeclaringField() == null || artifact.getDeclaringArtifact() == null) { p = getSqlName(artifact); } else { p = getSqlQualifiedName(artifact.getDeclaringArtifact()) + DOT$ + getSqlName(artifact); if (artifact.getDeclaringField().getType().isArray()) { p += UND$ + artifact.getDeclaringFieldIndex(); } p = StringUtils.removeStart(p, DOT$); } return p; }
From source file:com.evolveum.midpoint.web.component.wizard.resource.SchemaHandlingStep.java
private String formatPath(ItemPathType path) { String rv = String.valueOf(path); rv = StringUtils.removeStart(rv, "$user/"); rv = StringUtils.removeStart(rv, "$c:user/"); rv = StringUtils.removeStart(rv, "$focus/"); rv = StringUtils.removeStart(rv, "$c:focus/"); rv = StringUtils.removeStart(rv, "extension/"); rv = StringUtils.removeStart(rv, "c:extension/"); return rv;/* w w w. jav a 2s. c o m*/ }
From source file:adalid.util.meta.sql.MetaPlatformSql.java
private String rootlessPath(File file) { return StringUtils.removeStart(StringUtils.removeStartIgnoreCase(file.getPath(), getRoot().getPath()), FILE_SEPARATOR); }
From source file:ips1ap101.lib.base.util.StrUtils.java
public static String removeWords(String string, String remove, char affixType) { if (remove != null) { String separatorChars = ", "; String[] tokens = StringUtils.split(remove, separatorChars); for (String token : tokens) { remove = StrUtils.getWordyString(token); if (affixType == 'p') { string = StringUtils.removeStart(string, remove + " "); } else if (affixType == 's') { string = StringUtils.removeEnd(string, " " + remove); } else { string = StringUtils.remove(string, " " + remove + " "); }/* w w w.jav a 2 s . c o m*/ } } return string; }