Example usage for org.apache.commons.lang3 StringUtils split

List of usage examples for org.apache.commons.lang3 StringUtils split

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils split.

Prototype

public static String[] split(final String str, final String separatorChars) 

Source Link

Document

Splits the provided text into an array, separators specified.

Usage

From source file:com.threewks.thundr.pipeline.PipelineTest.java

@Test
public void shouldRunBasicPipeline() {
    // @formatter:off      
    List<String> results = Pipeline.of(new Op<InputStream, String>() {
        @Override//  ww w  . j  a  v a  2 s  .c o  m
        public void process(List<InputStream> in, List<String> into) {
            InputStream first = in.get(0);
            String string = readStringFromStream(first);
            into.addAll(Arrays.asList(StringUtils.split(string, ",")));
        }
    }).then(new BaseOp<String, String>() {
        @Override
        public String processSingle(String in) {
            return StringUtils.reverse(in);
        }

    }).then(new BaseOp<String, String>() {

        @Override
        public String processSingle(String in) {
            System.out.println(in);
            return in;
        }
    }).list(new ByteArrayInputStream(source.getBytes()));
    // @formatter:on
    assertThat(results.size(), is(2));
    assertThat(results.get(0), is("tsriF"));
    assertThat(results.get(1), is("dnoceS"));
}

From source file:com.github.lburgazzoli.karaf.cluster.common.CombinedClassLoaderManager.java

/**
 * @param bundleIds/*  w  w w.  ja  v  a  2s.  co m*/
 */
public void setEligibleBundleIds(String bundleIds) {
    m_bundleIds.clear();
    for (String bundleId : StringUtils.split(bundleIds, ",")) {
        m_bundleIds.add(bundleId);
    }
}

From source file:com.jdom.util.PropertiesUtil.java

public static List<String> getPropertyAsList(Properties properties, String key) {
    return Arrays.asList(StringUtils.split(properties.getProperty(key), SEPARATOR));
}

From source file:com.nesscomputing.migratory.mojo.database.util.TemplatingStatementLocator.java

@Override
public String locate(final String statementName, final StatementContext context) throws Exception {
    if (StringUtils.isEmpty(statementName)) {
        throw new IllegalStateException("Statement Name can not be empty/null!");
    }/*from   w w  w . j  ava 2  s .  c  o  m*/

    if (statementName.charAt(0) == '#') {
        // Multiple templates can be in a string template group. In that case, the name is #<template-group:<statement name>
        final String[] statementNames = StringUtils.split(statementName.substring(1), ":");

        final String location = prefix + statementNames[0] + ".st";

        LOG.trace("Loading SQL: %s", location);
        final URL locationUrl = Resources.getResource(this.getClass(), location);

        if (locationUrl == null) {
            throw new IllegalArgumentException("Location '" + location + "' does not exist!");
        }
        final String contents = loaderManager.loadFile(locationUrl.toURI());

        if (statementNames.length == 1) {
            final StringTemplate template = new StringTemplate(contents, AngleBracketTemplateLexer.class);
            template.setAttributes(context.getAttributes());
            final String sql = template.toString();

            LOG.trace("SQL: %s", sql);
            return sql;
        } else {
            final StringTemplateGroup group = new StringTemplateGroup(new StringReader(contents),
                    AngleBracketTemplateLexer.class);
            LOG.trace("Found %s in %s", group.getTemplateNames(), locationUrl);

            final StringTemplate template = group.getInstanceOf(statementNames[1]);
            template.setAttributes(context.getAttributes());
            final String sql = template.toString();

            LOG.trace("SQL: %s", sql);
            return sql;
        }
    } else {
        return statementName;
    }
}

From source file:net.noday.cat.service.impl.TagServiceImpl.java

@Override
public void update(long aid, String tagStr) {
    String[] ts = StringUtils.split(tagStr, ",");
    for (String tag : ts) {
        Tag obj = dao.getByName(tag);/*from   ww w  .  j a  v  a2s.c o m*/
        if (obj != null) {
            dao.updateTagRef(aid, obj.getId(), tag);
        } else {
            dao.saveTagAndRef(aid, tag);
        }
    }
}

