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

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

Introduction

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

Prototype

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

Source Link

Document

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

Usage

From source file:nz.ac.waikato.its.irr.scripts.FixSquishedMetadata.java

private static boolean process(Item item, String schema, String element, String qualifier, String delimiter,
        int minMatches, boolean dryRun) throws SQLException, AuthorizeException {
    boolean changes = false;
    List<Metadatum> newMetadata = new ArrayList<>();

    Metadatum[] allMd = item.getMetadata(schema, element, qualifier, Item.ANY);
    for (Metadatum md : allMd) {
        if (StringUtils.isNotBlank(md.value) && StringUtils.countMatches(md.value, delimiter) >= minMatches) {
            String[] individualValues = StringUtils.splitByWholeSeparator(md.value, delimiter);
            for (int i = 0; i < individualValues.length; i++) {
                individualValues[i] = individualValues[i].replaceAll("(\\r|\\n|\\t)", " ").replaceAll("  ", " ")
                        .trim();//from w w w.j av a2  s  . c  o  m
            }
            System.out.println("item id=" + item.getID() + ": split |" + md.value + "| into |"
                    + StringUtils.join(individualValues, '|') + "|");
            if (!dryRun) {
                for (String individualValue : individualValues) {
                    if (StringUtils.isNotBlank(individualValue)) {
                        Metadatum newMd = new Metadatum();
                        newMd.language = md.language;
                        newMd.value = individualValue;
                        newMetadata.add(newMd);
                    }
                }
                changes = true;
            }
        } else {
            newMetadata.add(md);
        }
    }
    if (!dryRun && changes) {
        item.clearMetadata(schema, element, qualifier, Item.ANY);
        for (Metadatum newMd : newMetadata) {
            item.addMetadata(schema, element, qualifier, newMd.language, newMd.value, newMd.authority,
                    newMd.confidence);
        }
        item.updateMetadata();
    }
    return changes;
}

From source file:org.apache.hadoop.hive.metastore.security.ZooKeeperTokenStore.java

/**
 * Parse comma separated list of ACL entries to secure generated nodes, e.g.
 * <code>sasl:hive/host1@MY.DOMAIN:cdrwa,sasl:hive/host2@MY.DOMAIN:cdrwa</code>
 * @param aclString//from   w  w w .j  a  v  a2  s . c  o m
 * @return ACL list
 */
public static List<ACL> parseACLs(String aclString) {
    String[] aclComps = StringUtils.splitByWholeSeparator(aclString, ",");
    List<ACL> acl = new ArrayList<ACL>(aclComps.length);
    for (String a : aclComps) {
        if (StringUtils.isBlank(a)) {
            continue;
        }
        a = a.trim();
        // from ZooKeeperMain private method
        int firstColon = a.indexOf(':');
        int lastColon = a.lastIndexOf(':');
        if (firstColon == -1 || lastColon == -1 || firstColon == lastColon) {
            LOGGER.error(a + " does not have the form scheme:id:perm");
            continue;
        }
        ACL newAcl = new ACL();
        newAcl.setId(new Id(a.substring(0, firstColon), a.substring(firstColon + 1, lastColon)));
        newAcl.setPerms(getPermFromString(a.substring(lastColon + 1)));
        acl.add(newAcl);
    }
    return acl;
}

From source file:org.apache.lens.cube.parse.TestJoinResolver.java

