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.wibidata.shopping.model.Category.java
public static Category fromProducts(Node node) throws MalformedURLException { Category category = new Category(); category.setName(StringUtils.removeStart(node.getLabel().toString(), "category:")); for (Edge edge : node.getEdges()) { Product product = new Product(); product.setId(edge.getTarget().getLabel().toString()); AvroMapReader<String> annotations = AvroMapReader .<String>create((Map<CharSequence, String>) (Map<? extends CharSequence, String>) edge .getTarget().getAnnotations()); product.setName(annotations.get("name").toString()); product.setDescription(annotations.get("description_short").toString()); product.setThumbnail(annotations.get("thumbnail").toString()); product.setInventory(Long.parseLong(annotations.get("inventory").toString())); product.setPrice(Double.parseDouble(annotations.get("price").toString())); category.addProduct(product);/*from w w w . ja v a 2s.c o m*/ } return category; }
From source file:com.iggroup.oss.restdoclet.doclet.util.UrlUtils.java
/** * Convert a URI list in the form of {"","",...""} into a String[] of URIs * /* ww w .j a v a 2 s . c o m*/ * @param multiUri URI list in the form "" or {"","",...""} * @return URIs */ public static String[] parseMultiUri(final String multiUri) { String value; value = StringUtils.removeStart(multiUri.trim(), "{"); value = StringUtils.removeEnd(value, "}"); value = value.replace("\"", ""); value = value.replaceAll("\\s", ""); return value.split(","); }
From source file:hudson.plugins.clearcase.model.Version.java
public static Version parse(String extendedViewPath, String viewPath) { String relative = StringUtils.removeStart(extendedViewPath, viewPath); relative = StringUtils.removeStart(relative, "/"); relative = StringUtils.removeStart(relative, "\\"); return new Version(relative); }
From source file:gobblin.data.management.util.PathUtils.java
/** * Removes the leading slash if present. * *//*from w w w .j a v a 2 s. c o m*/ public static Path withoutLeadingSeparator(Path path) { return new Path(StringUtils.removeStart(path.toString(), Path.SEPARATOR)); }
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 {//from w w w. j a va2s .c o m chain.doFilter(request, response); } finally { RequestContext.clearRequestContext(); } }
From source file:com.adobe.adobemarketingcloud.github.maven.scq.di.MojoConfiguration.java
public static String makeUrl(String url) { if (StringUtils.isBlank(url)) { return url; }// w ww.j a va2s . c o m String result = StringUtils.removeEnd(url, "/"); if (!result.startsWith("http://") && !result.startsWith("https://")) { result = StringUtils.removeStart(result, "/"); result = "http://" + result; } return result; }
From source file:com.ewcms.publication.freemarker.cache.DatabaseTemplateLoader.java
@Override public Object findTemplateSource(String name) throws IOException { Assert.notNull(name, "template uniquepath is null"); String path = StringUtils.removeStart(name, "/"); Template template = templateService.getTemplateByUniquePath(path); if (template == null) { logger.debug("{} is not exist.", path); return null; }/*from w w w. j av a 2 s . c o m*/ TemplateEntity entity = template.getTemplateEntity(); if (entity == null) { logger.debug("{} content is null", path); return null; } byte[] content = entity.getTplEntity(); long lastTime = template.getUpdTime().getTime(); return new TemplateSource(path, content, lastTime); }
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.antsdb.saltedfish.sql.mysql.Variable_referenceGenerator.java
@Override public Instruction gen(GeneratorContext ctx, Variable_referenceContext rule) throws OrcaException { String name = rule.VARIABLE().getText(); name = StringUtils.removeStart(name, "@"); return new GetSessionVarible(name); }
From source file:com.salesmanager.catalog.URLInterceptor.java
@Override protected String baseIntercept(ActionInvocation invoke, HttpServletRequest req, HttpServletResponse resp) throws Exception { // TODO Auto-generated method stub /**/*w w w . ja v a2 s. c om*/ * This interceptor is used for urls invoked using SEO type urls The * system is configured to support /category/category-name * /product/product-name /pagelink/page-name */ // get the product from the path String path = StringUtils.removeStart(req.getRequestURI(), req.getContextPath()); /** * should have left /category/<PRODUCT-URL>?request parameters or should * have left /pagelink/<PAGE-URL>?request parameters or should have left * /product/<PRODUCT-URL>?request parameters keep after second / and * before ? */ // remove /product or /category or /page String pathnocontext = path.substring(1);// remove / // should now have product/<PRODUCT-ID>?request parameters or // category/<CATEGORY-ID>?request parameters or pagelink/<PAGE-ID> String[] parameters = pathnocontext.split("/"); // should now have // parameters[0] = product or category or pagelink // parameters[1] = <PRODUCT-ID>?parameters if (parameters == null || parameters.length == 1) { throw new Exception("Invalid parameters in request " + path); } String id = parameters[1]; if (id.contains(".action")) { id = id.substring(0, id.indexOf(".action")); } SalesManagerBaseAction action = ((SalesManagerBaseAction) invoke.getAction()); action.setRequestedEntityId(id); return null; }