From source file:edu.ku.kuali.kra.award.options.FederalRateAgreementDateValuesFinder.java

/**
 * @see org.kuali.rice.krad.keyvalues.KeyValuesBase#getKeyValues()
 *//*from  w  ww . j a  va 2s. co m*/
public List<KeyValue> getKeyValues() {
    ParameterService parameterService = (ParameterService) KcServiceLocator.getService("parameterService");
    Collection<String> paramValues = parameterService.getParameterValuesAsString(AwardDocument.class,
            BUConstants.FEDERAL_RATE_DATE_OVERHEAD_KEY_FIELD_MAPPINGS);

    List<KeyValue> keyValues = new ArrayList<KeyValue>();
    keyValues.add(0, new ConcreteKeyValue("NA", "N/A"));
    for (String paramValue : paramValues) {
        String[] keyValueString = StringUtils.split(paramValue, "=");
        keyValues.add(new ConcreteKeyValue(keyValueString[0], keyValueString[0]));
    }
    return keyValues;
}

From source file:com.techcavern.wavetact.ircCommands.chanhalfop.Part.java

@Override
public void onCommand(String command, User user, PircBotX network, String prefix, Channel channel,
        boolean isPrivate, int userPermLevel, String... args) throws Exception {
    if (args.length < 1 || (args.length == 1 && args[0].equalsIgnoreCase(channel.getName()))) {
        channel.send().part();//from w w  w . j a  v  a 2s.co m
        Registry.lastLeftChannel.put(network, channel.getName());
    } else {
        if (userPermLevel >= 20) {
            boolean permanent = false;
            if (args[0].startsWith("+")) {
                args[0] = args[0].replace("+", "");
                permanent = true;
            }
            Registry.lastLeftChannel.put(network, args[0]);
            Registry.messageQueue.get(network).add("PART " + args[0]);
            if (permanent) {
                Record netRecord = DatabaseUtils.getNetwork(IRCUtils.getNetworkNameByNetwork(network));
                Set<String> channels = new HashSet<>(
                        Arrays.asList(StringUtils.split(netRecord.getValue(NETWORKS.CHANNELS), ", ")));
                channels.remove(args[0]);
                netRecord.setValue(NETWORKS.CHANNELS, StringUtils.join(channels, ", "));
                DatabaseUtils.updateNetwork(netRecord);
            }
        } else {
            IRCUtils.sendError(user, network, channel, "Permission denied", prefix);
        }
    }
}

From source file:com.mirth.connect.server.mybatis.MessageSearchResult.java

public void setMetaDataIds(String metaDataIds) {
    this.metaDataIds = metaDataIds;
    metaDataIdSet = new HashSet<Integer>();

    for (String piece : StringUtils.split(metaDataIds, ',')) {
        metaDataIdSet.add(Integer.parseInt(piece));
    }/*from   w w w. jav a  2 s .  c  o  m*/
}

From source file:dk.dma.ais.reader.AisReaders.java

/**
 * Creates a {@link AisTcpReader} from a list of one or more hosts. On the form: host1:port1,...,hostN:portN
 * //from w ww. ja va 2s.co m
 * @param commaHostPort
 */
public static AisTcpReader createReader(String commaHostPort) {
    AisTcpReader r = new AisTcpReader();
    String[] hostPorts = StringUtils.split(commaHostPort, ",");
    for (String hp : hostPorts) {
        r.addHostPort(HostAndPort.fromString(hp));
    }
    return r;
}

From source file:edu.illinois.cs.cogcomp.bigdata.lucene.WikiURLAnalyzer.java

public static List<String> pruningTokenization(String s) {
    List<String> tokens = new ArrayList<String>();
    String[] parts = StringUtils.split(s, replacement.charAt(0));

    for (String part : parts) {
        if (!part.endsWith("."))
            tokens.add(part);/*from  ww w.  ja  va  2  s . c om*/
    }
    return tokens;
}