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:com.activecq.api.utils.PathInfoUtil.java

/**
 * <p>//w  w  w . j a  va  2s .  c  o m
 * Gets the suffix segment at the supplied index.
 * </p><p>
 * Given: /content/page.html/suffixA/suffixB
 * <br/>
 * getSuffixSegment(request, 0) // --> "suffixA"
 * <br/>
 * getSuffixSegment(request, 1) // --> "suffixB"
 * </p>
 *
 * @param request
 * @param index
 * @return null if suffix segment cannot be found at the specified index
 */
public static String getSuffixSegment(SlingHttpServletRequest request, int index) {
    RequestPathInfo pathInfo = request.getRequestPathInfo();
    if (pathInfo == null || pathInfo.getSuffix() == null) {
        return null;
    }

    String[] suffixes = StringUtils.split(pathInfo.getSuffix(), '/');

    if (index >= 0 && index < suffixes.length) {
        return suffixes[index];
    } else {
        return null;
    }
}

From source file:com.antsdb.saltedfish.sql.SessionParameters.java

private void parseSqlModes(String value) {
    this.no_auto_value_on_zero = false;
    if (StringUtils.isEmpty(value)) {
        return;// w w w  .  j av  a 2 s .com
    }
    for (String mode : StringUtils.split(value, ',')) {
        if (mode.equals("NO_AUTO_VALUE_ON_ZERO")) {
            this.no_auto_value_on_zero = true;
        } else if (mode.equals("STRICT_TRANS_TABLES")) {
        } else {
            throw new OrcaException("unknown sql mode " + mode);
        }
    }
}

From source file:com.intel.cosbench.driver.random.HistogramIntGenerator.java

private static HistogramIntGenerator tryParse(String pattern) {
    pattern = StringUtils.substringBetween(pattern, "(", ")");
    String[] args = StringUtils.split(pattern, ',');
    ArrayList<Bucket> bucketsList = new ArrayList<Bucket>();
    for (String arg : args) {
        String[] values = StringUtils.split(arg, '|');
        if (values.length != 3) {
            throw new IllegalArgumentException();
        }/*ww  w  .  ja v a  2s .c o  m*/
        int lower = Integer.parseInt(values[0]);
        int upper = Integer.parseInt(values[1]);
        int weight = Integer.parseInt(values[2]);
        bucketsList.add(new Bucket(lower, upper, weight));
    }
    if (bucketsList.isEmpty()) {
        throw new IllegalArgumentException();
    }
    Collections.sort(bucketsList, new LowerComparator());
    final Bucket[] buckets = bucketsList.toArray(new Bucket[0]);
    int cumulativeWeight = 0;
    for (Bucket bucket : buckets) {
        cumulativeWeight += bucket.weight;
        bucket.cumulativeWeight = cumulativeWeight;
    }
    return new HistogramIntGenerator(buckets);
}

From source file:com.hangum.tadpole.rdb.core.editors.main.utils.SQLTextUtil.java

/**
 *   ??  ./*  w ww  .j a  v  a 2  s  .c  om*/
 * 
 * @param strQuery
 * @param intPosition
 * @return
 */
public static String findPrevKeywork(String strQuery, int intPosition) {
    String strBeforeTxt = strQuery.substring(0, intPosition);
    String[] strArryBeforeTxt = StringUtils.split(strBeforeTxt, ' ');

    try {
        for (int i = 1; i <= strArryBeforeTxt.length; i++) {
            String tmp = strArryBeforeTxt[strArryBeforeTxt.length - i];
            //  ? ; ? .
            tmp = removeSpecialChar(tmp);

            if (SQLConstants.listTableKeywords.contains(tmp.toUpperCase())) {
                return tmp.toUpperCase();
            } else if (SQLConstants.listColumnKeywords.contains(tmp.toUpperCase())) {
                return tmp.toUpperCase();
            }
        }
    } catch (Exception e) {
        logger.error("preve keyword", e);
    }

    return "";
}

From source file:com.laxser.blitz.scanning.LoadScope.java

private void init(String loadScope, String defType) {
    if (StringUtils.isBlank(loadScope) || "*".equals(loadScope)) {
        return;//from   w  w  w  .  ja  va2s  .  c  o m
    }
    loadScope = loadScope.trim();
    String[] componetConfs = StringUtils.split(loadScope, ";");
    for (String componetConf : componetConfs) {
        if (StringUtils.isBlank(loadScope)) {
            continue;
        }
        // "controllers=com.renren.xoa, com.renren.yourapp"
        componetConf = componetConf.trim();
        int componetTypeIndex;
        String componetType = defType; // "controllers", "applicationContext", "dao", "messages", "*"
        String componetConfValue = componetConf;
        if ((componetTypeIndex = componetConf.indexOf('=')) != -1) {
            componetType = componetConf.substring(0, componetTypeIndex).trim();
            componetConfValue = componetConf.substring(componetTypeIndex + 1).trim();
        }
        if (componetType.startsWith("!")) {
            componetType = componetType.substring(1);
        } else {
            componetConfValue = componetConfValue + ", net.paoding.rose";
        }
        String[] packages = StringUtils.split(componetConfValue, ", \t\n\r\0");//\t
        this.load.put(componetType, packages);
    }
}

