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.ewcms.publication.freemarker.directive.IncludeDirective.java
/** * ?//from w w w. ja v a 2s .c o m * * <p>?+?</p> * * @param siteId ? * @param path ? * @return */ String getUniqueTemplatePath(Integer siteId, String path) { String nPath = StringUtils.removeStart(path, "/"); String uPath = StringUtils.join(new Object[] { siteId, nPath }, "/"); logger.debug("Include path is {}", uPath); return uPath; }
From source file:info.magnolia.jcr.util.ContentMap.java
private Object getSpecialProperty(String strKey) { if (isSpecialProperty(strKey)) { final Method method = specialProperties.get(StringUtils.removeStart(strKey, "@")); try {/*from w w w .j a va 2 s . c o m*/ return method.invoke(content, null); } catch (Exception e) { throw new RuntimeException(e); } } return null; }
From source file:msi.gama.util.GAML.java
public static String getDocumentationOn(final String query) { final String keyword = StringUtils.removeEnd(StringUtils.removeStart(query.trim(), "#"), ":"); final Multimap<GamlIdiomsProvider<?>, IGamlDescription> results = GamlIdiomsProvider.forName(keyword); if (results.isEmpty()) { return "No result found"; }// w w w. ja v a 2s . c o m final StringBuilder sb = new StringBuilder(); final int max = results.keySet().stream().mapToInt(each -> each.name.length()).max().getAsInt(); final String separator = StringUtils.repeat("", max + 6).concat(Strings.LN); results.asMap().forEach((provider, list) -> { sb.append("").append(separator).append("|| "); sb.append(StringUtils.rightPad(provider.name, max)); sb.append(" ||").append(Strings.LN).append(separator); for (final IGamlDescription d : list) { sb.append("== ").append(toText(d.getTitle())).append(Strings.LN) .append(toText(provider.document(d))).append(Strings.LN); } }); return sb.toString(); // }
From source file:hudson.plugins.clearcase.ucm.service.BaselineService.java
private String stripPrefix(String selector) { return StringUtils.removeStart(selector, Baseline.PREFIX); }
From source file:com.enonic.cms.business.portal.processor.ContentRequestProcessor.java
private boolean redirectPathIsEqualToRequestedPath(String newLocalPath, String requestedPath) { newLocalPath = StringUtils.removeStart(newLocalPath, "/"); requestedPath = StringUtils.removeStart(requestedPath, "/"); newLocalPath = StringUtils.removeEnd(newLocalPath, "/"); requestedPath = StringUtils.removeEnd(requestedPath, "/"); return newLocalPath.equalsIgnoreCase(requestedPath); }
From source file:info.magnolia.module.delta.PartialBootstrapTask.java
protected String getOutputResourceName(final String resource, final String itemPath) { // get name as config.modules.xxx String inputResourceName = BootstrapUtil.getFilenameFromResource(resource, ".xml"); //replacing all "/" with "."; getting string after first node String tmpitemPath = itemPath.replace("/", "."); tmpitemPath = StringUtils.removeStart(tmpitemPath, "."); tmpitemPath = StringUtils.substringAfter(tmpitemPath, "."); String outputResourceName = inputResourceName + "." + tmpitemPath; if (StringUtils.isNotEmpty(targetResource)) { outputResourceName = targetResource; }// w w w. jav a2 s .c o m return outputResourceName; }
From source file:net.sourceforge.fenixedu.presentationTier.servlets.filters.JerseyOAuth2Filter.java
private boolean validScope(AppUserSession appUserSession, String uri) throws IOException, ServletException { uri = StringUtils.removeStart(StringUtils.removeEnd(uri, "/"), "/"); AuthScope scope = FenixJerseyAPIConfig.getScope(uri); if (scope != null) { if (appUserSession.getAppUserAuthorization().getApplication().getScopesSet().contains(scope)) { return true; }/*w ww .j a v a2 s .com*/ } return false; }
From source file:com.adobe.acs.commons.components.longformtext.impl.LongFormTextComponentImpl.java
private int getResourceIndex(final Resource resource) { final String resourceName = resource.getName(); if (!StringUtils.startsWith(resourceName, LONG_FORM_TEXT_PAR)) { return -1; }//from ww w .ja v a2 s. c o m final String indexStr = StringUtils.removeStart(resourceName, LONG_FORM_TEXT_PAR); try { return Integer.parseInt(indexStr); } catch (NumberFormatException ex) { return -1; } }
From source file:com.adobe.acs.commons.wcm.notifications.impl.SystemNotificationsImpl.java
@Override public String getMessage(String message, String onTime, String offTime) { if (StringUtils.isBlank(message)) { return message; }//from www. j ava 2 s .c om message = StringUtils.trimToEmpty(message); boolean allowHTML = false; if (StringUtils.startsWith(message, "html:")) { allowHTML = true; message = StringUtils.removeStart(message, "html:"); } if (onTime != null) { message = StringUtils.replace(message, "{{ onTime }}", onTime); } if (offTime != null) { message = StringUtils.replace(message, "{{ offTime }}", offTime); } if (!allowHTML) { message = message.replaceAll("(\r\n|\n)", "<br />"); } return message; }
From source file:gov.nih.nci.cabig.caaers.web.admin.OrganizationImporter.java
/** * This method accepts a String which should be like * "CA531","California Hematology Oncology Medical Group","Torrance","CA","USA" * It splits the string into 5 tokens and creates a LocalOrganization object. * If the number of token are less than 5 the record/line is rejected. * @param organizationString/*from www .ja v a 2 s. c om*/ * @return */ protected DomainObjectImportOutcome<Organization> processOrganization(String organizationString, int lineNumber) { DomainObjectImportOutcome<Organization> organizationImportOutcome = null; LocalOrganization localOrganization = null; StringTokenizer st = null; String institutionCode; String institutionName; String city; String state; String country; if (StringUtils.isNotEmpty(organizationString)) { logger.debug("Orginial line from file -- >>> " + organizationString); organizationString = organizationString.trim(); //Replace ", with "| //This is done to set a delimiter other than , organizationString = StringUtils.replace(organizationString, "\",", "\"|"); logger.debug("Modified line -- >>> " + organizationString); //Generate tokens from input String. st = new StringTokenizer(organizationString, "|"); //If there are 5 tokens as expected, process the record. Create a LocalOrganization object. if (st.hasMoreTokens() && st.countTokens() == 5) { organizationImportOutcome = new DomainObjectImportOutcome<Organization>(); localOrganization = new LocalOrganization(); institutionCode = StringUtils.removeStart(st.nextToken(), "\"").trim(); institutionCode = StringUtils.removeEnd(institutionCode, "\""); institutionName = StringUtils.removeStart(st.nextToken(), "\"").trim(); institutionName = StringUtils.removeEnd(institutionName, "\""); city = StringUtils.removeStart(st.nextToken(), "\"").trim(); city = StringUtils.removeEnd(city, "\""); state = StringUtils.removeStart(st.nextToken(), "\"").trim(); state = StringUtils.removeEnd(state, "\""); country = StringUtils.removeStart(st.nextToken(), "\"").trim(); country = StringUtils.removeEnd(country, "\""); localOrganization.setName(institutionName); localOrganization.setNciInstituteCode(institutionCode); localOrganization.setCity(city); localOrganization.setState(state); localOrganization.setCountry(country); organizationImportOutcome.setImportedDomainObject(localOrganization); organizationImportOutcome.setSavable(Boolean.TRUE); } else { logger.debug("Error in record -- >>> " + organizationString); organizationImportOutcome = new DomainObjectImportOutcome<Organization>(); StringBuilder msgBuilder = new StringBuilder("Invalid organization record found at line ::: "); msgBuilder.append(lineNumber); organizationImportOutcome.addErrorMessage(msgBuilder.toString(), Severity.ERROR); } } return organizationImportOutcome; }