private String parseUniqueId(final String pathInfo) { final String[] pathSegmentArray = StringUtils.split(pathInfo, "/"); if (null != pathSegmentArray && pathSegmentArray.length >= 1) { return pathSegmentArray[0]; } return null; }
public Filter(String selections, boolean isBlacklist) { name = "Default"; pipelines = StringUtils.isBlank(selections) ? new String[]{} : StringUtils.split(selections, ","); type = isBlacklist ? "blacklist" : "whitelist"; } }
private String getBranchFromUrl(String url) { String[] componentsOfUrl = StringUtils.split(url.toString(), HgUrlArgument.DOUBLE_HASH); if (componentsOfUrl.length > 1) { return componentsOfUrl[1]; } return HG_DEFAULT_BRANCH; } }
public static long[] splitLongs(String str) { String parts[] = org.apache.commons.lang3.StringUtils.split(str, ','); long numbers[] = new long[parts.length]; for (int i = 0; i < parts.length; i++) numbers[i] = Long.valueOf(parts[i]); return numbers; } }
private void trimAndAdd(String matcherString) { for (String part : StringUtils.split(matcherString, SEPARATOR)) { this.matchers.add(part.trim()); } }
public static Optional<List<String>> getIndexColumns(Map<String, Object> tableProperties) { requireNonNull(tableProperties); @SuppressWarnings("unchecked") String indexColumns = (String) tableProperties.get(INDEX_COLUMNS); if (indexColumns == null) { return Optional.empty(); } return Optional.of(Arrays.asList(StringUtils.split(indexColumns, ','))); }
public static String[] getAddreeStrArray(String netaddress, String four) { String[] fourStrArray = StringUtils.split(four.substring(1, four.length() - 1), ","); String address = netaddress.substring(0, netaddress.indexOf("{")); String[] addreeStrArray = new String[fourStrArray.length]; for (int i = 0; i < fourStrArray.length; i++) { addreeStrArray[i] = address + fourStrArray[i]; } return addreeStrArray; }
public static boolean isScope(String num, int index) { String[] strArray = StringUtils.split(num, "."); if (strArray.length != 4) { return false; } return isScope(strArray, index); }
public RangeRemoteAddressStrategy(String remoteAddr) { String[] strArray = StringUtils.split(remoteAddr, "."); if (analysis(strArray, 2) || analysis(strArray, 3)) { AclUtils.verify(remoteAddr, index - 1); StringBuffer sb = new StringBuffer().append(strArray[0].trim()).append(".").append(strArray[1].trim()).append("."); if (index == 3) { sb.append(strArray[2].trim()).append("."); } this.head = sb.toString(); } }
public JsonNode resolve(JsonNode tree, String path, String refFragmentPathDelimiters) { return resolve(tree, new ArrayList<>(asList(split(path, refFragmentPathDelimiters)))); }
@Override public List<Character> valueFrom(String valueString) throws IllegalArgumentException { String[] values = StringUtils.split(valueString, multiValueDelimiter()); List<Character> chars = new ArrayList<>(values.length); for (int i = 0; i < values.length; i++) { chars.add(values[i].charAt(0)); } return chars; }
public static void parseResourcePerms(PlainAccessResource plainAccessResource, Boolean isTopic, List<String> resources) { if (resources == null || resources.isEmpty()) { return; } for (String resource : resources) { String[] items = StringUtils.split(resource, "="); if (items.length == 2) { plainAccessResource.addResourceAndPerm(isTopic ? items[0].trim() : PlainAccessResource.getRetryTopic(items[0].trim()), parsePermFromString(items[1].trim())); } else { throw new AclException(String.format("Parse resource permission failed for %s:%s", isTopic ? "topic" : "group", resource)); } } }
public static Date getDatebyTime(Date date, int n) { String str = dateFormat(date, "yyyy-MM-dd"); String[] strs = StringUtils.split(str, "-"); int month = Integer.parseInt(strs[1]); int monthnow = (month + n) % 12; int year = Integer.parseInt(strs[0]) + (month + n) / 12; str = year + "-" + monthnow + "-" + strs[2]; return dateFormat(str, "yyyy-MM-dd"); }
private void createKids() { String message = ((ParseException) item).getMessage(); String[] lines = StringUtils.split(message, PMD.EOL); kids = new ExceptionNode[lines.length]; for (int i = 0; i < lines.length; i++) { kids[i] = new ExceptionNode(lines[i]); } }
private boolean analysis(String[] strArray, int index) { String value = strArray[index].trim(); this.index = index; if ("*".equals(value)) { setValue(0, 255); } else if (AclUtils.isMinus(value)) { if (value.indexOf("-") == 0) { throw new AclException(String.format("RangeRemoteAddressStrategy netaddress examine scope Exception value %s ", value)); } String[] valueArray = StringUtils.split(value, "-"); this.start = Integer.valueOf(valueArray[0]); this.end = Integer.valueOf(valueArray[1]); if (!(AclUtils.isScope(end) && AclUtils.isScope(start) && start <= end)) { throw new AclException(String.format("RangeRemoteAddressStrategy netaddress examine scope Exception start is %s , end is %s", start, end)); } } return this.end > 0 ? true : false; }
private void setRelatedIdList(CheckpointExecutable checkpointExecutable, List<String> segmentIdList, List<String> jobIdList) { for (AbstractExecutable taskForCheck : checkpointExecutable.getSubTasksForCheck()) { jobIdList.add(taskForCheck.getId()); if (taskForCheck instanceof CubingJob) { segmentIdList.addAll(Lists .newArrayList(StringUtils.split(CubingExecutableUtil.getSegmentId(taskForCheck.getParams())))); } else if (taskForCheck instanceof CheckpointExecutable) { setRelatedIdList((CheckpointExecutable) taskForCheck, segmentIdList, jobIdList); } } }
private void initHllConfig(JobContext context) { String _hllColumns = PinotOutputFormat.getHllColumns(context); if (_hllColumns != null) { String[] hllColumns = StringUtils.split(StringUtils.deleteWhitespace(_hllColumns), ','); if (hllColumns.length != 0) { HllConfig hllConfig = new HllConfig(PinotOutputFormat.getHllSize(context)); hllConfig.setColumnsToDeriveHllFields(new HashSet<>(Arrays.asList(hllColumns))); hllConfig.setHllDeriveColumnSuffix(PinotOutputFormat.getHllSuffix(context)); _segmentConfig.setHllConfig(hllConfig); } } }
@Test public void testSplit_String() { assertNull(StringUtils.split(null)); assertEquals(0, StringUtils.split("").length); String str = "a b .c"; String[] res = StringUtils.split(str); assertEquals(3, res.length); assertEquals("a", res[0]); assertEquals("b", res[1]); assertEquals(".c", res[2]); str = " a "; res = StringUtils.split(str); assertEquals(1, res.length); assertEquals("a", res[0]); str = "a" + WHITESPACE + "b" + NON_WHITESPACE + "c"; res = StringUtils.split(str); assertEquals(2, res.length); assertEquals("a", res[0]); assertEquals("b" + NON_WHITESPACE + "c", res[1]); }
@Test public void testSplit_StringChar() { assertNull(StringUtils.split(null, '.')); assertEquals(0, StringUtils.split("", '.').length); String str = "a.b.. c"; String[] res = StringUtils.split(str, '.'); assertEquals(3, res.length); assertEquals("a", res[0]); assertEquals("b", res[1]); assertEquals(" c", res[2]); str = ".a."; res = StringUtils.split(str, '.'); assertEquals(1, res.length); assertEquals("a", res[0]); str = "a b c"; res = StringUtils.split(str, ' '); assertEquals(3, res.length); assertEquals("a", res[0]); assertEquals("b", res[1]); assertEquals("c", res[2]); }
@Test public void shouldCloneOnlyTheSpecifiedBranchAndPointToIt() { String branchName = "second"; HgCommand hg = new HgCommand(null, secondBranchWorkingCopy, branchName, serverRepo.getAbsolutePath(), null); hg.clone(outputStreamConsumer, new UrlArgument(serverRepo.getAbsolutePath() + "#" + branchName)); String currentBranch = hg(secondBranchWorkingCopy, "branch").runOrBomb(null).outputAsString(); assertThat(currentBranch, is(branchName)); List<String> branches = hg(secondBranchWorkingCopy, "branches").runOrBomb(null).output(); ArrayList<String> branchNames = new ArrayList<>(); for (String branchDetails : branches) { branchNames.add(StringUtils.split(branchDetails, " ")[0]); } assertThat(branchNames.size(), is(2)); assertThat(branchNames.contains(branchName), is(true)); assertThat(branchNames.contains("default"), is(true)); }