@Test
public void testAutoJoinResolver() throws Exception {
    HiveConf conf = new HiveConf(hconf);
    conf.setBoolean(CubeQueryConfUtil.DISABLE_AGGREGATE_RESOLVER, true);
    // Test 1 Cube + dim
    String query = "select cubeCity.name, dim2chain.name, dim4chain.name, msr2 from testCube where "
            + TWO_DAYS_RANGE;/*  ww  w.  j a  v a 2s.c o m*/
    CubeQueryRewriter driver = new CubeQueryRewriter(conf, conf);
    CubeQueryContext rewrittenQuery = driver.rewrite(query);
    String hql = rewrittenQuery.toHQL();
    System.out.println("testAutoJoinResolverauto join HQL:" + hql);
    System.out.println(
            "testAutoJoinResolver@@Resolved join chain:[" + getAutoResolvedFromString(rewrittenQuery) + "]");
    List<String> expectedClauses = new ArrayList<String>();
    expectedClauses.add(getDbName() + "c1_testfact2_raw testcube");
    expectedClauses.add(getDbName()
            + "c1_citytable cubecity on testcube.cityid = cubecity.id and (cubecity.dt = 'latest')");
    expectedClauses.add(getDbName()
            + "c1_testdim2tbl dim2chain on testcube.dim2 = dim2chain.id and (dim2chain.dt = 'latest')");
    expectedClauses.add(getDbName()
            + "c1_testdim3tbl testdim3 on dim2chain.testdim3id = testdim3.id and (testdim3.dt = 'latest')");
    expectedClauses.add(getDbName()
            + "c1_testdim4tbl dim4chain on testdim3.testdim4id = dim4chain.id and (dim4chain.dt = 'latest')");

    List<String> actualClauses = new ArrayList<>();
    for (String clause : StringUtils.splitByWholeSeparator(getAutoResolvedFromString(rewrittenQuery), "join")) {
        if (StringUtils.isNotBlank(clause)) {
            actualClauses.add(clause.trim());
        }
    }
    System.out.println("testAutoJoinResolverExpected1" + expectedClauses);
    System.out.println("testAutoJoinResolverActual1" + actualClauses);
    Assert.assertEqualsNoOrder(expectedClauses.toArray(), actualClauses.toArray());

    // Test 2 Dim only query
    expectedClauses.clear();
    actualClauses.clear();
    String dimOnlyQuery = "select testDim2.name, dim4chain.name FROM testDim2 where " + TWO_DAYS_RANGE;
    rewrittenQuery = driver.rewrite(dimOnlyQuery);
    hql = rewrittenQuery.toHQL();
    System.out.println("testAutoJoinResolverauto join HQL:" + hql);
    System.out.println(
            "testAutoJoinResolver@@Resolved join chain:[" + getAutoResolvedFromString(rewrittenQuery) + "]");
    expectedClauses.add(getDbName() + "c1_testdim2tbl testdim2");
    expectedClauses.add(getDbName()
            + "c1_testdim3tbl testdim3 on testdim2.testdim3id = testdim3.id and (testdim3.dt = 'latest')");
    expectedClauses.add(getDbName()
            + "c1_testdim4tbl dim4chain on testdim3.testdim4id = dim4chain.id and (dim4chain.dt = 'latest')");
    for (String clause : StringUtils.splitByWholeSeparator(getAutoResolvedFromString(rewrittenQuery), "join")) {
        if (StringUtils.isNotBlank(clause)) {
            actualClauses.add(clause.trim());
        }
    }
    System.out.println("testAutoJoinResolverExpected2" + expectedClauses);
    System.out.println("testAutoJoinResolverActual2" + actualClauses);
    Assert.assertEquals(expectedClauses, actualClauses);

    // Test 3 Dim only query should throw error
    String errDimOnlyQuery = "select citydim.id, testDim4.name FROM citydim where " + TWO_DAYS_RANGE;
    getLensExceptionInRewrite(errDimOnlyQuery, hconf);
}

From source file:org.apache.lens.cube.parse.TestJoinResolver.java

