Example usage for com.google.common.base Splitter on

List of usage examples for com.google.common.base Splitter on

Introduction

In this page you can find the example usage for com.google.common.base Splitter on.

Prototype

@CheckReturnValue
@GwtIncompatible("java.util.regex")
public static Splitter on(final Pattern separatorPattern) 

Source Link

Document

Returns a splitter that considers any subsequence matching pattern to be a separator.

Usage

From source file:annis.security.Group.java

public Group(String name, String corpusNames) {
    this(name);/*from  ww  w  . j  a  va  2 s .  com*/
    List<String> splitted = Splitter.on(',').omitEmptyStrings().trimResults().splitToList(corpusNames);
    corpora.addAll(splitted);
}

From source file:org.apache.twill.yarn.DistributedShell.java

@Override
public void run() {
    for (String cmd : Splitter.on(';').split(getArgument("cmds"))) {
        try {//w ww.  j a va  2  s . c o m
            Process process = new ProcessBuilder(ImmutableList.copyOf(Splitter.on(' ').split(cmd)))
                    .redirectErrorStream(true).start();
            try (BufferedReader reader = new BufferedReader(
                    new InputStreamReader(process.getInputStream(), Charsets.US_ASCII))) {
                String line = reader.readLine();
                while (line != null) {
                    LOG.info(line);
                    line = reader.readLine();
                }
            }
        } catch (IOException e) {
            LOG.error("Fail to execute command " + cmd, e);
        }
    }
}

From source file:org.graylog2.dashboards.widgets.strategies.QuickvaluesBaseWidgetStrategy.java

private static List<String> getStackedFields(@Nullable Object value) {
    final String stackedFieldsString = (String) firstNonNull(value, "");
    return Splitter.on(',').trimResults().omitEmptyStrings().splitToList(stackedFieldsString);
}

From source file:org.jclouds.nodepool.config.BindJcloudsModules.java

@Provides
@Singleton/*from ww  w  .  ja  v  a2  s  .com*/
@Backend
protected Set<Module> provideBackendModules(@Named(NodePoolProperties.BACKEND_MODULES) String moduleString) {
    return ImmutableSet
            .copyOf(Iterables.transform(Splitter.on(',').split(moduleString), new Function<String, Module>() {

                @Override
                public Module apply(String input) {
                    try {
                        return Module.class.cast(Class.forName(input).newInstance());
                    } catch (InstantiationException e) {
                        throw Throwables.propagate(e);
                    } catch (IllegalAccessException e) {
                        throw Throwables.propagate(e);
                    } catch (ClassNotFoundException e) {
                        throw Throwables.propagate(e);
                    }
                }
            }));
}

From source file:io.macgyver.plugin.metrics.RegexMetricFilter.java

public RegexMetricFilter includes(String s) {

    Splitter.on(CharMatcher.anyOf(" \n\t\r,;|")).omitEmptyStrings().splitToList(Strings.nullToEmpty(s))
            .forEach(it -> {/*  w  w  w  .  j  a  v  a2s.c om*/

                include(Pattern.compile(it));

            });
    return this;
}

From source file:com.dopsun.msg4j.tools.JavaGenerator.java

@Override
public String generate(ModelInfo modelInfo) {
    String javaClassName = modelInfo.getOptions().get("javaClassName");
    List<String> parts = Lists.newArrayList(Splitter.on(".").split(javaClassName));
    String containerClassName = parts.get(parts.size() - 1);

    parts.remove(parts.size() - 1);//from   ww  w.  j a v  a 2s . com
    String packageStr = Joiner.on(".").join(parts);

    initializeVelocityTemplate();

    VelocityContext context = new VelocityContext();
    Template javaProxyTemplate = getVelocityTemplate();

    context.put("generator", this);

    context.put("package", packageStr);
    context.put("runTime", new Date());
    context.put("containerClassName", containerClassName);
    context.put("model", modelInfo);

    StringBuffer sb = mergeTemplate(context, javaProxyTemplate);
    return sb.toString();
}

From source file:fr.mtlx.odm.converters.LabeledURIConverter.java

@Override
public LabeledURI from(final String value) throws ConvertionException {
    final Iterator<String> iterator = Splitter.on(' ').limit(1).trimResults().split(value).iterator();

    URI uri;//from  w  w w.j a  v a 2  s.  c om
    try {
        uri = new URI(iterator.next());
    } catch (URISyntaxException e) {
        throw new ConvertionException(e);
    }

    final String label;

    if (iterator.hasNext())
        label = Strings.emptyToNull(iterator.next());
    else
        label = null;

    return new LabeledURI(uri, label);
}

From source file:net.holmes.core.business.mimetype.model.MimeType.java

/**
 * Instantiates a new mime type./*from   w  w  w  .ja v a2 s.  c  om*/
 *
 * @param mimeType mime type
 */
private MimeType(final String mimeType) {
    this.mimeType = mimeType;
    Iterable<String> mimeTypePart = Splitter.on('/').split(mimeType);
    this.type = MediaType.getByValue(getFirst(mimeTypePart, ""));
    this.subType = getLast(mimeTypePart, "");
}

From source file:com.newlandframework.avatarmq.core.AckMessageTask.java

public Long call() throws Exception {
    for (int i = 0; i < messages.length; i++) {
        boolean error = false;
        ProducerAckMessage ack = new ProducerAckMessage();
        Object[] msg = Splitter.on(MessageSystemConfig.MessageDelimiter).trimResults().splitToList(messages[i])
                .toArray();//from www.  j  a v  a2  s . c o m
        if (msg.length == 2) {
            ack.setAck((String) msg[0]);
            ack.setMsgId((String) msg[1]);

            if (error) {
                ack.setStatus(ProducerAckMessage.FAIL);
            } else {
                ack.setStatus(ProducerAckMessage.SUCCESS);
                count.incrementAndGet();
            }

            AckTaskQueue.pushAck(ack);
            SemaphoreCache.release(MessageSystemConfig.AckTaskSemaphoreValue);
        }
    }

    barrier.await();
    return count.get();
}

From source file:annis.gui.objects.ExportQuery.java

public ExportQuery annotationKeys(String annotationKeys) {
    this.annotationKeys = Splitter.on(',').omitEmptyStrings().trimResults().splitToList(annotationKeys);
    return this;
}