/** * Ensure decoded new lines are not propagated in headers, in order to prevent XSS * * @param input - decoded header string * @return - clean header string */ public static String stripMaliciousHeaderChars(String input) { for (char c : MALICIOUS_HEADER_CHARS) { input = StringUtils.remove(input, c); } return input; }
public static int exactVersionNo(String versionNo) { if (versionNo == null) throw new IllegalArgumentException("versionNo is not defined"); versionNo = org.apache.commons.lang3.StringUtils.removeIgnoreCase(versionNo, "-SNAPSHOT"); versionNo = org.apache.commons.lang3.StringUtils.remove(versionNo, "."); if (!NumberUtils.isDigits(versionNo)) throw new IllegalArgumentException("extracted versionNo is not a valid number: " + versionNo); return Integer.valueOf(versionNo); }
/** * Ensure decoded new lines are not propagated in headers, in order to prevent XSS * * @param input - decoded header string * @return - clean header string */ public static String stripMaliciousHeaderChars(String input) { for (char c : MALICIOUS_HEADER_CHARS) { input = StringUtils.remove(input, c); } return input; }
public Set<String> getCurrencies() { return additionalProperties .keySet() .stream() .filter(key -> key.startsWith(PREFIX_TOTAL)) .map(key -> StringUtils.remove(key, PREFIX_TOTAL)) .collect(Collectors.toSet()); }
private String relativeRoot(String absoluteRoot, String repoUrl) { return StringUtils.strip(StringUtils.remove(absoluteRoot, repoUrl), "/"); }
@Test public void testRemove_char() { // StringUtils.remove(null, *) = null assertNull(StringUtils.remove(null, 'a')); assertNull(StringUtils.remove(null, 'a')); assertNull(StringUtils.remove(null, 'a')); // StringUtils.remove("", *) = "" assertEquals("", StringUtils.remove("", 'a')); assertEquals("", StringUtils.remove("", 'a')); assertEquals("", StringUtils.remove("", 'a')); // StringUtils.remove("queued", 'u') = "qeed" assertEquals("qeed", StringUtils.remove("queued", 'u')); // StringUtils.remove("queued", 'z') = "queued" assertEquals("queued", StringUtils.remove("queued", 'z')); }
@Test public void testRemove_String() { // StringUtils.remove(null, *) = null assertNull(StringUtils.remove(null, null)); assertNull(StringUtils.remove(null, "")); assertNull(StringUtils.remove(null, "a")); // StringUtils.remove("", *) = "" assertEquals("", StringUtils.remove("", null)); assertEquals("", StringUtils.remove("", "")); assertEquals("", StringUtils.remove("", "a")); // StringUtils.remove(*, null) = * assertNull(StringUtils.remove(null, null)); assertEquals("", StringUtils.remove("", null)); assertEquals("a", StringUtils.remove("a", null)); // StringUtils.remove(*, "") = * assertNull(StringUtils.remove(null, "")); assertEquals("", StringUtils.remove("", "")); assertEquals("a", StringUtils.remove("a", "")); // StringUtils.remove("queued", "ue") = "qd" assertEquals("qd", StringUtils.remove("queued", "ue")); // StringUtils.remove("queued", "zz") = "queued" assertEquals("queued", StringUtils.remove("queued", "zz")); }
public String capitalizeTrailingWords(String name) { char[] wordDelimiters = generationConfig.getPropertyWordDelimiters(); if (containsAny(name, wordDelimiters)) { String capitalizedNodeName; if (areAllWordsUpperCaseBesideDelimiters(name, wordDelimiters)) { capitalizedNodeName = WordUtils.capitalizeFully(name, wordDelimiters); } else { capitalizedNodeName = WordUtils.capitalize(name, wordDelimiters); } name = name.charAt(0) + capitalizedNodeName.substring(1); for (char c : wordDelimiters) { name = remove(name, c); } } else if (areAllWordsUpperCaseBesideDelimiters(name, wordDelimiters)) { name = WordUtils.capitalizeFully(name, wordDelimiters); } return name; }
private static UserTrade adaptUserTrade( BithumbTransaction bithumbTransaction, CurrencyPair currencyPair) { final String units = StringUtils.remove(bithumbTransaction.getUnits(), ' '); return new UserTrade.Builder() .currencyPair(currencyPair) .originalAmount(new BigDecimal(units).abs()) .type(adaptTransactionSearch(bithumbTransaction.getSearch())) .feeAmount(bithumbTransaction.getFee()) .feeCurrency(currencyPair.counter) .price(bithumbTransaction.getPrice()) .timestamp(new Date(bithumbTransaction.getTransferDate())) .build(); }
protected void computePattern() { if (highlightFilterText && !StringUtils.isEmpty(StringUtils.remove(filterText, '*'))) { // add the groups in the pattern String patternText = "(" + filterText.replace("*", ").*(") + ").*"; patternText = StringUtils.remove(patternText, "()"); pattern = Pattern.compile(patternText, Pattern.CASE_INSENSITIVE); } else { pattern = null; } } }
protected void computePattern() { if (highlightFilterText && !StringUtils.isEmpty(StringUtils.remove(filterText, '*'))) { // add the groups in the pattern String patternText = "(" + filterText.replace("*", ").*(") + ").*"; patternText = StringUtils.remove(patternText, "()"); pattern = Pattern.compile(patternText, Pattern.CASE_INSENSITIVE); } else { pattern = null; } } }
private static LocalDate dateFomName(File f) { try { return new LocalDate(StringUtils.remove(f.getName(), ".json.gz")); } catch (IllegalArgumentException e) { return null; } }
public String getFullRobotName() { String fullRobotName = getSdfFile(); fullRobotName = fullRobotName.substring(fullRobotName.lastIndexOf("/") + 1, fullRobotName.length()); fullRobotName = StringUtils.capitalize(fullRobotName); fullRobotName = StringUtils.remove(fullRobotName, "_hw"); fullRobotName = StringUtils.remove(fullRobotName, "_sim"); fullRobotName = StringUtils.remove(fullRobotName, ".sdf"); return fullRobotName; }
public File relativeTo(File file, File directory) { String filePath = separatorsToUnix(file.getPath()); String directoryPath = separatorsToUnix(directory.getPath()); if ( !directoryPath.endsWith(UNIX_SEPARATOR) ){ // ensure directory has a trailing separator // that will be removed from the full file path directoryPath = directoryPath + UNIX_SEPARATOR; } return new File(remove(filePath, directoryPath)); }
public static String getRelativePath(File dir, File file) { String dirPath = LocationUtils.getCanonicalPath(dir); String filePath = LocationUtils.getCanonicalPath(file); if (!StringUtils.contains(filePath, dirPath)) { throw new IllegalArgumentException(file + " does not reside under " + dir); } return StringUtils.remove(filePath, dirPath); }
/** * Method creates a filename to store the service. * * @param service - Service to be stored. * @param extension - extension to use for the file. * @return - String representing file name. */ @Override public String build(final RegisteredService service, final String extension) { return StringUtils.remove(service.getName(), ' ') + '-' + service.getId() + '.' + extension; } }
/** * @param files Files * @return Expanded filenames */ public List<Path> getExpanded(final List<Path> files) { final List<Path> expanded = new ArrayList<Path>(); for(Path file : files) { expanded.add(new Path(file.getParent(), StringUtils.remove(file.getName(), String.format(".%s", this.getIdentifier())), EnumSet.of(Path.Type.file))); } return expanded; }