@Test
public void testJoinChains() throws ParseException, LensException, HiveException {
    String query, hqlQuery, expected;

    // Single joinchain with direct link
    query = "select cubestate.name, sum(msr2) from basecube where " + TWO_DAYS_RANGE
            + " group by cubestate.name";
    hqlQuery = rewrite(query, hconf);//from w  ww. j a v  a2  s  .  co m
    expected = getExpectedQuery("basecube",
            "SELECT (cubestate.name) as `name`, sum((basecube.msr2)) " + "as `sum(msr2)` FROM ",
            " join " + getDbName()
                    + "c1_statetable cubestate ON basecube.stateid=cubeState.id and cubeState.dt= 'latest'",
            null, "group by cubestate.name", null,
            getWhereForDailyAndHourly2days("basecube", "c1_testfact1_base"));
    TestCubeRewriter.compareQueries(hqlQuery, expected);

    // Single joinchain with two chains
    query = "select citystate.name, sum(msr2) from basecube where " + TWO_DAYS_RANGE
            + " group by citystate.name";
    hqlQuery = rewrite(query, hconf);
    expected = getExpectedQuery("basecube",
            "SELECT (citystate.name) as `name`, sum((basecube.msr2)) " + "as `sum(msr2)` FROM ",
            " join " + getDbName()
                    + "c1_citytable citydim ON baseCube.cityid = citydim.id and citydim.dt = 'latest'"
                    + " join " + getDbName()
                    + "c1_statetable cityState ON citydim.stateid=cityState.id and cityState.dt= 'latest'",
            null, "group by citystate.name", null,
            getWhereForDailyAndHourly2days("basecube", "c1_testfact1_base"));
    TestCubeRewriter.compareQueries(hqlQuery, expected);

    // Single joinchain with two chains, accessed as refcolumn
    query = "select cityStateCapital, sum(msr2) from basecube where " + TWO_DAYS_RANGE;
    hqlQuery = rewrite(query, hconf);
    expected = getExpectedQuery("basecube",
            "SELECT (citystate.capital) as `citystatecapital`, " + "sum((basecube.msr2)) as `sum(msr2)` FROM ",
            " join " + getDbName()
                    + "c1_citytable citydim ON baseCube.cityid = citydim.id and citydim.dt = 'latest'"
                    + " join " + getDbName() + "c1_statetable cityState ON citydim.stateid=cityState.id "
                    + "and cityState.dt= 'latest'",
            null, "group by citystate.capital", null,
            getWhereForDailyAndHourly2days("basecube", "c1_testfact1_base"));
    TestCubeRewriter.compareQueries(hqlQuery, expected);

    // Same test, Accessing refcol as a column of cube
    query = "select basecube.cityStateCapital, sum(msr2) from basecube where " + TWO_DAYS_RANGE;
    hqlQuery = rewrite(query, hconf);
    TestCubeRewriter.compareQueries(hqlQuery, expected);

    // Adding Order by
    query = "select cityStateCapital, sum(msr2) from basecube where " + TWO_DAYS_RANGE
            + " order by cityStateCapital";
    hqlQuery = rewrite(query, hconf);
    expected = getExpectedQuery("basecube",
            "SELECT (citystate.capital) as `citystatecapital`, " + "sum((basecube.msr2)) as `sum(msr2)` FROM ",
            " join " + getDbName()
                    + "c1_citytable citydim ON baseCube.cityid = citydim.id and citydim.dt = 'latest'"
                    + " join " + getDbName()
                    + "c1_statetable cityState ON citydim.stateid=cityState.id and cityState.dt= 'latest'",
            null, "group by citystate.capital order by citystatecapital", null,
            getWhereForDailyAndHourly2days("basecube", "c1_testfact1_base"));
    TestCubeRewriter.compareQueries(hqlQuery, expected);

    // Single joinchain, but one column accessed as refcol and another as chain.column
    query = "select citystate.name, cityStateCapital, sum(msr2) from basecube where " + TWO_DAYS_RANGE;
    hqlQuery = rewrite(query, hconf);
    expected = getExpectedQuery("basecube",
            "SELECT (citystate.name) as `name`, (citystate.capital) "
                    + "as `citystatecapital`, sum((basecube.msr2)) as `sum(msr2)` FROM ",
            " join " + getDbName()
                    + "c1_citytable citydim ON baseCube.cityid = citydim.id and citydim.dt = 'latest'"
                    + " join " + getDbName()
                    + "c1_statetable cityState ON citydim.stateid=cityState.id and cityState.dt= 'latest'",
            null, "group by citystate.name, citystate.capital", null,
            getWhereForDailyAndHourly2days("basecube", "c1_testfact1_base"));
    TestCubeRewriter.compareQueries(hqlQuery, expected);

    // Two unrelated join chains
    query = "select cubeState.name, cubecity.name, sum(msr2) from basecube where " + TWO_DAYS_RANGE;
    hqlQuery = rewrite(query, hconf);
    expected = getExpectedQuery("basecube",
            "SELECT (cubestate.name) as `name`, (cubecity.name) as `name`, sum((basecube.msr2)) as `sum(msr2)` FROM ",
            " join " + getDbName()
                    + "c1_statetable cubestate on basecube.stateid = cubestate.id and cubestate.dt = 'latest'"
                    + " join " + getDbName()
                    + "c1_citytable cubecity on basecube.cityid = cubecity.id and cubecity.dt = 'latest'",
            null, "group by cubestate.name,cubecity.name", null,
            getWhereForDailyAndHourly2days("basecube", "c1_testfact1_base"));
    TestCubeRewriter.compareQueries(hqlQuery, expected);

    // Multiple join chains with same destination table
    query = "select cityState.name, cubeState.name, sum(msr2) from basecube where " + TWO_DAYS_RANGE;
    hqlQuery = rewrite(query, hconf);
    expected = getExpectedQuery("basecube",
            "SELECT (citystate.name) as `name`, (cubestate.name) "
                    + "as `name`, sum((basecube.msr2)) as `sum(msr2)` FROM ",
            " join " + getDbName()
                    + "c1_statetable cubestate on basecube.stateid=cubestate.id and cubestate.dt='latest'"
                    + " join " + getDbName() + "c1_citytable citydim on basecube.cityid = citydim.id and "
                    + "citydim.dt = 'latest'" + " join " + getDbName()
                    + "c1_statetable citystate on citydim.stateid = citystate.id and "
                    + "citystate.dt = 'latest'",
            null, "group by citystate.name,cubestate.name", null,
            getWhereForDailyAndHourly2days("basecube", "c1_testfact1_base"));
    TestCubeRewriter.compareQueries(hqlQuery, expected);

    // Two joinchains, one accessed as refcol.
    query = "select cubestate.name, cityStateCapital, sum(msr2) from basecube where " + TWO_DAYS_RANGE;
    hqlQuery = rewrite(query, hconf);
    expected = getExpectedQuery("basecube",
            "SELECT (cubestate.name) as `name`, (citystate.capital) as `citystatecapital`, "
                    + "sum((basecube.msr2)) as `sum(msr2)` FROM ",
            "" + " join " + getDbName()
                    + "c1_statetable cubestate on basecube.stateid=cubestate.id and cubestate.dt='latest'"
                    + " join " + getDbName()
                    + "c1_citytable citydim on basecube.cityid = citydim.id and citydim.dt = 'latest'"
                    + " join " + getDbName()
                    + "c1_statetable citystate on citydim.stateid=citystate.id and citystate.dt='latest'" + "",
            null, "group by cubestate.name, citystate.capital", null,
            getWhereForDailyAndHourly2days("basecube", "c1_testfact1_base"));
    TestCubeRewriter.compareQueries(hqlQuery, expected);

    // Two joinchains with initial path common. Testing merging of chains
    query = "select cityState.name, cityZip.f1, sum(msr2) from basecube where " + TWO_DAYS_RANGE;
    hqlQuery = rewrite(query, hconf);
    expected = getExpectedQuery("basecube",
            "SELECT (citystate.name) as `name`, (cityzip.f1) as `f1`, sum((basecube.msr2)) as `sum(msr2)` FROM ",
            " join " + getDbName() + "c1_citytable citydim on basecube.cityid = citydim.id and "
                    + "citydim.dt = 'latest'" + " join " + getDbName()
                    + "c1_statetable citystate on citydim.stateid = citystate.id and "
                    + "citystate.dt = 'latest'" + " join " + getDbName()
                    + "c1_ziptable cityzip on citydim.zipcode = cityzip.code and " + "cityzip.dt = 'latest'",
            null, "group by citystate.name,cityzip.f1", null,
            getWhereForDailyAndHourly2days("basecube", "c1_testfact1_base"));
    TestCubeRewriter.compareQueries(hqlQuery, expected);

    // Two joinchains with common intermediate dimension, but different paths to that common dimension
    // checking aliasing
    query = "select cubeStateCountry.name, cubeCityStateCountry.name, sum(msr2) from basecube where "
            + TWO_DAYS_RANGE;
    hqlQuery = rewrite(query, hconf);
    expected = getExpectedQuery("basecube",
            "SELECT (cubestatecountry.name) as `name`, (cubecitystatecountry.name) as `name`, sum((basecube.msr2)) "
                    + "as `sum(msr2)` FROM ",
            "" + " join " + getDbName()
                    + "c1_citytable citydim on basecube.cityid = citydim.id and (citydim.dt = 'latest')"
                    + " join " + getDbName()
                    + "c1_statetable statedim_0 on citydim.stateid=statedim_0.id and statedim_0.dt='latest'"
                    + " join " + getDbName()
                    + "c1_countrytable cubecitystatecountry on statedim_0.countryid=cubecitystatecountry.id"
                    + " join " + getDbName()
                    + "c1_statetable statedim on basecube.stateid=statedim.id and (statedim.dt = 'latest')"
                    + " join " + getDbName()
                    + "c1_countrytable cubestatecountry on statedim.countryid=cubestatecountry.id " + "",
            null, "group by cubestatecountry.name, cubecitystatecountry.name", null,
            getWhereForDailyAndHourly2days("basecube", "c1_testfact1_base"));
    TestCubeRewriter.compareQueries(hqlQuery, expected);

    // Test 4 Dim only query with join chains

    List<String> expectedClauses = new ArrayList<>();
    List<String> actualClauses = new ArrayList<>();
    String dimOnlyQuery = "select testDim2.name, testDim2.cityStateCapital FROM testDim2 where "
            + TWO_DAYS_RANGE;
    CubeQueryRewriter driver = new CubeQueryRewriter(hconf, hconf);
    CubeQueryContext rewrittenQuery = driver.rewrite(dimOnlyQuery);
    String hql = rewrittenQuery.toHQL();
    System.out.println("testAutoJoinResolverauto join HQL:" + hql);
    System.out.println(
            "testAutoJoinResolver@@Resolved join chain:[" + getAutoResolvedFromString(rewrittenQuery) + "]");
    expectedClauses.add(getDbName() + "c1_testdim2tbl testdim2");
    expectedClauses.add(
            getDbName() + "c1_citytable citydim on testdim2.cityid = citydim.id and (citydim.dt = 'latest')");
    expectedClauses.add(getDbName()
            + "c1_statetable citystate on citydim.stateid = citystate.id and (citystate.dt = 'latest')");

    for (String clause : StringUtils.splitByWholeSeparator(getAutoResolvedFromString(rewrittenQuery), "join")) {
        if (StringUtils.isNotBlank(clause)) {
            actualClauses.add(clause.trim());
        }
    }
    System.out.println("testDimOnlyJoinChainExpected1 : " + expectedClauses);
    System.out.println("testDimOnlyJoinChainActual1 : " + actualClauses);
    Assert.assertEquals(expectedClauses, actualClauses);

    //Dim only join chain query without qualified tableName for join chain ref column
    actualClauses.clear();
    dimOnlyQuery = "select name, cityStateCapital FROM testDim2 where " + TWO_DAYS_RANGE;
    driver = new CubeQueryRewriter(hconf, hconf);
    rewrittenQuery = driver.rewrite(dimOnlyQuery);
    hql = rewrittenQuery.toHQL();
    System.out.println("testAutoJoinResolverauto join HQL:" + hql);
    System.out.println(
            "testAutoJoinResolver@@Resolved join chain:[" + getAutoResolvedFromString(rewrittenQuery) + "]");

    for (String clause : StringUtils.splitByWholeSeparator(getAutoResolvedFromString(rewrittenQuery), "join")) {
        if (StringUtils.isNotBlank(clause)) {
            actualClauses.add(clause.trim());
        }
    }
    System.out.println("testDimOnlyJoinChainExpected1 : " + expectedClauses);
    System.out.println("testDimOnlyJoinChainActual1 : " + actualClauses);
    Assert.assertEquals(expectedClauses, actualClauses);

    //With ChainRef.col
    actualClauses.clear();
    dimOnlyQuery = "select testDim2.name, cityState.capital FROM testDim2 where " + TWO_DAYS_RANGE;
    driver = new CubeQueryRewriter(hconf, hconf);
    rewrittenQuery = driver.rewrite(dimOnlyQuery);
    hql = rewrittenQuery.toHQL();
    System.out.println("testAutoJoinResolverauto join HQL:" + hql);
    System.out.println(
            "testAutoJoinResolver@@Resolved join chain:[" + getAutoResolvedFromString(rewrittenQuery) + "]");

    for (String clause : StringUtils.splitByWholeSeparator(getAutoResolvedFromString(rewrittenQuery), "join")) {
        if (StringUtils.isNotBlank(clause)) {
            actualClauses.add(clause.trim());
        }
    }
    System.out.println("testDimOnlyJoinChainExpected1 : " + expectedClauses);
    System.out.println("testDimOnlyJoinChainActual1 : " + actualClauses);
    Assert.assertEquals(expectedClauses, actualClauses);
}

