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

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

Introduction

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

Prototype

public static String deleteWhitespace(String str) 

Source Link

Document

Deletes all whitespaces from a String as defined by Character#isWhitespace(char) .

Usage

From source file:com.ewcms.publication.freemarker.generator.GeneratorBaseTest.java

@Test
public void testProcessOutputStream() throws Exception {
    GeneratorBaseImpl html = new GeneratorBaseImpl(cfg, initSite(), initChannel());

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    html.process(out, getTemplatePath("index.html"));

    String content = getContent(out.toByteArray());
    content = StringUtils.deleteWhitespace(content);
    Assert.assertEquals("homepage", content);

    out.close();//from  w w w  .j av a  2s  . c om
}

From source file:com.daveayan.rjson.RjsonInstantiationTest.java

public void verifyDefaultJsonObjectWithMultipleInstancesOfSameCustomObjectToJsonTransformer()
        throws IOException {
    String expectedJson = RjsonUtil.fileAsString(
            "./src/test/java/DATA-com.daveayan.rjson.Rjson/rjson_object_with_custom_object_to_json_transformer.txt");
    String actualJson = serializer().toJson(Rjson.newInstance().and(new SampleObjectToJsonTransformer())
            .and(new SampleObjectToJsonTransformer()));
    Assert.assertEquals(StringUtils.deleteWhitespace(expectedJson), StringUtils.deleteWhitespace(actualJson));
}

From source file:edu.ku.brc.specify.toycode.FixSQLString.java

/**
 * /*from   ww  w  .  j a va  2s . c o m*/
 */
private void fix() {
    StringBuilder sb = new StringBuilder("sql = \"");
    String srcStr = srcTA.getText();
    boolean wasInner = false;
    for (String line : StringUtils.split(srcStr, "\n")) {
        String str = StringUtils.deleteWhitespace(line);

        if (str.toUpperCase().startsWith("INNER") || str.toUpperCase().startsWith("ORDER")
                || str.toUpperCase().startsWith("GROUP")) {
            if (!wasInner) {
                sb.append(" \" +");
                wasInner = false;
            }
            sb.append("\n    \"" + line.trim() + " \" +");
            wasInner = true;
        } else {
            if (wasInner) {
                sb.append("    \"");
                wasInner = false;
            }
            sb.append(' ');
            sb.append(StringUtils.replace(line.trim(), "\n", " "));
        }
    }

    if (wasInner) {
        sb.setLength(sb.length() - 3);
        sb.append("\";");
    } else {
        sb.append("\";");
    }
    dstTA.setText(sb.toString());

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            dstTA.requestFocus();
            dstTA.selectAll();
            UIHelper.setTextToClipboard(dstTA.getText());
        }
    });

}

From source file:com.ewcms.publication.freemarker.directive.PropertyDirectiveTest.java

/**
 * ?/*from   ww  w .  ja  v a  2s. c o m*/
 * 
 * @throws Exception
 */
@Test
public void testExceptionTemplate() throws Exception {
    Template template = cfg.getTemplate(getTemplatePath("exception.html"));

    ObjectBean objectValue = new ObjectBean();
    objectValue.setTitle("test");
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("object", objectValue);

    String content = process(template, map);
    content = StringUtils.deleteWhitespace(content);
    Assert.assertEquals("throwsException", content);
}

From source file:module.siadap.activities.CreateOrEditCompetenceEvaluationActivityInformation.java

