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:be.i8c.codequality.sonar.plugins.sag.webmethods.flow.FlowLanguage.java

private String[] getFlowFileSuffixes() {
    String[] suffixes = filterEmptyStrings(
            config.getStringArray(FlowLanguageProperties.FLOW_FILE_SUFFIXES_KEY));
    if (suffixes.length == 0) {
        suffixes = StringUtils.split(FlowLanguageProperties.FLOW_FILE_SUFFIXES_DEFVALUE, ",");
    }/*from ww  w. j ava  2 s .c om*/
    return suffixes;
}

From source file:com.shishu.utility.url.TableUtil.java

public static String unreverseUrl(String reversedUrl) {
    StringBuilder buf = new StringBuilder(reversedUrl.length() + 2);

    int pathBegin = reversedUrl.indexOf('/');
    if (pathBegin == -1)
        pathBegin = reversedUrl.length();
    String sub = reversedUrl.substring(0, pathBegin);

    String[] splits = StringUtils.split(sub, ':'); // {<reversed host>, <port>, <protocol>}

    buf.append(splits[1]); // add protocol
    buf.append("://");
    reverseAppendSplits(splits[0], buf); // splits[0] is reversed
    // host/*from  w w w.  j a v a2 s. c  om*/
    if (splits.length == 3) { // has a port
        buf.append(':');
        buf.append(splits[2]);
    }
    buf.append(reversedUrl.substring(pathBegin));
    return buf.toString();
}