From source file:org.castafiore.ecm.Main.java

private static void template(File template, String dir, String name) throws Exception {
    String scss = IOUtil.getFileContenntAsString(template);
    scss = scss.replace("#", ".");
    scss = scss.replace("id=", "class=");
    if (scss.contains("</h4>"))
        scss = StringUtils.splitByWholeSeparator(scss, "</h4>")[1];
    else if (scss.contains("</h2>"))
        scss = StringUtils.splitByWholeSeparator(scss, "</h2>")[1];
    else//from  w w  w  .  ja v a  2  s .co m
        scss = StringUtils.splitByWholeSeparator(scss, "<body>")[1];
    scss = StringUtils.splitByWholeSeparator(scss, "</body>")[0];
    scss = "<div><div class=\"" + name + "\"><link href=\"designer/menu/vertical/contents/" + name
            + "/style.css\" rel=\"stylesheet\" type=\"text/css\" />" + scss + "</div></div>";
    FileOutputStream out = new FileOutputStream(new File(dir + "\\preview.html"));
    out.write(scss.getBytes());
    out.flush();
    out.close();
}

From source file:org.castafiore.utils.ResourceUtil.java

public static String getTemplate(String templateLocation, Application app) {

    String contextPath = app.getContextPath();
    String serverPort = app.getServerPort();
    String servaerName = app.getServerName();
    if ("www.3racingtips.com".equalsIgnoreCase(servaerName)) {
        servaerName = "racingtips.s18.eatj.com";
    }//from w  ww  .  j ava  2s . c o m

    if (!contextPath.startsWith("/")) {
        contextPath = "/" + contextPath;
    }
    if (contextPath.endsWith("/") && templateLocation.startsWith("/")) {
        templateLocation = templateLocation.substring(1);
    }
    if (!contextPath.endsWith("/") && !templateLocation.startsWith("/")) {
        templateLocation = "/" + templateLocation;
    }
    //String url = "";
    if (!templateLocation.startsWith("http")) {
        templateLocation = "http://" + servaerName + ":" + serverPort + contextPath + "" + templateLocation;
    }

    try {
        //URL oUrl = new URL(templateLocation);
        //InputStream in = oUrl.openStream();

        String template = readUrl(templateLocation);

        //throw new Exception("dfs");
        return template;
    } catch (Exception e) {

        try {
            String[] asSpec = StringUtils.splitByWholeSeparator(templateLocation, "spec=");
            if (asSpec != null && asSpec.length == 2) {
                String spec = asSpec[1];
                ResourceLocator locator = ResourceLocatorFactory.getResourceLocator(spec);
                InputStream data = locator.getResource(spec, null).getInputStream();

                String template = IOUtil.getStreamContentAsString(data);
                return template;
            } else {
                throw new RuntimeException("unable to load template:" + templateLocation, e);
            }
        } catch (Exception ex) {
            throw new RuntimeException("unable to load template:" + templateLocation, e);
        }
        //e.printStackTrace();
    }

}