From source file:jp.co.tis.gsp.tools.db.AbstractDbObjectParser.java

protected void setupTemplateLoader() {
    if (ddlTemplateFileDir != null) {
        try {//  w w w  . j a  va2 s.  c om
            FileTemplateLoader templateLoader = new FileTemplateLoader(new File("./" + ddlTemplateFileDir));
            templateLoaderList.add(templateLoader);
        } catch (IOException e) {
            // configuration?????????????
            throw new IllegalArgumentException("failed to reach project resource", e);
        }
    }

    if (url != null) {
        String[] urlTokens = StringUtils.split(url, ':');
        if (urlTokens.length < 3) {
            throw new IllegalArgumentException("url isn't jdbc url format.");
        }
        templateLoaderList.add(
                new ClassTemplateLoader(Erd.class, "/jp/co/tis/gsp/tools/db/template/" + urlTokens[1] + "/"));
    }

    templateLoaderList
            .add(new ClassTemplateLoader(AbstractDbObjectParser.class, "/jp/co/tis/gsp/tools/db/template/"));
}

From source file:com.redhat.rhn.manager.common.BaseFileListEditCommand.java

/**
 * Parse the incoming list of files by newline.
 *
 * @param listIn to parse/*from  ww w.  j a  va  2  s  .  c o  m*/
 */
public void updateFiles(String listIn) {
    this.list.getFileNames().clear();
    String[] files = StringUtils.split(listIn, "\n");
    for (int i = 0; i < files.length; i++) {
        String cleanFile = files[i].trim();
        if (cleanFile != null && !cleanFile.equals("")) {
            this.list.addFileName(files[i].trim());
        }
    }
}

From source file:name.vysoky.re.Expression.java

private void parseExpression() throws IllegalArgumentException {
    String[] a = StringUtils.split(expression, '/');
    if (a.length != 4)
        throw new IllegalArgumentException("Invalid format of regular expression!");
    pattern = Pattern.compile(a[1]);
    replacement = a[2];//  w ww.j  a  va2s .  c o m
}

From source file:com.seer.datacruncher.validation.custom.EmailJoined.java

@Override
public ResultStepValidation checkValidity(String emails) {
    String email;// w w  w . ja  v a 2  s .c  o m
    boolean foundChr = false;
    char chrDelimiter = chrDel[0];
    result.setValid(true);
    try {
        for (char aChrDel : chrDel) {
            if ((emails.indexOf(aChrDel, 0)) < 0) {
                foundChr = false;
            } else {
                foundChr = true;
                chrDelimiter = aChrDel;
                break;
            }
        }
        if (foundChr) {
            int last = emails.lastIndexOf(chrDelimiter);
            if (last == emails.length() - 1)
                emails = emails.substring(0, emails.length() - 1);
            List<String> emailList = Arrays.asList(StringUtils.split(emails.trim(), chrDelimiter));
            for (String anEmailList : emailList) {
                email = anEmailList;
                if (!isValid(email.trim())) {
                    result.setValid(false);
                    result.setMessageResult("EmailJoined: [" + email + "] wrong.\n" + invalidCause);
                }
            }
        } else {
            email = emails;
            if (isValid(email)) {
                result.setValid(true);
            } else {
                result.setValid(false);
                result.setMessageResult("EmailJoined: [" + email + "] wrong.\n" + invalidCause);
            }
        }
    } catch (Exception exception) {
        result.setValid(false);
        result.setMessageResult("EmailJoined: [" + emails + "] wrong.\n" + exception.getMessage());
    }
    return result;
}

From source file:hydrograph.ui.propertywindow.widgets.customwidgets.joinproperty.ELTJoinPortCount.java

private void setPropertyNames() {
    String propertyNameArray[] = StringUtils.split(this.propertyName, "|");
    if (StringUtils.isNotEmpty(propertyNameArray[0]))
        firstPortPropertyName = propertyNameArray[0];

    if (propertyNameArray.length == 2
            && StringUtils.equals(Constants.UNUSED_PORT_COUNT_PROPERTY, propertyNameArray[1]))
        this.unusedPortPropertyName = propertyNameArray[1];

}