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.apache.james.jmap.utils.SortConverter.java
private static SearchQuery.Sort toSort(String jmapSort) { Preconditions.checkNotNull(jmapSort); List<String> splitToList = Splitter.on(SEPARATOR).splitToList(jmapSort); checkField(splitToList);//from w w w .j av a 2s . c om return new SearchQuery.Sort(getSortClause(splitToList.get(0)), isReverse(splitToList)); }
From source file:org.apache.curator.x.async.modeled.details.ZPathImpl.java
private static ZPathImpl parseInternal(String fullPath, UnaryOperator<String> nameFilter) { List<String> nodes = ImmutableList.<String>builder().add(PATH_SEPARATOR).addAll(Splitter.on(PATH_SEPARATOR) .omitEmptyStrings().splitToList(fullPath).stream().map(nameFilter).collect(Collectors.toList())) .build();/*w ww . j a v a2 s. c om*/ nodes.forEach(ZPathImpl::validate); return new ZPathImpl(nodes, null); }
From source file:com.github.zhongl.api.FileParser.java
public void parse(File file) throws IOException { bindBuilders();// ww w .j a v a2 s . co m List<String> lines = Files.readLines(file, Charset.defaultCharset()); for (String line : lines) { Iterator<String> iterator = Splitter.on('\t').omitEmptyStrings().trimResults().split(line).iterator(); list.add(map.get(iterator.next()).build(iterator)); } }
From source file:org.rf.ide.core.executor.RedSystemProperties.java
private static ImmutableList<String> getPaths(final String name) { final String paths = System.getenv(name); if (paths == null || paths.isEmpty()) { return ImmutableList.of(); }//from w w w . ja va2 s . c o m return ImmutableList.copyOf(Splitter.on(getPathsSeparator()).splitToList(paths)); }
From source file:ezbake.amino.cli.commands.CreateGroup.java
public static Set<TGroupMember> parseGroupMembers(Collection<String> groupMembers) { return ImmutableSet.copyOf(Collections2.transform(groupMembers, new Function<String, TGroupMember>() { @Override// ww w . j ava2 s . c o m public TGroupMember apply(String member) { String[] memberAndRole = member.split(":"); String name = memberAndRole[0]; Set<TGroupRole> roles = ImmutableSet.copyOf(Iterables .transform(Splitter.on(',').split(memberAndRole[1]), new Function<String, TGroupRole>() { @Override public TGroupRole apply(String name) { return TGroupRole.valueOf(name); } })); return new TGroupMember(name, roles); } })); }
From source file:io.urmia.util.StringUtils.java
public static Iterable<String> splitRespectEscape(String s, char c) { String cs = shouldEscape(c) ? "\\" + c : Character.toString(c); Pattern p = Pattern.compile("[^\\\\]" + cs); //return Splitter.on(c).omitEmptyStrings().trimResults().split(s); return Splitter.on(p).omitEmptyStrings().trimResults().split(s); }
From source file:dropship.agent.statsd.SnitchService.java
private static String getHostname() { String defaultHostname = "localhost"; try {//from w ww . j a v a 2 s . c o m return Iterables.getFirst(Splitter.on('.').split(InetAddress.getLocalHost().getHostName()), defaultHostname); } catch (Exception e) { return defaultHostname; } }
From source file:org.dcache.macaroons.Caveat.java
public Caveat(String caveat) throws InvalidCaveatException { List<String> keyvalue = Splitter.on(SEPARATOR).limit(2).splitToList(caveat); checkCaveat(keyvalue.size() == 2, "Missing ':'"); String label = keyvalue.get(0); value = keyvalue.get(1);//from w ww. j av a2 s .co m type = CaveatType.identify(label); }
From source file:org.acoustid.data.sql.DataUtils.java
private static int[] decodeIntArray(CharSequence str, char sep) { int length = 1 + CharMatcher.is(sep).countIn(str); int[] result = new int[length]; Iterator<String> iter = Splitter.on(sep).split(str).iterator(); int i = 0;//from w w w. ja v a 2s. co m while (iter.hasNext()) { long longValue = Long.parseLong(iter.next(), 10); result[i++] = (longValue <= Integer.MAX_VALUE) ? (int) (longValue) : (int) (longValue & Integer.MAX_VALUE - Integer.MAX_VALUE - 1); } return result; }
From source file:io.macgyver.plugin.etcd.EtcdClientServiceFactory.java
@Override protected Object doCreateInstance(ServiceDefinition def) { Properties p = def.getProperties(); String uriList = p.getProperty("uri", "http://127.0.0.1:4001"); List<String> x = Splitter.on(Pattern.compile("[;,\\s]")).omitEmptyStrings().splitToList(uriList); logger.info("etcd uri list: {}", x); List<URI> tmp = Lists.newArrayList(); for (String uri : x) { try {// w w w . ja va2s . c o m URI u = URI.create(uri); tmp.add(u); } catch (Exception e) { logger.warn("problem parsing uri", e); } } EtcdClient c = new EtcdClient(tmp.toArray(new URI[0])); return c; }