List of usage examples for com.google.common.base Splitter splitToList
@CheckReturnValue
@Beta
public List<String> splitToList(CharSequence sequence)
From source file:com.google.javascript.refactoring.RefasterJs.java
private List<String> getInputs() throws IOException { Set<String> patterns = new HashSet<>(); // The args4j library can't handle multiple files provided within the same flag option, // like --inputs=file1.js,file2.js so handle that here. Splitter commaSplitter = Splitter.on(','); for (String input : inputs) { patterns.addAll(commaSplitter.splitToList(input)); }//from w w w . j a va2s .c om patterns.addAll(arguments); return CommandLineRunner.findJsFiles(patterns); }
From source file:com.google.javascript.refactoring.RefasterJs.java
private List<String> getExterns() throws IOException { Set<String> patterns = new HashSet<>(); // The args4j library can't handle multiple files provided within the same flag option, // like --externs=file1.js,file2.js so handle that here. Splitter commaSplitter = Splitter.on(','); for (String extern : externs) { patterns.addAll(commaSplitter.splitToList(extern)); }//from w ww . j a va 2 s .co m return CommandLineRunner.findJsFiles(patterns); }
From source file:ratpack.config.internal.source.ArgsConfigSource.java
@Override protected Properties loadProperties() throws Exception { Splitter splitter = Splitter.on(separator).limit(2); Properties properties = new Properties(); for (String arg : args) { List<String> values = splitter.splitToList(arg); if (values.size() == 1) { properties.put(values.get(0), ""); } else {//from w w w . j a v a 2s .c om properties.put(values.get(0), values.get(1)); } } return properties; }
From source file:com.linkedin.pinot.broker.requesthandler.MultipleOrEqualitiesToInClauseFilterQueryTreeOptimizer.java
private List<String> valueDoubleTabListToElements(String doubleTabSeparatedElements) { Splitter valueSplitter = Splitter.on("\t\t"); return valueSplitter.splitToList(doubleTabSeparatedElements); }
From source file:org.eobjects.datacleaner.util.DefaultEnumMatcher.java
private Collection<String> findSecondaryMatchStrings(String string) { if (string == null) { return Collections.emptySet(); }//from w ww . j a va2s .c o m string = StringUtils.replaceAll(string, "-", " "); string = StringUtils.replaceAll(string, "_", " "); string = StringUtils.replaceAll(string, "|", " "); string = StringUtils.replaceAll(string, "*", " "); string = StringUtils.replaceAll(string, " ", " "); string = string.trim(); string = string.toUpperCase(); final Splitter splitter = Splitter.on(' '); final List<String> words1 = splitter.splitToList(string); string = string.replaceAll("[0-9]", ""); final List<String> words2 = splitter.splitToList(string); string = StringUtils.replaceWhitespaces(string, ""); final List<String> words3 = splitter.splitToList(string); final Collection<String> result = new HashSet<String>(); result.addAll(words1); result.addAll(words2); result.addAll(words3); return result; }
From source file:org.datacleaner.util.DefaultEnumMatcher.java
/** * Normalizes the incoming string before doing matching * /* w w w .j a v a 2 s . co m*/ * @param string * @param tokenize * @return */ protected Collection<String> normalize(String string, boolean tokenize) { if (string == null) { return Collections.emptyList(); } if (tokenize) { final Collection<String> result = new LinkedHashSet<>(); result.addAll(normalize(string, false)); final Splitter splitter = Splitter.on(' ').omitEmptyStrings(); final List<String> tokens = splitter.splitToList(string); for (String token : tokens) { final Collection<String> normalizedTokens = normalize(token, false); result.addAll(normalizedTokens); } return result; } else { string = StringUtils.replaceWhitespaces(string, ""); string = StringUtils.replaceAll(string, "-", ""); string = StringUtils.replaceAll(string, "_", ""); string = StringUtils.replaceAll(string, "|", ""); string = StringUtils.replaceAll(string, "*", ""); string = string.toUpperCase(); if (string.isEmpty()) { return Collections.emptyList(); } final String withoutNumbers = string.replaceAll("[0-9]", ""); if (withoutNumbers.equals(string) || withoutNumbers.isEmpty()) { return Arrays.asList(string); } return Arrays.asList(string, withoutNumbers); } }
From source file:org.sosy_lab.cpachecker.util.cwriter.CExpressionInvariantExporter.java
/** * Export invariants extracted from {@code pReachedSet} into the file * specified by the options as {@code __VERIFIER_assume()} calls, * intermixed with the program source code. *///from www. j a v a2 s . c o m public void exportInvariant(String analyzedPrograms, ReachedSet pReachedSet) throws IOException, InterruptedException { Splitter commaSplitter = Splitter.on(',').omitEmptyStrings().trimResults(); List<String> programs = commaSplitter.splitToList(analyzedPrograms); for (String program : programs) { // Grab only the last component of the program filename. Path trimmedFilename = Paths.get(program).getFileName(); if (trimmedFilename != null) { try (Writer output = MoreFiles.openOutputFile(prefix.getPath(trimmedFilename.toString()), Charset.defaultCharset())) { writeProgramWithInvariants(output, program, pReachedSet); } } } }
From source file:org.apache.gobblin.compliance.purger.HivePurgerPublisher.java
private void submitEvent(WorkUnitState state, String name) { WorkUnit workUnit = state.getWorkunit(); Map<String, String> metadata = new HashMap<>(); String recordsRead = state.getProp(ComplianceConfigurationKeys.NUM_ROWS); metadata.put(ComplianceConfigurationKeys.WORKUNIT_RECORDSREAD, recordsRead); metadata.put(ComplianceConfigurationKeys.WORKUNIT_BYTESREAD, getDataSize(workUnit.getProp(ComplianceConfigurationKeys.RAW_DATA_SIZE), workUnit.getProp(ComplianceConfigurationKeys.TOTAL_SIZE))); String partitionNameProp = workUnit.getProp(ComplianceConfigurationKeys.PARTITION_NAME); Splitter AT_SPLITTER = Splitter.on("@").omitEmptyStrings().trimResults(); List<String> namesList = AT_SPLITTER.splitToList(partitionNameProp); if (namesList.size() != 3) { log.warn("Not submitting event. Invalid partition name: " + partitionNameProp); return;/* w ww . j av a 2 s . co m*/ } String dbName = namesList.get(0), tableName = namesList.get(1), partitionName = namesList.get(2); org.apache.hadoop.hive.metastore.api.Partition apiPartition = null; Partition qlPartition = null; try { Table table = new Table(this.client.getTable(dbName, tableName)); apiPartition = this.client.getPartition(dbName, tableName, partitionName); qlPartition = new Partition(table, apiPartition); } catch (Exception e) { log.warn("Not submitting event. Failed to resolve partition '" + partitionName + "': " + e); e.printStackTrace(); return; } HivePartitionDataset hivePartitionDataset = new HivePartitionDataset(qlPartition); String recordsWritten = DatasetUtils.getProperty(hivePartitionDataset, ComplianceConfigurationKeys.NUM_ROWS, ComplianceConfigurationKeys.DEFAULT_NUM_ROWS); String recordsPurged = Long.toString((Long.parseLong(recordsRead) - Long.parseLong(recordsWritten))); metadata.put(ComplianceConfigurationKeys.WORKUNIT_RECORDSWRITTEN, recordsWritten); metadata.put(ComplianceConfigurationKeys.WORKUNIT_BYTESWRITTEN, getDataSize( DatasetUtils.getProperty(hivePartitionDataset, ComplianceConfigurationKeys.RAW_DATA_SIZE, ComplianceConfigurationKeys.DEFAULT_RAW_DATA_SIZE), DatasetUtils.getProperty(hivePartitionDataset, ComplianceConfigurationKeys.TOTAL_SIZE, ComplianceConfigurationKeys.DEFAULT_TOTAL_SIZE))); metadata.put(DatasetMetrics.DATABASE_NAME, hivePartitionDataset.getDbName()); metadata.put(DatasetMetrics.TABLE_NAME, hivePartitionDataset.getTableName()); metadata.put(DatasetMetrics.PARTITION_NAME, hivePartitionDataset.getName()); metadata.put(DatasetMetrics.RECORDS_PURGED, recordsPurged); this.eventSubmitter.submit(name, metadata); }
From source file:org.graylog.plugins.map.search.MapDataSearch.java
private Map<String, Long> validateTerms(final String field, final Map<String, Long> terms) throws ValueTypeException { final Splitter splitter = Splitter.on(',').omitEmptyStrings().trimResults(); for (String term : terms.keySet()) { if (Strings.isNullOrEmpty(term)) { continue; }//w w w.j av a 2 s. c o m final List<String> list = splitter.splitToList(term); if (list.size() != 2) { throw getValueTypeException(field, term); } for (String value : list) { if (!VALIDATION_PATTERN.matcher(value).matches()) { throw getValueTypeException(field, term); } } } return terms; }
From source file:com.linkedin.pinot.broker.requesthandler.MultipleOrEqualitiesToInClauseFilterQueryTreeOptimizer.java
private List<String> valueDoubleTabListToElements(List<String> doubleTabSeparatedElements) { Splitter valueSplitter = Splitter.on("\t\t"); List<String> valueElements = new ArrayList<>(); for (String value : doubleTabSeparatedElements) { valueElements.addAll(valueSplitter.splitToList(value)); }//from ww w .ja v a 2 s .c o m return valueElements; }