From source file:org.devproof.portal.core.module.common.component.ExtendedLabel.java

private List<String> getTextLines(String tagPart) {
    String str2img = StringUtils.substringAfter(tagPart, CLOSE_SEP);
    List<String> str2ImgLines = new ArrayList<String>();
    String tmp[] = StringUtils.splitByWholeSeparator(str2img, "<br />");
    for (String t : tmp) {
        str2ImgLines.add(HtmlUtils.htmlUnescape(t.replaceAll("\\<.*?>", "")));
    }//from   w  ww .  ja va 2s.c  o m
    return str2ImgLines;
}

From source file:org.devproof.portal.module.article.entity.Article.java

private List<String> getSplittedPages(String pages) {
    String[] splitted = StringUtils.splitByWholeSeparator(pages, "page-break-after");
    List<String> result = new ArrayList<String>();
    if (splitted.length > 1) {
        StringBuilder buf = new StringBuilder();
        for (int i = 0; i < splitted.length; i++) {
            String actual = splitted[i];
            int open = actual.lastIndexOf('<');
            int close = actual.lastIndexOf('>');
            if (open < 0 || close > open) {
                // kein tag
                buf.append(actual);/*from  ww w  .  ja v a  2  s. c om*/
                if (splitted.length - 1 != i)
                    buf.append("page-break-after");
            } else {
                // tag
                buf.append(StringUtils.substringBeforeLast(actual, "<"));
                result.add(buf.toString());
                buf = new StringBuilder();
                String closeTag = StringUtils.substringAfterLast(actual, "<");
                closeTag = "</" + StringUtils.substringBefore(closeTag, " ") + ">";
                splitted[i + 1] = StringUtils.substringAfter(splitted[i + 1], closeTag);
            }
        }
        if (buf.length() > 0) {
            result.add(buf.toString());
        }
    } else {
        result.add(pages);
    }
    return result;
}

