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.model.AttachmentAccessToken.java
public static AttachmentAccessToken from(String serializedAttachmentAccessToken, String blobId) { Preconditions.checkArgument(!Strings.isNullOrEmpty(serializedAttachmentAccessToken), "'AttachmentAccessToken' is mandatory"); List<String> split = Splitter.on(SEPARATOR).splitToList(serializedAttachmentAccessToken); Preconditions.checkArgument(split.size() == 3, "Wrong 'AttachmentAccessToken'"); String defaultValue = null;/* ww w . j ava 2 s . c om*/ return builder().blobId(blobId).username(Iterables.get(split, 0, defaultValue)) .expirationDate(ZonedDateTime.parse(Iterables.get(split, 1, defaultValue))) .signature(Iterables.get(split, 2, defaultValue)).build(); }
From source file:ru.codeinside.adm.parser.EmployeeFixtureParser.java
public EmployeeFixtureParser() { groupSplitter = Splitter.on(',').trimResults().omitEmptyStrings(); stack = new LinkedList<Row>(); }
From source file:com.dangdang.ddframe.rdb.sharding.api.rule.DataNode.java
public DataNode(final String dataNode) { List<String> segments = Splitter.on(DELIMITER).splitToList(dataNode); dataSourceName = segments.get(0); tableName = segments.get(1); }
From source file:ratpack.config.internal.source.ArgsConfigSource.java
@Override protected Properties loadProperties() throws Exception { Splitter splitter = Splitter.on(separator).limit(2); Properties properties = new Properties(); for (String arg : args) { List<String> values = splitter.splitToList(arg); if (values.size() == 1) { properties.put(values.get(0), ""); } else {//from ww w .j a v a2 s.c om properties.put(values.get(0), values.get(1)); } } return properties; }
From source file:com.google.api.codegen.transformer.nodejs.NodeJSPackageMetadataNamer.java
public NodeJSPackageMetadataNamer(String packageName, String domainLayerLocation) { // Get the service name from the package name by removing the version suffix (if any). List<String> names = Splitter.on(".").splitToList(packageName); if (names.size() < 2) { this.serviceName = packageName; }// www . j av a2 s . c o m this.serviceName = names.get(0); this.domainLayerLocation = domainLayerLocation; }
From source file:org.onehippo.cms7.essentials.components.cms.blog.BlogUpdater.java
/** * Indicate if the document variant represented by node should be handled. * * @param node JCR node to consider// w ww .j av a 2 s . co m * @return true if the node is interesting, false otherwise. * @throws javax.jcr.RepositoryException */ public static boolean wants(final Node node, final String documentType) throws RepositoryException { // check if namespace is registered namespace, skip otherwise: if (Strings.isNullOrEmpty(documentType) || documentType.indexOf(':') == -1) { return false; } final Iterable<String> iterable = Splitter.on(':').omitEmptyStrings().trimResults().split(documentType); final Iterator<String> iterator = iterable.iterator(); if (iterator.hasNext()) { final String namespacePrefix = iterator.next(); if (!namespacePrefixExists(node.getSession(), namespacePrefix)) { return false; } } return node.getPrimaryNodeType().isNodeType(documentType); }
From source file:org.apache.isis.core.metamodel.facets.members.cssclassfa.CssClassFaFacetAbstract.java
/** * Adds the optional <em>fa</em> and <em>fa-fw</em> FontAwesome classes * * @param value The original CSS classes defined with {@literal @} * {@link org.apache.isis.applib.annotation.CssClassFa CssClassFa} * @return The original CSS classes plus <em>fa</em> and <em>fa-fw</em> if not already provided *//*from www .j ava 2 s .c om*/ static String sanitize(final String value) { final Iterable<String> classes = Splitter.on(WHITESPACE).split(value.trim()); final Set<String> cssClassesSet = Sets.newLinkedHashSet(); cssClassesSet.add("fa"); cssClassesSet.add("fa-fw"); for (final String cssClass : classes) { cssClassesSet.add(faPrefix(cssClass)); } return Joiner.on(' ').join(cssClassesSet).trim(); }
From source file:nl.knaw.huygens.solr.SolrUtils.java
public static List<String> splitTerms(String terms) { Iterable<String> split = Splitter.on(" ").split(terms); StringBuilder tmpTerm = null; boolean append = false; List<String> termlist = Lists.newArrayList(); for (String part : split) { if (part.startsWith("\"")) { tmpTerm = new StringBuilder(part); append = true;/*from w w w . j a v a 2s . c om*/ } else if (part.endsWith("\"")) { tmpTerm.append(" ").append(part); termlist.add(tmpTerm.toString()); append = false; } else if (append) { tmpTerm.append(" ").append(part); } else { termlist.add(part); } } return termlist; }
From source file:com.teradata.benchto.driver.utils.PropertiesUtils.java
public static Optional<List<String>> splitProperty(String value) { if (isNullOrEmpty(value)) { return Optional.empty(); }/* w ww .j ava 2s . c o m*/ Iterable<String> values = Splitter.on(",").trimResults().split(value); return Optional.of(ImmutableList.copyOf(values)); }
From source file:org.elasticlib.console.display.ByteLengthFormatter.java
private static String format(long length, Unit unit) { BigDecimal value = BigDecimal.valueOf(length).divide(BigDecimal.valueOf(unit.prefix)); Iterator<String> parts = Splitter.on('.').split(value.toPlainString()).iterator(); String integerPart = parts.next(); if (!parts.hasNext()) { return integerPart; }//w w w .ja v a2s . co m String fractionalPart = parts.next().substring(0, 1); return String.join(",", integerPart, fractionalPart); }