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.jclouds.cloudsigma.functions.MapToStaticIPInfo.java
@Override public StaticIPInfo apply(Map<String, String> from) { if (from.size() == 0) return null; if (from.size() == 0) return null; StaticIPInfo.Builder builder = new StaticIPInfo.Builder(); builder.ip(from.get("resource")); builder.user(from.get("user")); builder.netmask(from.get("netmask")); builder.nameservers(Splitter.on(' ').split(from.get("nameserver"))); builder.gateway(from.get("gateway")); try {//from ww w .ja va 2 s . co m return builder.build(); } catch (NullPointerException e) { logger.trace("entry missing data: %s; %s", e.getMessage(), from); return null; } }
From source file:com.nesscomputing.httpserver.log.file.FileRequestLogConfig.java
@Config("fields") @Default(REQUEST_LOG_FIELDS_DEFAULT)/*from ww w . j a v a 2 s. c om*/ public List<String> getLogFields() { return ImmutableList.copyOf(Splitter.on(",").split(REQUEST_LOG_FIELDS_DEFAULT)); }
From source file:com.cloudera.branchreduce.onezero.SimplifiedLpParser.java
public SimplifiedLpParser(String fileData) { this.fileContents = Lists.newArrayList(Splitter.on("\n").split(fileData)); }
From source file:com.github.lukaszkusek.xml.comparator.document.XPathLine.java
XPathLine(int index, String line, boolean ignoreNamespace) { this.index = index; List<String> lineElements = Splitter.on("\t").splitToList(line); setXPath(lineElements.get(0), ignoreNamespace); setValue(lineElements.get(1));//from w ww . j av a 2 s . c o m setAttributeNameAndValue(lineElements.get(2)); }
From source file:com.google.api.codegen.py.PythonContextCommon.java
public List<String> convertToCommentedBlock(String content) { if (Strings.isNullOrEmpty(content)) { return ImmutableList.<String>of(); }/*www . j a va2 s. c o m*/ List<String> comments = Splitter.on("\n").splitToList(content); ImmutableList.Builder<String> builder = ImmutableList.builder(); if (comments.size() > 1) { builder.add("\"\"\""); for (String comment : comments) { builder.add(comment); } builder.add("\"\"\""); } else { // one-line comment. builder.add("\"\"\"" + content + "\"\"\""); } return builder.build(); }
From source file:com.textocat.textokit.postagger.opennlp.DefaultFeatureExtractors.java
public static DefaultFeatureExtractors from(Properties props, MorphDictionary morphDict) { int prevTagsInHistory = ConfigPropertiesUtils.getIntProperty(props, "prevTags"); int leftContextSize = ConfigPropertiesUtils.getIntProperty(props, "leftContext"); int rightContextSize = ConfigPropertiesUtils.getIntProperty(props, "rightContext"); if (morphDict != null) { String morphDictVersion = ConfigPropertiesUtils.getStringProperty(props, PROP_DICTIONARY_VERSION); if (!Objects.equal(morphDictVersion, morphDict.getVersion())) { throw new IllegalStateException( String.format( "Dictionary versions do not match:\n" + "The feature extractors have %s\n" + "The supplied dictionary has %s", morphDictVersion, morphDict.getVersion())); }/*ww w. j a v a2 s .c om*/ } String targetGramCategoriesStr = ConfigPropertiesUtils.getStringProperty(props, "targetGramCategories"); Iterable<String> targetGramCategories = Splitter.on(',').trimResults().split(targetGramCategoriesStr); return new DefaultFeatureExtractors(prevTagsInHistory, leftContextSize, rightContextSize, targetGramCategories, morphDict); }
From source file:com.google.publicalerts.cap.validator.ValidatorUtil.java
public static Set<CapProfile> parseProfiles(String profileStr) { if (CapUtil.isEmptyOrWhitespace(profileStr)) { return ImmutableSet.of(); }//w ww. jav a2 s.c o m Splitter splitter = Splitter.on(",").trimResults().omitEmptyStrings(); List<String> profileList = Lists.newArrayList(splitter.split(profileStr)); Set<CapProfile> profiles = Sets.newHashSet(); for (CapProfile profile : CapProfiles.getProfiles()) { for (String p : profileList) { if (profile.getCode().equals(p)) { profiles.add(profile); } } } return profiles; }
From source file:org.apache.druid.java.util.common.parsers.DelimitedParser.java
public DelimitedParser(@Nullable final String delimiter, @Nullable final String listDelimiter, final boolean hasHeaderRow, final int maxSkipHeaderRows) { super(listDelimiter, hasHeaderRow, maxSkipHeaderRows); this.delimiter = delimiter != null ? delimiter : FlatTextFormat.DELIMITED.getDefaultDelimiter(); Preconditions.checkState(!this.delimiter.equals(getListDelimiter()), "Cannot have same delimiter and list delimiter of [%s]", this.delimiter); this.splitter = Splitter.on(this.delimiter); }
From source file:com.android.ide.eclipse.adt.internal.editors.layout.ActionBarHandler.java
@Override public List<String> getMenuIdNames() { String commaSeparatedMenus = getXmlAttribute(ATTR_MENU); List<String> menus = new ArrayList<String>(); Iterables.addAll(menus, Splitter.on(',').trimResults().omitEmptyStrings().split(commaSeparatedMenus)); return menus; }
From source file:google.registry.tools.CreateReservedListCommand.java
private static void validateListName(String name) { List<String> nameParts = Splitter.on('_').splitToList(name); checkArgument(nameParts.size() == 2, INVALID_FORMAT_ERROR_MESSAGE); String tld = nameParts.get(0); if (!tld.equals("common")) { assertTldExists(tld);/*www . j a v a 2 s.com*/ } checkArgument(nameParts.get(1).matches("[-a-zA-Z0-9]+"), INVALID_FORMAT_ERROR_MESSAGE); }