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:com.google.copybara.util.console.Consoles.java
/** * Logs text as separate lines using {@link Console#info(String)}. If {@code text} is an empty * string, does nothing.//from w w w .j ava 2 s.c o m */ public static void logLines(Console console, String prefix, String text) { Iterator<String> lines = Splitter.on('\n').split(text).iterator(); while (lines.hasNext()) { String line = lines.next(); if (line.isEmpty() && !lines.hasNext()) { break; } console.info(prefix + line); } }
From source file:com.lithium.flow.util.BaseEncodings.java
@Nonnull public static BaseEncoding of(@Nonnull String name) { checkNotNull(name);// w w w. j a v a2s . c o m Iterator<String> it = Splitter.on(".").split(name).iterator(); BaseEncoding encoding = getEncoding(it.next()); while (it.hasNext()) { String mod = it.next(); switch (mod) { case "lowerCase": encoding = encoding.lowerCase(); break; case "upperCase": encoding = encoding.upperCase(); break; case "omitPadding": encoding = encoding.omitPadding(); break; default: throw new RuntimeException("unknown modifier: " + mod); } } return encoding; }
From source file:com.teradata.tempto.internal.convention.TableName.java
public static TableName parse(String value) { if (value.contains(".")) { List<String> parts = Splitter.on('.').splitToList(value); checkState(parts.size() == 2,//from w w w . j a v a2s.c o m "Invalid table name syntax. Expected at most one occurrence of '.' in '%s'.", value); return new TableName(parts.get(1), Optional.of(parts.get(0))); } else { return new TableName(value, Optional.empty()); } }
From source file:fr.dutra.confluence2wordpress.util.CollectionUtils.java
public static List<String> split(String str, String sep) { if (StringUtils.isBlank(str)) { return null; }/* ww w .ja v a 2 s. c o m*/ Splitter splitter = Splitter.on(sep).trimResults().omitEmptyStrings(); List<String> list = new ArrayList<String>(); for (String token : splitter.split(str)) { list.add(token); } if (list.isEmpty()) { return null; } return list; }
From source file:com.google.api.codegen.py.PythonSphinxCommentFixer.java
/** Returns a Sphinx-formatted comment string. */ public static String sphinxify(String comment) { boolean inCodeBlock = false; boolean first = true; Iterable<String> lines = Splitter.on("\n").split(comment); StringBuffer sb = new StringBuffer(); for (String line : lines) { if (inCodeBlock) { // Code blocks are either empty or indented if (!(line.trim().isEmpty() || CommentPatterns.CODE_BLOCK_PATTERN.matcher(line).matches())) { inCodeBlock = false;/*from w w w . j av a 2 s .c o m*/ line = applyTransformations(line); } } else if (CommentPatterns.CODE_BLOCK_PATTERN.matcher(line).matches()) { inCodeBlock = true; line = "::\n\n" + line; } else { line = applyTransformations(line); } if (!first) { sb.append("\n"); } first = false; sb.append(line.replace("\"", "\\\"")); } return sb.toString().trim(); }
From source file:org.rf.ide.core.testdata.model.table.keywords.names.QualifiedKeywordName.java
public static QualifiedKeywordName fromOccurrence(final String givenWholeName) { final List<String> splitted = Splitter.on('.').splitToList(givenWholeName); final String name = splitted.get(splitted.size() - 1).trim(); final String source = Joiner.on('.').join(splitted.subList(0, splitted.size() - 1)).trim(); return new QualifiedKeywordName(unifyDefinition(name), name.toLowerCase(), source); }
From source file:co.cask.cdap.template.etl.common.PluginID.java
public static PluginID from(String idStr) { Iterator<String> parts = Splitter.on(':').split(idStr).iterator(); return new PluginID(parts.next(), parts.next(), Integer.valueOf(parts.next())); }
From source file:annis.service.objects.FrequencyTableQuery.java
public static FrequencyTableQuery parse(String completeDefinition) { FrequencyTableQuery result = new FrequencyTableQuery(); Iterator<String> it = Splitter.on(',').trimResults().omitEmptyStrings().split(completeDefinition) .iterator();/*from w w w.jav a2s. com*/ while (it.hasNext()) { String f = it.next(); FrequencyTableEntry entry = FrequencyTableEntry.parse(f); if (entry != null) { result.add(entry); } } return result; }
From source file:org.splevo.jamopp.extraction.FileUtil.java
/** * Get the last segment of a file directory path. * * @param path/*from www . j ava 2 s .c o m*/ * The absolute path. * @return The last segment found. Null if no segment is available at all. */ public static String getLastSegment(String path) { if (path == null || path.isEmpty()) { return null; } Iterable<String> split = Splitter.on(File.separator).trimResults().omitEmptyStrings().split(path); ArrayList<String> segments = Lists.newArrayList(split); String lastSegment = segments.get(segments.size() - 1); return lastSegment; }
From source file:org.zoumbox.mh_dla_notifier.troll.EquipementType.java
public static EquipementType fromType(String type) { List<String> types = Lists.newArrayList(Splitter.on(" ").trimResults().split(type)); String searchedType = types.get(0); return valueOf(searchedType); }