List of usage examples for org.apache.commons.lang3 StringUtils substringAfter
public static String substringAfter(final String str, final String separator)
Gets the substring after the first occurrence of a separator.
From source file:com.u2apple.tool.util.AndroidDeviceUtils.java
public static String buildProductId(String brand, String model) { String productId = null;/*from www .j a v a 2 s .c om*/ if (StringUtils.isNotBlank(brand) && StringUtils.isNotBlank(model)) { brand = brand.toLowerCase(); model = model.toLowerCase(); String modelWithoutBrand; if (StringUtils.containsIgnoreCase(model, brand)) { modelWithoutBrand = StringUtils.substringAfter(model, brand); } else { modelWithoutBrand = model; } //?model. // if ("samsung".equalsIgnoreCase(brand) && modelWithoutBrand.contains("-")) { // int index = modelWithoutBrand.indexOf("-"); // //When "-" is the last char. // if (index < modelWithoutBrand.length() - 1) { // modelWithoutBrand = modelWithoutBrand.substring(index + 1); // } // } String formattedModel = formatModel(modelWithoutBrand); //?? // if ("vivo".equalsIgnoreCase(brand)) { // productId = "bbk-vivo" + formattedModel; // } else { productId = brand + "-" + formattedModel; // } } return productId; }
From source file:de.blizzy.documentr.search.GetVisibleBranchDocIdsTask.java
@Override public BitSet call() throws IOException { List<String> branches = Lists .newArrayList(permissionEvaluator.getBranchesForPermission(authentication, Permission.VIEW)); if (!branches.isEmpty()) { Collections.sort(branches); BooleanQuery allBranchesQuery = new BooleanQuery(); for (String projectAndBranch : branches) { String projectName = StringUtils.substringBefore(projectAndBranch, "/"); //$NON-NLS-1$ String branchName = StringUtils.substringAfter(projectAndBranch, "/"); //$NON-NLS-1$ TermQuery projectQuery = new TermQuery(new Term(PageIndex.PROJECT, projectName)); TermQuery branchQuery = new TermQuery(new Term(PageIndex.BRANCH, branchName)); BooleanQuery projectAndBranchQuery = new BooleanQuery(); projectAndBranchQuery.add(projectQuery, BooleanClause.Occur.MUST); projectAndBranchQuery.add(branchQuery, BooleanClause.Occur.MUST); allBranchesQuery.add(projectAndBranchQuery, BooleanClause.Occur.SHOULD); }//from w ww . ja va 2 s . c om AbstractDocIdsCollector collector = new AllDocIdsCollector(); searcher.search(allBranchesQuery, collector); return collector.getDocIds(); } else { return new BitSet(1); } }
From source file:com.gargoylesoftware.htmlunit.html.HtmlMeta.java
/** * Handles the cookies specified in meta tags, * like <tt><meta http-equiv='set-cookie' content='webm=none; path=/;'></tt>. *//*from w ww . j av a 2s . co m*/ protected void performSetCookie() { final String[] parts = COOKIES_SPLIT_PATTERN.split(getContentAttribute(), 0); final String name = StringUtils.substringBefore(parts[0], "="); final String value = StringUtils.substringAfter(parts[0], "="); final URL url = getPage().getUrl(); final String host = url.getHost(); final boolean secure = "https".equals(url.getProtocol()); String path = null; Date expires = null; for (int i = 1; i < parts.length; i++) { final String partName = StringUtils.substringBefore(parts[i], "=").trim().toLowerCase(); final String partValue = StringUtils.substringAfter(parts[i], "=").trim(); if ("path".equals(partName)) { path = partValue; } else if ("expires".equals(partName)) { expires = com.gargoylesoftware.htmlunit.util.StringUtils.parseHttpDate(partValue); } else { notifyIncorrectness("set-cookie http-equiv meta tag: unknown attribute '" + partName + "'."); } } final Cookie cookie = new Cookie(host, name, value, path, expires, secure); getPage().getWebClient().getCookieManager().addCookie(cookie); }
From source file:de.blizzy.documentr.search.GetVisibleBranchDocIdsTaskTest.java
@Test public void call() throws IOException { List<String> branches = Lists.newArrayList("project1/branch1", "project1/branch2", "project2/branch"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ when(permissionEvaluator.getBranchesForPermission(authentication, Permission.VIEW)) .thenReturn(Sets.newHashSet(branches)); BooleanQuery query = new BooleanQuery(); for (String projectAndBranch : branches) { BooleanQuery q = new BooleanQuery(); String projectName = StringUtils.substringBefore(projectAndBranch, "/"); //$NON-NLS-1$ String branchName = StringUtils.substringAfter(projectAndBranch, "/"); //$NON-NLS-1$ q.add(new TermQuery(new Term(PageIndex.PROJECT, projectName)), BooleanClause.Occur.MUST); q.add(new TermQuery(new Term(PageIndex.BRANCH, branchName)), BooleanClause.Occur.MUST); query.add(q, BooleanClause.Occur.SHOULD); }// w ww . ja va2 s . c o m task.call(); verify(searcher).search(eq(query), Matchers.any(AllDocIdsCollector.class)); }
From source file:com.adobe.acs.commons.reports.models.PageReplicationStatusModel.java
public String getReplicationStatus() { Session session = resource.getResourceResolver().adaptTo(Session.class); String path = resource.getPath(); if (path.contains(JcrConstants.JCR_CONTENT)) { path = StringUtils.substringAfter(path, JcrConstants.JCR_CONTENT) + JcrConstants.JCR_CONTENT; } else {//from w w w . j a va 2 s . c o m path += "/" + JcrConstants.JCR_CONTENT; } log.debug("Getting replication status for {}", path); ReplicationStatus status = replicator.getReplicationStatus(session, path); Status rStatus = Status.NOT_ACTIVATED; if (status != null) { if (status.isDeactivated()) { rStatus = Status.DEACTIVATED; } else if (status.isPending()) { rStatus = Status.IN_PROGRESS; } else if (status.isActivated()) { Calendar lastModified = getLastModified(resource.getResourceResolver(), path); if (lastModified != null && status.getLastPublished() != null && lastModified.after(status.getLastPublished())) { rStatus = Status.MODIFIED; } else { rStatus = Status.ACTIVATED; } } } log.debug("Retrieved replication status {}", rStatus); return rStatus.toString(); }
From source file:net.sf.dynamicreports.report.builder.chart.SeriesOrderByNamesComparator.java
@Override public int compare(String o1, String o2) { String row1;//from www . j a v a2s .com String row2; if (StringUtils.countMatches(o1, GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY) == 1 && StringUtils.countMatches(o2, GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY) == 1) { String group1 = StringUtils.substringBefore(o1, GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY); String group2 = StringUtils.substringBefore(o2, GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY); int compare = group1.compareTo(group2); if (compare != 0) { return compare; } row1 = StringUtils.substringAfter(o1, GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY); row2 = StringUtils.substringAfter(o2, GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY); } else { row1 = o1; row2 = o2; } int index1 = seriesNames.indexOf(row1); int index2 = seriesNames.indexOf(row2); if (index1 < 0 && index2 < 0) { return row1.compareTo(row2); } if (index1 == index2) { return 0; } if (index1 < 0) { return index1 * -1; } if (index2 < 0) { return index2; } return index1 - index2; }
From source file:com.eryansky.common.orm.PropertyFilter.java
/** * @param filterName ,???. /*www. ja v a 2 s.c o m*/ * eg. LIKES_NAME_OR_LOGIN_NAME * @param value . */ public PropertyFilter(final String filterName, final String value) { String firstPart = StringUtils.substringBefore(filterName, "_"); String matchTypeCode = StringUtils.substring(firstPart, 0, firstPart.length() - 1); String propertyTypeCode = StringUtils.substring(firstPart, firstPart.length() - 1, firstPart.length()); try { matchType = Enum.valueOf(MatchType.class, matchTypeCode); } catch (RuntimeException e) { throw new IllegalArgumentException( "filter??" + filterName + ",.", e); } try { propertyClass = Enum.valueOf(PropertyType.class, propertyTypeCode).getValue(); } catch (RuntimeException e) { throw new IllegalArgumentException( "filter??" + filterName + ",.", e); } String propertyNameStr = StringUtils.substringAfter(filterName, "_"); Assert.isTrue(StringUtils.isNotBlank(propertyNameStr), "filter??" + filterName + ",??."); propertyNames = StringUtils.splitByWholeSeparator(propertyNameStr, PropertyFilter.OR_SEPARATOR); this.matchValue = ConvertUtils.convertStringToObject(value, propertyClass); }
From source file:de.jfachwert.post.Adressat.java
/** * Bei natuerlichen Personen mit Vornamen kann hierueber der Vorname * ermittelt werden.// ww w . j a v a 2s.com * * @return z.B. "Max" */ public String getVorname() { if (hasVorname()) { return StringUtils.substringAfter(this.getCode(), ",").trim(); } else { throw new IllegalStateException("keine nat\u00fcrliche Person: " + this.getCode()); } }
From source file:com.threewks.thundr.configuration.PropertiesLoader.java
private Map<String, String> readProperties(String resourceAsString) { Map<String, String> properties = new LinkedHashMap<String, String>(); Scanner scanner = new Scanner(resourceAsString); try {// w w w.j a v a2 s. co m while (scanner.hasNextLine()) { String line = scanner.nextLine(); line = StringUtils.substringBefore(line, "#"); line = StringUtils.trimToNull(line); String key = StringUtils.substringBefore(line, "="); String value = StringUtils.substringAfter(line, "="); if (key != null) { properties.put(key, value); } } } finally { scanner.close(); } return properties; }
From source file:io.wcm.devops.conga.plugins.aem.util.JsonContentLoaderTest.java
@SuppressWarnings("unchecked") private static Map<String, Object> getDeep(Map<String, Object> map, String path) { String name = StringUtils.substringBefore(path, "/"); Object object = map.get(name); if (object == null || !(object instanceof Map)) { return null; }/*w w w.j a v a 2s .com*/ String remainingPath = StringUtils.substringAfter(path, "/"); Map<String, Object> childMap = (Map<String, Object>) object; if (StringUtils.isEmpty(remainingPath)) { return childMap; } else { return getDeep(childMap, remainingPath); } }