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

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

Introduction

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

Prototype

public static String[] splitByWholeSeparatorPreserveAllTokens(String str, String separator) 

Source Link

Document

Splits the provided text into an array, separator string specified.

Usage

From source file:org.opentestsystem.delivery.testreg.integration.DownloadTemplateIntegrationTest.java

private void assertExcelTemplate(InputStream inpustream) throws Exception {
    Workbook workbook = WorkbookFactory.create(inpustream);
    assertThat(workbook.getNumberOfSheets(), is(1));
    String sheetName = new String();
    if (formatType.name().length() > 32) {
        sheetName = formatType.name().substring(0, 31);
    } else {//from   w  ww . j a va2  s.c o  m
        sheetName = formatType.name();
    }
    Sheet sheet = workbook.getSheet(sheetName);

    assertThat(sheet, is(notNullValue()));

    String[] columns = StringUtils.splitByWholeSeparatorPreserveAllTokens(columnString, "|");
    assertThat(sheet.getRow(HEADER_ROW).getLastCellNum(), is((short) columns.length));

    int cellNo = 0;
    for (String columnName : columns) {
        assertThat(sheet.getRow(HEADER_ROW).getCell(cellNo++).getStringCellValue(), is(columnName));
    }
}

From source file:org.talend.dataquality.common.inference.AnalyzerTestBase.java

protected static List<String[]> getRecords(InputStream inputStream) {
    if (inputStream == null) {
        throw new IllegalArgumentException("Input stream cannot be null.");
    }//  w  ww. j  a v a2s. c o m
    try {
        List<String[]> records = new ArrayList<String[]>();
        final List<String> lines = IOUtils.readLines(inputStream);
        for (String line : lines) {
            String[] record = StringUtils.splitByWholeSeparatorPreserveAllTokens(line, ";");
            records.add(record);
        }
        return records;
    } catch (IOException e) {
        throw new RuntimeException(e);
    } finally {
        try {
            inputStream.close();
        } catch (IOException e) {
            // Silent ignore
            e.printStackTrace();
        }
    }
}

From source file:org.talend.dataquality.datamasking.semantic.DatePatternHelper.java

private static void loadPatterns(String patternFileName, List<Map<Pattern, String>> patternParsers)
        throws IOException {
    InputStream stream = DatePatternHelper.class.getResourceAsStream(patternFileName);
    try {/*  w ww. j  a  v  a  2s  . c  o m*/
        List<String> lines = IOUtils.readLines(stream, "UTF-8");
        Map<Pattern, String> currentGroupMap = new LinkedHashMap<Pattern, String>();
        patternParsers.add(currentGroupMap);
        for (String line : lines) {
            if (!"".equals(line.trim())) { // Not empty
                if (line.startsWith("--")) { // group separator
                    currentGroupMap = new LinkedHashMap<Pattern, String>();
                    patternParsers.add(currentGroupMap);
                } else {
                    String[] lineArray = StringUtils.splitByWholeSeparatorPreserveAllTokens(line, "\t");
                    String format = lineArray[0];
                    Pattern pattern = Pattern.compile(lineArray[1]);
                    currentGroupMap.put(pattern, format);
                }
            }
        }
        stream.close();
    } catch (IOException e) {
        LOGGER.error(e.getMessage(), e);
    }
}

From source file:org.talend.dataquality.record.linkage.ui.composite.utils.MatchRuleAnlaysisUtils.java

/**
 * //from  w  ww .  ja va  2  s .  c  o m
 * @param group ID one
 * @param group ID two.
 * @return true if they are the same group considering the two merged groups (groupID contains two more UUID).
 */
public static boolean isSameGroup(String groupID1, String groupID2) {
    if (groupID1 == null || groupID1.trim().equals(StringUtils.EMPTY) || groupID2 == null
            || groupID2.trim().equals(StringUtils.EMPTY)) {
        return false;
    }
    String[] ids1 = StringUtils.splitByWholeSeparatorPreserveAllTokens(groupID1, PluginConstant.COMMA_STRING);
    String[] ids2 = StringUtils.splitByWholeSeparatorPreserveAllTokens(groupID2, PluginConstant.COMMA_STRING);
    for (String id1 : ids1) {
        for (String id2 : ids2) {
            if (id1.equalsIgnoreCase(id2)) {
                return true;
            }
        }
    }
    return false;
}

From source file:org.talend.dataquality.statistics.datetime.SystemDateTimePatternManager.java

