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:annis.utils.Utils.java

public static Long[] split2Long(String text, char seperator) {
    String[] str = StringUtils.split(text, seperator);
    Long[] lng = new Long[str.length];

    for (int i = 0; i < lng.length; i++) {
        try {//w  w  w  .j ava 2 s  .  com
            lng[i] = Long.parseLong(str[i]);
        } catch (NumberFormatException ex) {
            log.error("Could not parse long value, assuming \"0\" as default", ex);
        }
    }

    return lng;
}

From source file:ch.cyberduck.core.s3.LaxHostnameDelegatingTrustManager.java

@Override
public void setTarget(final String hostname) {
    final String simple;
    final String[] parts = StringUtils.split(hostname, '.');
    if (parts.length > 4) {
        ArrayUtils.reverse(parts);/* ww  w . j ava2 s .c o  m*/
        // Rewrite c.cyberduck.s3.amazonaws.com which does not match wildcard certificate *.s3.amazonaws.com
        simple = StringUtils.join(parts[3], ".", parts[2], ".", parts[1], ".", parts[0]);
        log.warn(String.format("Rewrite hostname target to %s", simple));
    } else {
        simple = hostname;
    }
    super.setTarget(simple);
}

From source file:actions.support.PathParser.java

public PathParser(String contextPath, String path) {
    String contextRemovedPath = StringUtils.removeStart(path, contextPath);
    this.pathSegments = StringUtils.split(contextRemovedPath, DELIM);
}

From source file:com.twitter.distributedlog.service.streamset.DelimiterStreamPartitionConverter.java

@Override
protected Partition newPartition(String streamName) {
    String[] parts = StringUtils.split(streamName, delimiter);
    if (null != parts && parts.length == 2) {
        try {//from   w  ww .j a  va  2  s  .c o m
            int partition = Integer.parseInt(parts[1]);
            return new Partition(parts[0], partition);
        } catch (NumberFormatException nfe) {
            // ignore the exception
        }
    }
    return new Partition(streamName, 0);
}

From source file:edu.psu.swe.scim.spec.protocol.attribute.AttributeReferenceListWrapper.java

public AttributeReferenceListWrapper(String attributeReferencesString) {

    String[] split = StringUtils.split(attributeReferencesString, ",");

    for (String af : split) {
        log.debug("--> Attribute -> " + af);
        AttributeReference attributeReference = new AttributeReference(af.trim());
        attributeReferences.add(attributeReference);
    }// ww  w.j a  va 2s  .  c o m
}

From source file:com.denimgroup.threadfix.framework.impl.dotNet.Action.java

static Action action(@Nonnull String name, @Nonnull Set<String> attributes, @Nonnull Integer lineNumber,
        @Nonnull Integer endLineNumber, @Nonnull Set<String> parameters,
        @Nonnull Set<ModelField> parametersWithTypes) {
    Action action = new Action();
    action.name = name;//from ww  w  . j av a 2s . c  om
    action.attributes = attributes;
    action.lineNumber = lineNumber;
    action.parametersWithTypes = parametersWithTypes;
    action.endLineNumber = endLineNumber;
    action.parameters = parameters;

    for (ModelField field : parametersWithTypes) {
        if (field.getType().equals("Include")) {
            for (String s : StringUtils.split(field.getParameterKey(), ',')) {
                action.parameters.add(s.trim());
            }
        } else {
            action.parameters.add(field.getParameterKey());
        }
    }

    return action;
}

From source file:de.micromata.genome.util.text.StringCommaList.java

/**
 * Decode long array./*from   w  ww.j  av  a  2s  .  c  o  m*/
 * 
 * @param merged the merged
 * @return the long[]
 */
public static Long[] decodeLongArray(String merged) {
    String[] splitted = StringUtils.split(merged, ',');
    Long[] ret = new Long[splitted.length];
    for (int i = 0; i < splitted.length; ++i) {
        ret[i] = Long.parseLong(splitted[i]);
    }
    return ret;
}

From source file:com.nesscomputing.service.discovery.server.job.BuildPathJob.java

public BuildPathJob(final String path) {
    this.elements = StringUtils.split(path, "/");
}

From source file:com.thinkbiganalytics.servicemonitor.support.ServiceMonitorCheckUtil.java

/**
 * get a map of the Service and any components that should be checked within that service.
 *///from  w w  w .jav  a2s.c om
public static Map<String, List<String>> getMapOfServiceAndComponents(String services) {
    Map<String, List<String>> map = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);
    if (StringUtils.isNotBlank(services)) {
        String finalServiceString = services;
        if (services.contains("/")) {
            int i = 1;
            String serviceName = null;
            for (String servicePart : StringUtils.split(services, "/")) {
                //service name is the first string before the /

                if (serviceName == null) {
                    if (servicePart.contains(",")) {
                        serviceName = StringUtils.substringAfterLast(servicePart, ",");
                    } else {
                        serviceName = servicePart;
                    }
                } else {
                    String components = "";
                    String origComponents = "";
                    if (servicePart.contains("]")) {
                        components = StringUtils.substringBeforeLast(servicePart, "]");
                        components = StringUtils.substringAfter(components, "[");
                        origComponents = "[" + components + "]";
                    } else {
                        components = StringUtils.substringBefore(servicePart, ",");
                        origComponents = components;
                    }
                    String[] componentsArr = StringUtils.split(components, ",");
                    map.put(serviceName, Arrays.asList(componentsArr));

                    //now remove these from the finalServiceString
                    finalServiceString = StringUtils.replace(finalServiceString,
                            serviceName + "/" + origComponents, "");

                    //reset serviceName
                    serviceName = StringUtils.substringAfterLast(servicePart, ",");

                }
                i++;
            }
        }

        for (String service : StringUtils.split(finalServiceString, ",")) {
            String serviceName = service;
            map.put(serviceName, Arrays.asList(new String[] { ALL_COMPONENTS }));
        }
    }
    return map;
}

From source file:com.mowitnow.lawnmower.service.InputService.java

public Lawn createLawn(String input) {
    final String lines[] = StringUtils.split(input, System.getProperty("line.separator"));
    final String size[] = StringUtils.split(lines[0], " ");
    final int width = Integer.valueOf(size[0]);
    final int height = Integer.valueOf(size[1]);
    return Lawn.getInstance(width, height);
}