From source file:com.intel.cosbench.driver.generator.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) {
        int v1 = StringUtils.indexOf(arg, '|');
        int v2 = StringUtils.lastIndexOf(arg, '|');
        boolean isOpenRange = ((v2 - v1) == 1) ? true : false;
        String[] values = StringUtils.split(arg, '|');
        int lower, upper, weight;
        if (isOpenRange) {
            lower = Integer.parseInt(values[0]);
            upper = UniformIntGenerator.getMAXupper();
            weight = Integer.parseInt(values[1]);
        } else if (values.length != 3) {
            throw new IllegalArgumentException();
        } else {/* ww  w.j a  v  a 2 s  . c o  m*/
            lower = Integer.parseInt(values[0]);
            upper = Integer.parseInt(values[1]);
            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.googlecode.jtiger.modules.ecside.table.tool.PageSizeTool.java

public void rowsDisplayedDroplist() {

    int allRowsDisplayed = getTableModel().getLimit().getTotalRows();
    int currentRowsDisplayed = getTableModel().getLimit().getCurrentRowsDisplayed();
    int rowsDisplayed = getTableModel().getTable().getRowsDisplayed();

    String pageSizeList = getTableModel().getTable().getPageSizeList();

    String[] sizeList = null;//from w  w  w.j  av  a2s  .  c o m

    if (pageSizeList != null) {
        sizeList = StringUtils.split(pageSizeList, ",");
    }

    getHtmlBuilder().select()
            .name(getTableModel().getTableHandler().prefixWithTableId() + TableConstants.ROWS_DISPLAYED);

    String formId = getTableModel().getTable().getTableId();

    StringBuffer onchange = new StringBuffer();

    onchange.append(ECSideConstants.UTIL_FUNCTION_NAME + ".changeRowsDisplayed(");

    onchange.append("'" + formId + "',this);");

    getHtmlBuilder().onchange(onchange.toString());

    getHtmlBuilder().close();

    getHtmlBuilder().newline();
    getHtmlBuilder().tabs(4);

    int i = 0;
    int maxSize = Integer.MAX_VALUE;

    boolean hasDefaultSize = false;
    if (sizeList != null) {
        for (i = 0; i < sizeList.length; i++) {
            int size = 0;
            String text;
            if (sizeList[i].trim().toLowerCase().startsWith("max:")) {

                try {
                    if (maxSize == Integer.MAX_VALUE) {
                        maxSize = new Integer(sizeList[i].substring(4)).intValue();
                    }
                } catch (Exception e) {
                    maxSize = Integer.MAX_VALUE;
                }
                continue;
            } else if (allRowsDisplayed < maxSize && "all".equalsIgnoreCase(sizeList[i].trim())) {
                size = allRowsDisplayed;
                text = getTableModel().getMessages().getMessage(PreferencesConstants.TOOLBAR_PAGE_ALL);

            } else {
                try {
                    size = Integer.parseInt(sizeList[i].trim());
                    text = String.valueOf(size);
                } catch (Exception ei) {
                    continue;
                }
            }
            if (!hasDefaultSize) {
                hasDefaultSize = size == currentRowsDisplayed;
            }
            if (size <= maxSize) {
                getHtmlBuilder().option().value(String.valueOf(size));
                if (currentRowsDisplayed == size) {
                    getHtmlBuilder().selected();
                }
                getHtmlBuilder().close();
                getHtmlBuilder().append(text);
                getHtmlBuilder().optionEnd();
            }
        }
    }

    if (i == 0 || !hasDefaultSize) {
        // default rows
        if (rowsDisplayed > allRowsDisplayed) {
            rowsDisplayed = allRowsDisplayed;
        }
        getHtmlBuilder().option().value(String.valueOf(rowsDisplayed));
        if (currentRowsDisplayed == rowsDisplayed) {
            getHtmlBuilder().selected();
        }
        getHtmlBuilder().close();
        getHtmlBuilder().append(String.valueOf(rowsDisplayed));
        getHtmlBuilder().optionEnd();
    }

    getHtmlBuilder().newline();
    getHtmlBuilder().tabs(4);

    getHtmlBuilder().selectEnd();
}

From source file:com.ilscipio.scipio.ce.webapp.ftl.template.GetStyleNamesByPrefixMethod.java

@SuppressWarnings("unchecked")
@Override/*from w ww  .j  a  v a 2 s. c  o m*/
public Object exec(List args) throws TemplateModelException {
    if (args == null || args.size() != 2) {
        throw new TemplateModelException("Invalid number of arguments (expected: 2)");
    }
    String styleString = LangFtlUtil.getAsStringNonEscaping(((TemplateScalarModel) args.get(0)));
    styleString = TemplateFtlUtil.getPlainClassArgNames(styleString);

    String prefix = LangFtlUtil.getAsStringNonEscaping(((TemplateScalarModel) args.get(1)));

    String[] names = StringUtils.split(styleString, ' ');
    // NOTE: For emergency/safety reasons, use the current wrapper, which MAY be escaping.
    // style strings contain only simple characters anyway.
    ObjectWrapper objectWrapper = LangFtlUtil.getCurrentObjectWrapper();
    SimpleSequence res = new SimpleSequence(names.length, objectWrapper);

    for (String name : names) {
        if (name.startsWith(prefix)) {
            res.add(name);
        }
    }

    // redundant
    //return LangFtlUtil.wrap(res, objectWrapper);
    return res;
}

From source file:hydrograph.ui.dataviewer.datasetinformation.DatasetLabelProvider.java

@Override
public String getColumnText(Object element, int columnIndex) {
    GridRow gridRow = (GridRow) element;
    switch (columnIndex) {
    case 0:/*from   w  w w .jav a2 s . c o  m*/
        return gridRow.getFieldName();
    case 1:
        String[] dataTypeCanonicalName = StringUtils.split(gridRow.getDataTypeValue(), ".");
        return dataTypeCanonicalName[dataTypeCanonicalName.length - 1];
    case 2:
        return gridRow.getDateFormat();
    case 3:
        return gridRow.getPrecision();
    case 4:
        return gridRow.getScale();
    case 5:
        return gridRow.getScaleTypeValue();
    case 6:
        return gridRow.getDescription();
    }
    return null;
}

From source file:gov.nih.nci.cabig.caaers.domain.Notification.java

@Transient
public List<String> getRecipientEmails() {
    if (StringUtils.isEmpty(emails))
        return new ArrayList<String>();
    return Arrays.asList(StringUtils.split(emails, ','));
}

From source file:com.edgenius.wiki.service.impl.SitemapMetadata.java

/**
 * @param pageUuid//from   w  w w .  j  av a 2 s  . com
 * @return
 */
public String getPageUrl(String pageUuid) {
    String value = pageMap.get(pageUuid);
    String[] str = StringUtils.split(value, SEP);
    if (str != null && str.length == 2) {
        return str[1];
    }
    return null;
}

From source file:ml.shifu.shifu.udf.EvalScoreUDFTest.java

public void testExec() throws IOException {
    Tuple input = TupleFactory.getInstance().newTuple(31);
    for (int i = 0; i < 31; i++) {
        input.set(i, 1);//  ww  w . ja v a2  s .  c  o m
    }
    input.set(0, "M");

    check(instance.exec(input), StringUtils.split("M,1.0,42,74,5,35,35,30,74,65,5", ","));
}

From source file:com.thoughtworks.acceptance.SecurityManagerTest.java

protected void setUp() throws Exception {
    super.setUp();
    System.setSecurityManager(null);
    source = new CodeSource(new File("target").toURI().toURL(), (Certificate[]) null);

    sm = new DynamicSecurityManager();
    Policy policy = Policy.getPolicy();
    sm.setPermissions(source, policy.getPermissions(source));
    sm.addPermission(source, new RuntimePermission("setSecurityManager"));

    File mainClasses = new File(System.getProperty("user.dir"), "target/classes/-");
    File testClasses = new File(System.getProperty("user.dir"), "target/test-classes/-");
    String[] javaClassPath = StringUtils.split(System.getProperty("java.class.path"), File.pathSeparatorChar);
    File javaHome = new File(System.getProperty("java.home"), "-");

    // necessary permission start here
    sm.addPermission(source, new FilePermission(mainClasses.toString(), "read"));
    sm.addPermission(source, new FilePermission(testClasses.toString(), "read"));
    sm.addPermission(source, new FilePermission(javaHome.toString(), "read"));
    for (int i = 0; i < javaClassPath.length; ++i) {
        if (javaClassPath[i].endsWith(".jar")) {
            sm.addPermission(source, new FilePermission(javaClassPath[i], "read"));
        }//from  ww  w  . j  av  a 2  s. c om
    }
}