List of usage examples for org.apache.commons.lang3 StringUtils deleteWhitespace
public static String deleteWhitespace(final String str)
Deletes all whitespaces from a String as defined by Character#isWhitespace(char) .
StringUtils.deleteWhitespace(null) = null StringUtils.deleteWhitespace("") = "" StringUtils.deleteWhitespace("abc") = "abc" StringUtils.deleteWhitespace(" ab c ") = "abc"
From source file:gov.nih.nci.firebird.selenium2.pages.components.tags.search.PersonSearchTagHelper.java
private boolean areEquivalent(SearchResultListing<?> listing, Person person) { return listing.getName().equals(person.getDisplayNameForList()) && StringUtils.deleteWhitespace(listing.getAddress()) .equals(StringUtils.deleteWhitespace(person.getPostalAddress().toString())) && listing.getEmailAddress().equals(person.getEmail()); }
From source file:eu.europa.ec.fisheries.uvms.rules.service.business.AbstractFact.java
private List<String> getXpathsForProps(String propertyNames) { List<String> xpathsList = new ArrayList<>(); if (StringUtils.isNotEmpty(propertyNames)) { String propNamesTrimmed = StringUtils.deleteWhitespace(propertyNames); String[] propNames = propNamesTrimmed.split(","); for (String propName : propNames) { xpathsList.add(XPathRepository.INSTANCE.getMapForSequence(this.getSequence(), propName)); }//from w w w .j a v a2s . co m } return xpathsList; }
From source file:com.github.mavogel.ilias.utils.IOUtils.java
/** * Checks if the line contains the {@link Defaults#CHOICE_WILDCARD} character. * * @param line the line to check//from www. jav a2 s.c o m * @return true if it contains the character, false otherwise */ private static boolean containsWildcard(final String line) { return StringUtils.deleteWhitespace(line).equalsIgnoreCase(Defaults.CHOICE_WILDCARD.toLowerCase()); }
From source file:io.bitsquare.btc.WalletService.java
@Inject public WalletService(RegTestHost regTestHost, TradeWalletService tradeWalletService, AddressEntryList addressEntryList, UserAgent userAgent, Preferences preferences, Socks5ProxyProvider socks5ProxyProvider, @Named(BtcOptionKeys.WALLET_DIR) File appDir, @Named(NetworkOptionKeys.SOCKS5_DISCOVER_MODE) String socks5DiscoverModeString) { this.regTestHost = regTestHost; this.tradeWalletService = tradeWalletService; this.addressEntryList = addressEntryList; this.preferences = preferences; this.socks5ProxyProvider = socks5ProxyProvider; this.params = preferences.getBitcoinNetwork().getParameters(); this.walletDir = new File(appDir, "bitcoin"); this.userAgent = userAgent; storage = new Storage<>(walletDir); Long persisted = storage.initAndGetPersistedWithFileName("BloomFilterNonce"); if (persisted != null) { bloomFilterTweak = persisted;/*from w w w .jav a 2 s. c o m*/ } else { bloomFilterTweak = new Random().nextLong(); storage.queueUpForSave(bloomFilterTweak, 100); } String[] socks5DiscoverModes = StringUtils.deleteWhitespace(socks5DiscoverModeString).split(","); int mode = 0; for (int i = 0; i < socks5DiscoverModes.length; i++) { switch (socks5DiscoverModes[i]) { case "ADDR": mode |= Socks5MultiDiscovery.SOCKS5_DISCOVER_ADDR; break; case "DNS": mode |= Socks5MultiDiscovery.SOCKS5_DISCOVER_DNS; break; case "ONION": mode |= Socks5MultiDiscovery.SOCKS5_DISCOVER_ONION; break; case "ALL": default: mode |= Socks5MultiDiscovery.SOCKS5_DISCOVER_ALL; break; } } socks5DiscoverMode = mode; }
From source file:com.github.mavogel.ilias.utils.IOUtils.java
/** * Reads and parses a single choice from the user.<br> * Handles wrong inputs and ensures the choice is in * the range of the possible choices./*w w w. j ava 2 s . c o m*/ * * @param choices the possible choices * @return the choice of the user. */ public static int readAndParseSingleChoiceFromUser(final List<?> choices) { boolean isCorrectInput = false; String line = null; int userChoice = -1; Scanner scanner = new Scanner(System.in); while (!isCorrectInput) { try { LOG.info("A single choice only! (E.g.: 1)"); line = StringUtils.deleteWhitespace(scanner.nextLine()); userChoice = Integer.valueOf(line); isCorrectInput = isInRange(choices, userChoice); } catch (NumberFormatException nfe) { LOG.error("'" + line + "' is not a number! Try again"); } catch (IllegalArgumentException iae) { LOG.error(iae.getMessage()); } } return userChoice; }
From source file:com.linkedin.pinot.hadoop.io.PinotOutputFormat.java
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); }/*from w ww . java2 s . co m*/ } }
From source file:com.github.mavogel.ilias.utils.IOUtils.java
/** * Reads and parses the registration period.<br> * Validates the format and that the start is after the end. * * @return the {@link RegistrationPeriod} *//*from w ww.j av a 2s. com*/ public static RegistrationPeriod readAndParseRegistrationDates() { LOG.info("Date need to be of the format 'yyyy-MM-ddTHH:mm'. E.g.: 2016-04-15T13:00"); // TODO get from the formatter LocalDateTime registrationStart = null, registrationEnd = null; boolean validStart = false, validEnd = false; Scanner scanner = new Scanner(System.in); while (!validStart) { LOG.info("Registration start: "); String line = StringUtils.deleteWhitespace(scanner.nextLine()); try { registrationStart = LocalDateTime.parse(line, Defaults.DATE_FORMAT); validStart = true; } catch (DateTimeParseException dtpe) { LOG.error("'" + line + "' is not a valid date"); } } while (!validEnd) { LOG.info("Registration end: "); String line = scanner.nextLine(); try { registrationEnd = LocalDateTime.parse(line, Defaults.DATE_FORMAT); validEnd = registrationStart.isBefore(registrationEnd); if (!validEnd) { LOG.error("End of registration has to be after the start'" + registrationStart + "'"); } } catch (DateTimeParseException dtpe) { LOG.error("'" + line + "' is not a valid date"); } } return new RegistrationPeriod(registrationStart, registrationEnd); }
From source file:com.github.mavogel.ilias.utils.IOUtils.java
/** * Reads and parses a positive integer./*from w w w .ja v a2 s. com*/ * * @return the positive integer. */ public static int readAndParsePositiveInteger() { boolean isCorrectInput = false; String line = null; int positiveInteger = -1; Scanner scanner = new Scanner(System.in); while (!isCorrectInput) { try { LOG.info("Enter a positive integer:"); line = StringUtils.deleteWhitespace(scanner.nextLine()); positiveInteger = Integer.valueOf(line); isCorrectInput = positiveInteger >= 0; } catch (NumberFormatException nfe) { LOG.error("'" + line + "' is not a positive integer! Try again"); } catch (IllegalArgumentException iae) { LOG.error(iae.getMessage()); } } return positiveInteger; }
From source file:com.github.mavogel.ilias.utils.IOUtils.java
/** * Reads and parses the confirmation of the user for an action. * * @return <code>true</code> if the user confirmed with Y for YES, <code>false</code> otherwise. *///from ww w . j ava 2 s. c om public static boolean readAndParseUserConfirmation() { LOG.info("Confirm please: [Y] or [N]"); boolean validChoice = false; boolean choice = false; Scanner scanner = new Scanner(System.in); while (!validChoice) { String line = scanner.nextLine(); if (StringUtils.deleteWhitespace(line).equalsIgnoreCase("Y")) { choice = true; validChoice = true; } else if (StringUtils.deleteWhitespace(line).equalsIgnoreCase("N")) { choice = false; validChoice = true; } else { LOG.error("Invalid choice. Try again!"); } } return choice; }
From source file:com.sample.domain.entities.anagrafica.Cliente.java
public void setCellulare(String cellulare) { this.cellulare = StringUtils.deleteWhitespace(cellulare); setSmsAbilitato(this.cellulare != null && !this.cellulare.equals("")); }