/**
 * /*from  www  . j  a v  a  2s .co m*/
 * @param competence
 *            the competence to check if there's an equivalent set here
 * @return true if for the given competence we have in the {@link #getCompetences()} any competence with the same name and
 *         description (whitespace tolerant)
 */
public boolean hasEquivalentCompetence(Competence competence) {
    String competenceProcessedDescription = StringUtils.deleteWhitespace(competence.getDescription());
    String competenceProcessedName = StringUtils.deleteWhitespace(competence.getName());
    for (Competence availableCompetence : getCompetences()) {
        if (StringUtils.equalsIgnoreCase(StringUtils.deleteWhitespace(availableCompetence.getDescription()),
                competenceProcessedDescription)) {
            return true;
        }
    }
    return false;
}

From source file:com.jaspersoft.studio.dnd.DataAdapterDragSourceListener.java

private String createTemDataAdapterFile(final MDataAdapter dataAdapter) {
    try {/*from  w  ww.j a  v  a  2  s  . com*/
        File tempDirectory = FileUtils.getTempDirectory();
        String tempDataAdapterFilePath = tempDirectory.getAbsolutePath() + "/" //$NON-NLS-1$
                + StringUtils.deleteWhitespace(dataAdapter.getDisplayText()) + DATA_ADAPTER_FILE_EXT;
        File tempDataAdapterFile = new File(tempDataAdapterFilePath);
        if (tempDataAdapterFile.exists()) {
            // fallback solution
            tempDataAdapterFile = File.createTempFile(DATA_ADAPTER_FILE_PREFIX, DATA_ADAPTER_FILE_EXT);
        }
        JasperReportsConfiguration jrConfig = dataAdapter.getJasperConfiguration();
        if (jrConfig == null)
            jrConfig = JasperReportsConfiguration.getDefaultInstance();
        String xml = DataAdapterManager.toDataAdapterFile(dataAdapter.getValue(), jrConfig);
        FileUtils.writeByteArrayToFile(tempDataAdapterFile, xml.getBytes(ENCODING));
        return tempDataAdapterFile.getAbsolutePath();
    } catch (UnsupportedEncodingException e) {
        JaspersoftStudioPlugin.getInstance()
                .logError(NLS.bind(Messages.DataAdapterDragSourceListener_EncondingErrorMsg, ENCODING), e);
    } catch (IOException e) {
        JaspersoftStudioPlugin.getInstance().logError(Messages.DataAdapterDragSourceListener_IOErrorMsg, e);
    }
    return null;
}

From source file:com.taobao.adfs.distributed.DistributedServer.java

static String getServerName(Configuration conf) throws IOException {
    String serverName = StringUtils.deleteWhitespace(conf.get("distributed.server.name"));
    if (serverName == null || serverName.split(":").length != 2) {
        String host = conf.get("distributed.server.host", "").trim();
        if (host.isEmpty()) {
            List<InetAddress> inetAddressList = Utilities.getInetAddressList();
            host = inetAddressList.isEmpty() ? "localhost" : inetAddressList.get(0).getHostAddress();
        }//from   www  .j  a  va  2s.c  om
        serverName = host + ":50000";
    }
    String[] serverNameHostAndPort = serverName.split(":");
    serverNameHostAndPort[1] = conf.get("distributed.server.port", serverNameHostAndPort[1]);
    serverName = serverNameHostAndPort[0] + ":" + serverNameHostAndPort[1];
    conf.set("distributed.server.name", serverName);
    return serverName;
}

From source file:com.ewcms.publication.freemarker.directive.page.SkipNumberDirectiveTest.java

@Test
public void testNumberTemplate() throws Exception {
    Template template = cfg.getTemplate(getTemplatePath("number.html"));
    Map<String, Object> params = new HashMap<String, Object>();
    params.put(GlobalVariable.PAGE_NUMBER.toString(), Integer.valueOf(10));
    params.put(GlobalVariable.PAGE_COUNT.toString(), Integer.valueOf(20));
    UriRuleable rule = mock(UriRuleable.class);
    when(rule.getUri()).thenReturn("");
    params.put(GlobalVariable.URI_RULE.toString(), rule);
    String value = this.process(template, params);
    value = StringUtils.deleteWhitespace(value);
    String expected = "..8-9-10-1112-13-..";
    Assert.assertEquals(expected, value);
}

From source file:com.cognifide.cq.cqsm.core.actions.scanner.ClassScanner.java

private List<String> parsePackagesFromHeader(String header) {
    String values = PropertiesUtil.toString(bundle.getHeaders().get(header), null);
    if (values == null) {
        return Collections.emptyList();
    }//w w  w  .jav a 2 s. com
    String[] packages = StringUtils.deleteWhitespace(values).split(";");

    return Arrays.asList(packages);
}

From source file:com.daveayan.rjson.RjsonInstantiationTest.java

public void verifyDefaultJsonObjectWithCustomJsonToObjectTransformer() throws IOException {
    String expectedJson = RjsonUtil.fileAsString(
            "./src/test/java/DATA-com.daveayan.rjson.Rjson/rjson_object_with_custom_json_to_object_transformer.txt");
    String actualJson = serializer().toJson(Rjson.newInstance().and(new SampleJsonToObjectTransformer()));
    Assert.assertEquals(StringUtils.deleteWhitespace(expectedJson), StringUtils.deleteWhitespace(actualJson));
}