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.jboss.hal.dmr.ResourceAddress.java
/** Creates a new resource address from the specified string. */ public static ResourceAddress from(String address) { if (Strings.isNullOrEmpty(address)) { throw new IllegalArgumentException("Address must not be null or empty"); }/* ww w . j a va 2 s . c o m*/ String safeAddress = address.startsWith("/") ? address.substring(1) : address; ResourceAddress ra = new ResourceAddress(); Map<String, String> segments = Splitter.on('/').omitEmptyStrings().withKeyValueSeparator('=') .split(safeAddress); for (Map.Entry<String, String> entry : segments.entrySet()) { ra.add(entry.getKey(), entry.getValue()); } return ra; }
From source file:org.apache.gobblin.runtime.plugins.GobblinInstancePluginUtils.java
/** * Parse a collection of {@link GobblinInstancePluginFactory} from the system configuration by reading the key * {@link #PLUGINS_KEY}.//from w w w. j av a2s .c om */ public static Collection<GobblinInstancePluginFactory> instantiatePluginsFromSysConfig(Config config) throws ClassNotFoundException, InstantiationException, IllegalAccessException { String pluginsStr = config.getString(PLUGINS_KEY); List<GobblinInstancePluginFactory> plugins = Lists.newArrayList(); for (String pluginName : Splitter.on(",").split(pluginsStr)) { plugins.add(instantiatePluginByAlias(pluginName)); } return plugins; }
From source file:tv.icntv.log.stb.commons.SplitterIcntv.java
public static Map<String, String> toMap(Iterable<String> iterable, String split) { Iterator<String> it = iterable.iterator(); Map<String, String> maps = Maps.newHashMap(); while (it.hasNext()) { String value = it.next(); List<String> result = Lists.newArrayList(Splitter.on(split).trimResults().limit(2).split(value)); if (result.size() != 2) { logger.error("message = {}", value); continue; }/* w ww . ja v a 2 s . com*/ maps.put(result.get(0), result.get(1)); } return maps; }
From source file:com.ebay.pulsar.analytics.cache.CacheConfig.java
public void setUnCacheable(String unCacheable) { if (unCacheable == null) this.unCacheable = new ArrayList<String>(); else/* www .jav a2 s . c o m*/ this.unCacheable = Splitter.on(",").omitEmptyStrings().splitToList(unCacheable); }
From source file:com.atlassian.jira.rest.client.internal.json.ProjectJsonParser.java
static Iterable<String> parseExpandos(final JSONObject json) throws JSONException { if (json.has("expand")) { final String expando = json.getString("expand"); return Splitter.on(',').split(expando); } else {/* w ww . j a va 2s . co m*/ return Collections.emptyList(); } }
From source file:org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.DatacenterAndName.java
public static DatacenterAndName fromSlashEncoded(String name) { Iterable<String> parts = Splitter.on('/').split(checkNotNull(name, "name")); checkArgument(Iterables.size(parts) == 2, "name must be in format datacenterId/name"); return new DatacenterAndName(Iterables.get(parts, 0), Iterables.get(parts, 1)); }
From source file:org.eclipse.che.inject.PairArrayConverter.java
@Override public Object convert(String value, TypeLiteral<?> toType) { final String[] pairs = Iterables.toArray(Splitter.on(",").split(value), String.class); @SuppressWarnings("unchecked") final Pair<String, String>[] result = new Pair[pairs.length]; for (int i = 0; i < pairs.length; i++) { result[i] = PairConverter.fromString(pairs[i]); }//ww w. ja va2 s.co m return result; }
From source file:com.mgmtp.perfload.agent.util.ClassNameUtils.java
public static String abbreviatePackageName(String className) { if (className.contains(".")) { String packageName = substringBeforeLast(className, "."); String simpleClassName = substringAfterLast(className, "."); List<String> list = from(Splitter.on('.').splitToList(packageName)) .transform(new Function<String, String>() { @Override/* ww w .j a va 2 s.c o m*/ public String apply(String input) { return input.substring(0, 1); } }).toList(); return Joiner.on('.').join(list) + '.' + simpleClassName; } else { return className; } }
From source file:org.haiku.haikudepotserver.support.web.NaturalLanguageWebHelper.java
/** * <p>This will look at parameters on the supplied request and will return a natural language. It will * resort to English language if no other language is able to be derived.</p> *//*ww w . j av a 2 s . c o m*/ public static NaturalLanguage deriveNaturalLanguage(ObjectContext context, HttpServletRequest request) { Preconditions.checkNotNull(context); if (null != request) { String naturalLanguageCode = request.getParameter(WebConstants.KEY_NATURALLANGUAGECODE); if (!Strings.isNullOrEmpty(naturalLanguageCode)) { Optional<NaturalLanguage> naturalLanguageOptional = NaturalLanguage.getByCode(context, naturalLanguageCode); if (naturalLanguageOptional.isPresent()) { return naturalLanguageOptional.get(); } else { LOGGER.info("the natural language '{}' was specified, but was not able to be found", naturalLanguageCode); } } // see if we can deduce it from the locale. Locale locale = request.getLocale(); if (null != locale) { Iterator<String> langI = Splitter.on(Pattern.compile("[-_]")).split(locale.toLanguageTag()) .iterator(); if (langI.hasNext()) { Optional<NaturalLanguage> naturalLanguageOptional = NaturalLanguage.getByCode(context, langI.next()); if (naturalLanguageOptional.isPresent() && naturalLanguageOptional.get().getIsPopular()) { return naturalLanguageOptional.get(); } } } } return NaturalLanguage.getByCode(context, NaturalLanguage.CODE_ENGLISH).get(); }
From source file:io.hops.metadata.yarn.entity.ApplicationId.java
private void build() { Iterator<String> it = Splitter.on('_').trimResults().split(id).iterator(); it.next(); // prefix. clustertimestamp = Long.parseLong(it.next()); appId = Integer.parseInt(it.next()); }