private static void loadPatterns(String patternFileName, List<Map<Pattern, String>> patternParsers)
        throws IOException {
    InputStream stream = SystemDateTimePatternManager.class.getResourceAsStream(patternFileName);
    try {//from  ww w  . j  a  v a 2  s  .  c om
        List<String> lines = IOUtils.readLines(stream, "UTF-8");
        Map<Pattern, String> currentGroupMap = new LinkedHashMap<Pattern, String>();
        patternParsers.add(currentGroupMap);
        for (String line : lines) {
            if (!"".equals(line.trim())) { // Not empty
                if (line.startsWith("--")) { // group separator
                    currentGroupMap = new LinkedHashMap<Pattern, String>();
                    patternParsers.add(currentGroupMap);
                } else {
                    String[] lineArray = StringUtils.splitByWholeSeparatorPreserveAllTokens(line, "\t");
                    String format = lineArray[0];
                    Pattern pattern = Pattern.compile(lineArray[1]);
                    currentGroupMap.put(pattern, format);
                }
            }
        }
        stream.close();
    } catch (IOException e) {
        LOGGER.error(e.getMessage(), e);
    }
}

From source file:org.talend.dataquality.statistics.quality.DataTypeQualityAnalyzerTest.java

public static List<String[]> getRecords(InputStream inputStream, String separator) {
    if (inputStream == null) {
        throw new IllegalArgumentException("Input stream cannot be null.");
    }//from  ww  w  . j av a  2  s. c o  m
    try {
        List<String[]> records = new ArrayList<String[]>();
        final List<String> lines = IOUtils.readLines(inputStream);
        for (String line : lines) {
            String[] record = StringUtils.splitByWholeSeparatorPreserveAllTokens(line, separator);
            records.add(record);
        }
        return records;
    } catch (IOException e) {
        throw new RuntimeException(e);
    } finally {
        try {
            inputStream.close();
        } catch (IOException e) {
            // Silent ignore
            e.printStackTrace();
        }
    }

}

From source file:org.talend.dataquality.statistics.semantic.SemanticStatisticsTestBase.java

protected static List<String[]> getRecords(InputStream inputStream, String lineSeparator) {
    if (inputStream == null) {
        throw new IllegalArgumentException("Input stream cannot be null.");
    }//from w w w  .j a v  a2s . c  o  m
    try {
        List<String[]> records = new ArrayList<String[]>();
        final List<String> lines = IOUtils.readLines(inputStream);
        for (String line : lines) {
            String[] record = StringUtils.splitByWholeSeparatorPreserveAllTokens(line, lineSeparator);
            records.add(record);
        }
        return records;
    } catch (IOException e) {
        throw new RuntimeException(e);
    } finally {
        try {
            inputStream.close();
        } catch (IOException e) {
            // Silent ignore
            e.printStackTrace();
        }
    }
}

From source file:org.yes.cart.domain.entity.impl.CustomerOrderDetAttributesImpl.java

public CustomerOrderDetAttributesImpl(final String raw) {
    if (raw != null && raw.length() > 0) {
        final String[] valueTriplets = StringUtils.splitByWholeSeparatorPreserveAllTokens(raw, SEPARATOR);
        for (int i = 0; i < valueTriplets.length - 2; i += 3) {
            final String key = valueTriplets[i];
            final String value = valueTriplets[i + 1];
            final String displayValue = valueTriplets[i + 2];
            if (value != null && value.length() > 0) {
                if (displayValue != null && displayValue.length() > 0) {
                    values.put(key, new Pair<String, String>(value, displayValue));
                    continue;
                }/* w w w .ja  v a 2  s  .co  m*/
                values.put(key, new Pair<String, String>(value, null));
            }
        }
    }
}

From source file:org.yes.cart.domain.entityindexer.impl.StoredAttributesImpl.java

public StoredAttributesImpl(final String raw) {
    if (raw != null && raw.length() > 0) {
        final String[] valueTriplets = StringUtils.splitByWholeSeparatorPreserveAllTokens(raw, SEPARATOR);
        for (int i = 0; i < valueTriplets.length - 2; i += 3) {
            final String key = valueTriplets[i];
            final String value = valueTriplets[i + 1];
            final String displayValue = valueTriplets[i + 2];
            if (value != null && value.length() > 0) {
                if (displayValue != null && displayValue.length() > 0) {
                    final I18NModel model = new StringI18NModel(displayValue);
                    if (!model.getAllValues().isEmpty()) {
                        values.put(key, new Pair<String, I18NModel>(value, model));
                        continue;
                    }// ww w  .  j ava 2 s.  c o m
                }
                values.put(key, new Pair<String, I18NModel>(value, null));
            }
        }
    }
}

From source file:org.yes.cart.domain.i18n.impl.StringI18NModel.java

public StringI18NModel(final String raw) {
    if (raw != null && raw.length() > 0) {
        final String[] valuePairs = StringUtils.splitByWholeSeparatorPreserveAllTokens(raw, SEPARATOR);
        for (int i = 0; i < valuePairs.length - 1; i += 2) {
            final String key = valuePairs[i];
            final String value = valuePairs[i + 1];
            if (value != null && value.length() > 0) {
                values.put(key, value);/*from ww  w .  j a  va2s .  co m*/
            }
        }
    }
}