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

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

Introduction

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

Prototype

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

Source Link

Document

Splits the provided text into an array, separators specified.

Usage

From source file:de.thischwa.pmcms.tool.XY.java

/**
 * Constructor to interpret to comma-separated values, e.g.: <code>1,2</code>
 * /*w  w w. j  ava  2 s .c  o  m*/
 * @param str
 */
public XY(final String str) {
    if (StringUtils.isEmpty(str))
        return;
    String tmp = StringUtils.strip(str);
    String values[] = StringUtils.split(tmp, ",");
    if (values.length != 2 && !(StringUtils.isNumeric(values[0]) && StringUtils.isNumeric(values[1])))
        throw new IllegalArgumentException("Can't interpret coordinate string!");
    setLocation(Integer.parseInt(values[0].trim()), Integer.parseInt(values[1].trim()));
}

From source file:com.exxeta.eis.sonar.esql.core.Esql.java

public String[] getFileSuffixes() {
    String[] suffixes = settings.getStringArray(EsqlPlugin.FILE_SUFFIXES_KEY);
    if (suffixes == null || suffixes.length == 0) {
        suffixes = StringUtils.split(EsqlPlugin.FILE_SUFFIXES_DEFVALUE, ",");
    }//ww w .j  a va 2s .  c  om
    return suffixes;
}

From source file:iddb.web.security.subject.Subject.java

@Override
public void setLoginId(String loginId) {
    super.setLoginId(loginId);
    String[] p = StringUtils.split(loginId, "@");
    this.screenName = p[0];
}

From source file:hydrograph.ui.common.util.ParameterUtil.java

/**
 * Returns true if input string starts with parameter.
 * // www  . j av a2  s. co  m
 * @param path
 * @param separator
 * @return
 */
public static boolean startsWithParameter(String path, char separator) {
    String pathSegments[] = StringUtils.split(path, separator);
    if (isParameter(pathSegments[0])) {
        return true;
    }
    return false;
}

From source file:com.zyeeda.jofm.commands.HttpServletCommand.java

public HttpServletCommand(HttpServletRequest request, HttpServletResponse response)
        throws IllegalRequestException {
    this.request = request;
    this.response = response;

    String path = request.getServletPath();
    LoggerHelper.debug(logger, "servlet path = {}", path);
    String[] parts = StringUtils.split(path, '/');

    if (parts.length != 2) {
        throw new IllegalRequestException(request);
    }/*from  w  w  w. j  ava  2  s.  co  m*/

    this.scope = parts[0];
    this.operation = parts[1];
}

From source file:com.ebay.jetstream.config.mongo.MongoScopesUtil.java

public static final List<String> parseServerInfo(String changedBeanScope) {
    List<String> servers = new ArrayList<String>();
    try {//from w w w  . j a va2 s . c om
        String[] values = StringUtils.split(changedBeanScope, ":");
        if (values.length >= 2) {
            String serverInfo = values[1];
            servers = Arrays.asList(serverInfo.split(","));

        } else {
            LOGGER.warn(
                    "parseServerInfo - didn't pass arguments properly, value has to be either local:something or dc:something but it was : "
                            + changedBeanScope);
        }
    } catch (Exception e) {
        LOGGER.info("parseServerInfo method ran into exception ", e);
    }

    return servers;
}

From source file:com.tesora.dve.server.connectionmanager.messages.AddConnectParametersExecutor.java

@Override
public ResponseMessage execute(SSConnection agent, Object message) throws Throwable {

    AddConnectParametersRequest acpr = (AddConnectParametersRequest) message;

    for (String qualifiedTable : acpr.getSvrDBParams().getReplSlaveIgnoreTblList()) {
        String[] tableComponents = StringUtils.split(qualifiedTable, '.');
        if (tableComponents.length != 2)
            logger.warn("Invalid entry '" + qualifiedTable + "' in Replication Slave table ignore list");
        else if (logger.isDebugEnabled())
            logger.debug("Adding " + qualifiedTable + " to table list");

        agent.getReplicationOptions().addTableFilter(agent.getSchemaContext(), tableComponents[0],
                tableComponents[1]);/*from w ww  .j a  v  a 2  s .com*/
    }

    agent.setCacheName(acpr.getSvrDBParams().getCacheName());

    return new GenericResponse().success();
}

From source file:com.xyz.util.PropertyFilter.java

/**
 * //from w  ww. j a  v a 2 s. c o m
 * @param filterName EQ_S_NAME
 * @param value
 */
public PropertyFilter(final String filterName, final Object value) {

    String matchTypeCode = StringUtils.substringBefore(filterName, "_");
    try {
        matchType = Enum.valueOf(MatchType.class, matchTypeCode.toUpperCase());
    } catch (RuntimeException e) {
        throw new IllegalArgumentException("filter??,.",
                e);
    }

    String propertyNameStr = StringUtils.substringAfter(filterName, "_");
    propertyNames = StringUtils.split(propertyNameStr, PropertyFilter.OR_SEPARATOR);

    this.value = value;
}

From source file:de.shadowhunt.sonar.plugins.ignorecode.model.CoveragePattern.java

/**
 * Create a new {@link CoveragePattern} from the given line describing the resourcePattern, the rulePattern and
 * the lines in the resource/*  w w  w.java  2  s. c o m*/
 *
 * @param line each line must consist out of the resourcePattern and lineValues,
 * separated by a ';'
 *
 * @return the new {@link CoveragePattern} from the given line
 */
public static CoveragePattern parseLine(final String line) {
    final String[] fields = StringUtils.split(line, ';');
    if (fields.length != 2) {
        throw new IllegalArgumentException("The line does not define 2 fields separated by ';': " + line);
    }

    final String resourcePattern = fields[0];
    if (StringUtils.isBlank(resourcePattern)) {
        throw new IllegalArgumentException("The first field does not define a resource pattern: " + line);
    }

    final String lineValues = fields[1];
    if (StringUtils.isBlank(lineValues)) {
        throw new IllegalArgumentException("The third field does not define a range of lines: " + line);
    }

    final SortedSet<Integer> lines = parseLineValues(lineValues);
    return new CoveragePattern(resourcePattern, lines);
}

From source file:edu.cwru.jpdg.Javac.java

/**
 * loads a java file from the resources directory. Give the fully
 * qualified name of the java file. eg. for:
 *
 *     source/test/resources/java/test/parse/HelloWorld.java
 *
 * give://from  ww  w  . java 2s . co  m
 *
 *     test.parse.HelloWorld
 */
public static String load(String full_name) {
    ClassLoader loader = Javac.class.getClassLoader();
    String[] split = StringUtils.split(full_name, ".");
    String name = split[split.length - 1];
    String slash_name = StringUtils.join(split, pathsep);
    String resource = Paths.get("java").resolve(slash_name + ".java").toString();
    InputStream ci = loader.getResourceAsStream(resource);
    BufferedReader bi = new BufferedReader(new InputStreamReader(ci));

    List<String> lines = new ArrayList<String>();
    String line;
    try {
        while ((line = bi.readLine()) != null) {
            lines.add(line);
        }
    } catch (IOException e) {
        throw new RuntimeException(e.getMessage());
    }
    lines.add(line);
    return StringUtils.join(lines, "\n");
}