From source file:org.drugis.addis.gui.builder.TreatmentCategorizationView.java

private JComponent buildOverviewPanel() {
    final FormLayout layout = new FormLayout("fill:pref:grow", "p");

    final PanelBuilder builder = new PanelBuilder(layout);
    final CellConstraints cc = new CellConstraints();
    int row = 1;/*w  ww.j ava 2  s. c o  m*/

    builder.addSeparator(CategoryKnowledgeFactory.getCategoryKnowledge(Drug.class).getSingularCapitalized(),
            cc.xy(1, row));
    row = LayoutUtil.addRow(layout, row);
    builder.add(DrugView.createDrugOverviewPanel(d_model.getDrugPresentation()), cc.xy(1, row));
    layout.appendRow(RowSpec.decode("10dlu"));
    row += 1;

    row = LayoutUtil.addRow(layout, row);
    builder.addSeparator("Dose categories", cc.xy(1, row));
    for (final Category category : d_model.getBean().getCategories()) {
        row = LayoutUtil.addRow(layout, row);
        builder.addSeparator(CategoryKnowledgeFactory.getCategoryKnowledge(Study.class).getPlural()
                + " measuring this " + CategoryKnowledgeFactory.getCategoryKnowledge(Drug.class).getSingular()
                + " categorized as '" + category.getName() + "'", cc.xy(1, row));
        row = LayoutUtil.addRow(layout, row);
        String criterionLabel = category.getCriterionLabel();
        String[] criteria = StringUtils.splitByWholeSeparator(criterionLabel, " OR ");
        criterionLabel = StringUtils.join(criteria, " OR\n");
        builder.add(
                AuxComponentFactory.createAutoWrapLabel(
                        new UnmodifiableHolder<String>("Inclusion criteria: " + criterionLabel)),
                cc.xy(1, row));
        row = LayoutUtil.addRow(layout, row);

        builder.add(DrugView.buildStudyListComponent(d_model.getCategorizedStudyList(category),
                Main.getMainWindow()), cc.xy(1, row));
        layout.appendRow(RowSpec.decode("10dlu"));
        row += 1;
    }
    return builder.getPanel();
}

From source file:org.ebayopensource.turmeric.eclipse.typelibrary.ui.TypeLibraryUtil.java

private static File getJarFile(String baseLocation) {
    String[] parts = StringUtils.splitByWholeSeparator(baseLocation, "!/");
    File file = new File(parts[0]);
    return file;//from   w  w w . j  a  va  2s.c om
}