List of usage examples for com.google.common.base Splitter on
@CheckReturnValue @GwtIncompatible("java.util.regex") public static Splitter on(final Pattern separatorPattern)
From source file:org.dcache.gplazma.util.JsonWebToken.java
public static boolean isCompatibleFormat(String token) { List<String> elements = Splitter.on('.').limit(3).splitToList(token); return elements.size() == 3 && elements.stream().allMatch(JsonWebToken::isBase64Encoded); }
From source file:de.metas.ui.web.window.model.DocumentQueryOrderBy.java
/** * @param orderBysListStr Command separated field names. Use +/- prefix for ascending/descending. e.g. +C_BPartner_ID,-DateOrdered */// w ww .j av a 2 s . c o m public static final List<DocumentQueryOrderBy> parseOrderBysList(final String orderBysListStr) { if (Check.isEmpty(orderBysListStr, true)) { return ImmutableList.of(); } return Splitter.on(',').trimResults().omitEmptyStrings().splitToList(orderBysListStr).stream() .map(orderByStr -> parseOrderBy(orderByStr)).collect(GuavaCollectors.toImmutableList()); }
From source file:hmi.animation.RenamingMap.java
public static BiMap<String, String> renamingMap(String renaming) { BiMap<String, String> renamingMap = HashBiMap.create(); Splitter split = Splitter .on(CharMatcher.WHITESPACE// w w w . j a va 2 s .com .or(CharMatcher.is('\n').or(CharMatcher.is('\r').or(CharMatcher.is('\f'))))) .trimResults().omitEmptyStrings(); String[] splittedStr = Iterables.toArray(split.split(renaming), String.class); if (splittedStr.length % 2 > 0) { throw new IllegalArgumentException("renaming string does not contain an even amount of names"); } for (int i = 0; i < splittedStr.length / 2; i++) { renamingMap.put(splittedStr[i * 2], splittedStr[i * 2 + 1]); } return renamingMap; }
From source file:com.globaldatachain.certscript.ScriptParser.java
public Iterable<Instruction> parse(String script) { Iterable<String> instructions = Splitter.on(Pattern.compile("(\\s|\\n)")).split(script); List<Instruction> parsed = new ArrayList<>(); for (String instruction : instructions) { if (instruction.startsWith("0x")) { parsed.add(new Push(new HexBinaryAdapter().unmarshal(instruction.substring(2)))); } else if (instruction.contentEquals("SWAP")) { parsed.add(new Swap()); } else if (instruction.contentEquals("HASH(SHA-256)")) { parsed.add(new HashSha256()); } else if (instruction.contentEquals("EQUAL")) { parsed.add(new Equal()); } else if (instruction.contentEquals("DUP")) { parsed.add(new Dup()); } else if (instruction.contentEquals("CONCAT")) { parsed.add(new Concat()); } else if (instruction.contentEquals("CHECK")) { parsed.add(new Check()); } else if (instruction.contentEquals("BTC_TX_OUTPUT_SCRIPT_PUB_KEY")) { parsed.add(new BtcTxOutputScriptPubKey()); } else if (instruction.contentEquals("BTC_TX_OUTPUT")) { parsed.add(new BtcTxOutput()); } else if (instruction.contentEquals("BTC_TX")) { parsed.add(new BtcTx(bitcoinTransactionRetriever)); } else if (instruction.isEmpty()) { } else {//from w w w. j ava 2 s. co m throw new IllegalArgumentException(instruction); } } return parsed; }
From source file:com.lithium.flow.filer.RegexSubpathPredicate.java
public RegexSubpathPredicate(@Nonnull String pathRegex) { checkNotNull(pathRegex); Splitter.on('/').split(pathRegex).forEach(part -> patterns.add(Pattern.compile(part))); }
From source file:org.openqa.selenium.internal.selenesedriver.FindElements.java
@Override protected List<Map<String, String>> executeFind(Selenium selenium, String how, String using, String parentLocator) {//from w ww. j a va 2 s. c o m String result = selenium.getEval(String.format(SCRIPT, how, using, parentLocator)); Iterable<String> allKeys = Splitter.on(",").split(result); List<Map<String, String>> toReturn = Lists.newArrayList(); for (String key : allKeys) { if (key.length() > 0) { toReturn.add(newElement(key)); } } return toReturn; }
From source file:fr.rjoakim.android.jonetouch.db.AuthenticationTypeDB.java
public static Iterable<String> buildInsertQueries() { final StringBuilder builder = new StringBuilder(); builder.append("INSERT INTO "); builder.append(TABLE_NAME).append(" (").append(COLUMN_NAME_ID).append(",").append(COLUMN_NAME_TYPE) .append(") "); builder.append("VALUES ('1', 'aucune');#"); builder.append("INSERT INTO "); builder.append(TABLE_NAME).append(" (").append(COLUMN_NAME_ID).append(",").append(COLUMN_NAME_TYPE) .append(") "); builder.append("VALUES ('2', 'ssh avec mot de passe');"); return Splitter.on("#").split(builder.toString()); }
From source file:org.arbeitspferde.groningen.subject.open.ProcessServingAddressGenerator.java
public static ProcessServingAddressInfo parseAddress(final String address) { int processId; String[] addressParts = Iterables.toArray(Splitter.on("/").split(address), String.class); try {//from w ww . j a va2 s.c o m processId = Integer.parseInt(addressParts[addressParts.length - 1]); } catch (NumberFormatException e) { return null; } return new ProcessServingAddressInfo(addressParts[0], addressParts[1], addressParts[2], processId); }
From source file:com.ebay.xcelite.converters.DelimiterColumnValueConverter.java
@Override public Collection<?> deserialize(String value) { String str = (String) value; Iterable<String> split = Splitter.on(getDelimiter()).omitEmptyStrings().trimResults().split(str); return getCollection(split); }
From source file:org.gradle.vcs.git.internal.GitVersionRef.java
private static String extractName(Ref ref) { List<String> parts = Splitter.on("/").splitToList(ref.getName()); return parts.get(parts.size() - 1); }