List of usage examples for com.google.common.base Splitter split
@CheckReturnValue public Iterable<String> split(final CharSequence sequence)
From source file:com.android.build.gradle.internal.pipeline.TransformTask.java
private boolean updateIncrementalInputsWithChangedFiles(@NonNull List<IncrementalTransformInput> consumedInputs, @NonNull List<IncrementalTransformInput> referencedInputs, @NonNull Map<File, Status> changedFilesMap, @NonNull Set<File> removedFiles) { // we're going to concat both list multiple times, and the Iterators API ultimately put // all the iterators to concat in a list. So let's reuse a list. List<Iterator<IncrementalTransformInput>> iterators = Lists.newArrayListWithCapacity(2); Splitter splitter = Splitter.on(File.separatorChar); // start with the removed files as they carry the risk of removing incremental mode. // If we detect such a case, we stop immediately. for (File removedFile : removedFiles) { List<String> removedFileSegments = Lists.newArrayList(splitter.split(removedFile.getAbsolutePath())); Iterator<IncrementalTransformInput> iterator = getConcatIterator(consumedInputs, referencedInputs, iterators);/* w w w .j a va 2s .c om*/ boolean found = false; while (iterator.hasNext()) { IncrementalTransformInput next = iterator.next(); if (next.checkRemovedJarFile(Sets.union(transform.getScopes(), transform.getReferencedScopes()), transform.getInputTypes(), removedFile, removedFileSegments) || next.checkRemovedFolderFile( Sets.union(transform.getScopes(), transform.getReferencedScopes()), transform.getInputTypes(), removedFile, removedFileSegments)) { found = true; break; } } if (!found && !isSecondaryFile(removedFile)) { // this deleted file breaks incremental because we cannot figure out where it's // coming from and what types/scopes is associated with it. return false; } } // now handle the added/changed files. for (Map.Entry<File, Status> entry : changedFilesMap.entrySet()) { File changedFile = entry.getKey(); Status changedStatus = entry.getValue(); // first go through the jars first as it's a faster check. Iterator<IncrementalTransformInput> iterator = getConcatIterator(consumedInputs, referencedInputs, iterators); boolean found = false; while (iterator.hasNext()) { if (iterator.next().checkForJar(changedFile, changedStatus)) { // we can skip to the next changed file. found = true; break; } } if (found) { continue; } // now go through the folders. First get a segment list for the path. iterator = getConcatIterator(consumedInputs, referencedInputs, iterators); List<String> changedSegments = Lists.newArrayList(splitter.split(changedFile.getAbsolutePath())); while (iterator.hasNext()) { if (iterator.next().checkForFolder(changedFile, changedSegments, changedStatus)) { // we can skip to the next changed file. break; } } } return true; }
From source file:org.glowroot.container.impl.JavaagentContainer.java
public List<String> getUnexpectedConsoleLines() { List<String> unexpectedLines = Lists.newArrayList(); Splitter splitter = Splitter.on(Pattern.compile("\r?\n")).omitEmptyStrings(); String capturedOutput = consoleOutputPipe.getCapturedOutput(); if (capturedOutput == null) { throw new IllegalStateException("Cannot check console lines unless JavaagentContainer" + " was created with captureConsoleOutput=true"); }/* w w w . j a v a 2s. co m*/ for (String line : splitter.split(capturedOutput)) { if (line.contains("Glowroot started") || line.contains("Glowroot listening") || line.contains("Glowroot plugins loaded")) { continue; } unexpectedLines.add(line); } return unexpectedLines; }
From source file:com.facebook.buck.cli.BuckConfig.java
public ImmutableSet<String> getListenerJars() { String jarPathsString = getValue("extensions", "listeners").or(""); Splitter splitter = Splitter.on(',').omitEmptyStrings().trimResults(); return ImmutableSet.copyOf(splitter.split(jarPathsString)); }
From source file:com.mattc.argus2.io.ListFile.java
@Override public void load(File file) { StringWriter writer = null;//from w ww . jav a2s . c o m FileReader reader = null; try { final Splitter splitter = Splitter.onPattern("\r?\n").omitEmptyStrings().trimResults(); String result = null; final char[] buf = new char[1024]; writer = new StringWriter(); reader = new FileReader(file); for (int c = reader.read(buf); c != -1; c = reader.read(buf)) { writer.write(buf, 0, c); } // Assemble defaults result = writer.toString(); this.defaults.clear(); // Ensure that Comments are not included. for (final String s : splitter.split(result)) { if (!s.startsWith("#")) { this.defaults.add(s); } } // -- } catch (final IOException e) { Console.exception(e); } finally { IOUtils.closeSilently(writer); IOUtils.closeSilently(reader); } this.items.addAll(this.defaults); Configs.ensureFilesExist(this); }
From source file:com.facebook.buck.cli.BuckConfig.java
@VisibleForTesting DefaultJavaPackageFinder createDefaultJavaPackageFinder() { Optional<String> srcRootsOptional = getValue("java", "src_roots"); ImmutableSet<String> paths; if (srcRootsOptional.isPresent()) { String srcRoots = srcRootsOptional.get(); Splitter splitter = Splitter.on(',').omitEmptyStrings().trimResults(); paths = ImmutableSet.copyOf(splitter.split(srcRoots)); } else {//from w w w . j av a 2 s . c o m paths = ImmutableSet.of(); } return DefaultJavaPackageFinder.createDefaultJavaPackageFinder(paths); }
From source file:com.zimbra.cs.mailclient.smtp.SmtpConnection.java
/** * Reads replies to {@code EHLO} or {@code HELO}. * <p>/* w ww .j a v a 2 s .co m*/ * Returns the reply code. Handles multiple {@code 250} responses. * * @param command the command name * @param firstReply the first reply line returned from sending {@code EHLO} or {@code HELO} */ private int readHelloReplies(String command, Reply firstReply) throws IOException { Reply reply = firstReply; int line = 1; serverExtensions.clear(); serverAuthMechanisms.clear(); while (true) { if (reply.text == null) { throw new CommandFailedException(command, "Invalid server response at line " + line + ": " + reply); } if (reply.code != 250) { return reply.code; } if (line > 1) { // Parse server extensions. Matcher matcher = PAT_EXTENSION.matcher(reply.text); if (matcher.matches()) { String extName = matcher.group(1).toUpperCase(); serverExtensions.add(extName); if (extName.equals(AUTH)) { // Parse auth mechanisms. Splitter splitter = Splitter.on(CharMatcher.WHITESPACE).trimResults().omitEmptyStrings(); for (String mechanism : splitter.split(matcher.group(2))) { serverAuthMechanisms.add(mechanism.toUpperCase()); } } } } if (reply.last) { // Last 250 response. mailIn.trace(); return 250; } else { // Multiple response lines. reply = Reply.parse(mailIn.readLine()); } line++; } }
From source file:com.facebook.buck.cli.BuckConfig.java
/** * Return Strings so as to avoid a dependency on {@link LabelSelector}! *//*from w w w.j a v a2 s. c o m*/ ImmutableList<String> getDefaultRawExcludedLabelSelectors() { Optional<String> excludedRulesOptional = getValue("test", "excluded_labels"); if (excludedRulesOptional.isPresent()) { String excludedRules = excludedRulesOptional.get(); Splitter splitter = Splitter.on(',').omitEmptyStrings().trimResults(); ImmutableList.Builder<String> builder = new ImmutableList.Builder<>(); // Validate that all specified labels are valid. for (String raw : splitter.split(excludedRules)) { builder.add(raw); } return builder.build(); } else { return ImmutableList.of(); } }
From source file:com.google.sampling.experiential.client.ExperimentDefinitionPanel.java
protected boolean emailStringIsValid(String emailString) { Splitter sp = Splitter.on(",").trimResults().omitEmptyStrings(); for (String email : sp.split(emailString)) { if (!email.matches(EMAIL_REGEX)) { return false; }//w w w. j a va2s.c o m } return true; }
From source file:com.google.sampling.experiential.client.ExperimentDefinitionPanel.java
private void setAdminsOn(ExperimentDAO experiment) { List<String> admins = new ArrayList<String>(); String adminsText = adminList.getText(); if (adminsText.length() == 0) { admins.add(loginInfo.getEmailAddress()); } else {/* w ww . j a va2 s.c o m*/ Splitter sp = Splitter.on(",").trimResults().omitEmptyStrings(); for (String admin : sp.split(adminsText)) { admins.add(admin); } } String[] adminStrArray = new String[admins.size()]; adminStrArray = admins.toArray(adminStrArray); experiment.setAdmins(adminStrArray); }
From source file:com.google.sampling.experiential.client.ExperimentDefinitionPanel.java
private void setPublishedUsersOn(ExperimentDAO experiment) { List<String> userEmails = new ArrayList<String>(); String userListText = userList.getText(); if (userListText.length() > 0) { Splitter sp = Splitter.on(",").trimResults().omitEmptyStrings(); for (String userEmail : sp.split(userListText)) { userEmails.add(userEmail);/*from w w w. j a v a2 s . co m*/ } } String[] userEmailsStrArray = new String[userEmails.size()]; userEmailsStrArray = userEmails.toArray(userEmailsStrArray); experiment.setPublishedUsers(userEmailsStrArray); }