Example usage for org.apache.commons.lang3 StringUtils contains

List of usage examples for org.apache.commons.lang3 StringUtils contains

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils contains.

Prototype

public static boolean contains(final CharSequence seq, final CharSequence searchSeq) 

Source Link

Document

Checks if CharSequence contains a search CharSequence, handling null .

Usage

From source file:io.wcm.handler.link.type.ExternalLinkType.java

@Override
public boolean accepts(String linkRef) {
    // accept as external link if the ref contains "://" and mailto links
    return StringUtils.contains(linkRef, "://") || StringUtils.startsWith(linkRef, "mailto:");
}

From source file:io.wcm.devops.conga.generator.plugins.fileheader.WindowsShellScriptFileHeaderTest.java

@Test
public void testApply() throws Exception {
    File file = new File("target/generation-test/fileHeader.cmd");
    FileUtils.write(file, "myscript");

    List<String> lines = ImmutableList.of("Der Jodelkaiser", "aus dem Oetztal", "ist wieder daheim.");
    FileHeaderContext context = new FileHeaderContext().commentLines(lines);
    FileContext fileContext = new FileContext().file(file);

    assertTrue(underTest.accepts(fileContext, context));
    underTest.apply(fileContext, context);

    assertTrue(StringUtils.contains(FileUtils.readFileToString(file),
            "REM Der Jodelkaiser\r\nREM aus dem Oetztal\r\nREM ist wieder daheim.\r\n"));

    FileHeaderContext extractContext = underTest.extract(fileContext);
    assertEquals(lines, extractContext.getCommentLines());

    file.delete();/* w w  w. ja  v  a  2s . c  om*/
}

From source file:io.wcm.devops.conga.generator.plugins.fileheader.XmlFileHeaderTest.java

@Test
public void testApply() throws Exception {
    File file = new File("target/generation-test/fileHeader.xml");
    FileUtils.copyFile(new File(getClass().getResource("/validators/xml/validXml.xml").toURI()), file);

    List<String> lines = ImmutableList.of("Der Jodelkaiser", "aus dem Oetztal", "ist wieder daheim.");
    FileHeaderContext context = new FileHeaderContext().commentLines(lines);
    FileContext fileContext = new FileContext().file(file);

    assertTrue(underTest.accepts(fileContext, context));
    underTest.apply(fileContext, context);

    assertTrue(StringUtils.contains(FileUtils.readFileToString(file),
            "Der Jodelkaiser\naus dem Oetztal\nist wieder daheim.\n"));

    FileHeaderContext extractContext = underTest.extract(fileContext);
    assertEquals(lines, extractContext.getCommentLines());

    file.delete();//from w  w  w. ja  va 2 s .  c o m
}

From source file:de.knightsoftnet.mtwidgets.client.ui.widget.oracle.PhoneNumberCommonRestOracle.java

@Override
protected boolean needSuggest(final String pentry) {
    return StringUtils.isNotEmpty(pentry)
            && (pentry.charAt(0) != '0' && StringUtils.countMatches(pentry, " ") < 2
                    || pentry.charAt(0) == '0' && !StringUtils.contains(pentry, '/'));
}

From source file:io.wcm.devops.conga.plugins.aem.fileheader.AnyFileHeaderTest.java

@Test
public void testApply() throws Exception {
    File file = new File("target/generation-test/fileHeader.any");
    FileUtils.write(file, "myany { }");

    List<String> lines = ImmutableList.of("Der Jodelkaiser", "aus dem Oetztal", "ist wieder daheim.");
    FileHeaderContext context = new FileHeaderContext().commentLines(lines);
    FileContext fileContext = new FileContext().file(file);

    assertTrue(underTest.accepts(fileContext, context));
    underTest.apply(fileContext, context);

    assertTrue(StringUtils.contains(FileUtils.readFileToString(file),
            "# Der Jodelkaiser\n# aus dem Oetztal\n# ist wieder daheim.\n"));

    FileHeaderContext extractContext = underTest.extract(fileContext);
    assertEquals(lines, extractContext.getCommentLines());

    file.delete();//from  w  ww  .  ja v a 2 s  . co  m
}

From source file:io.wcm.devops.conga.generator.plugins.fileheader.JsonFileHeaderTest.java

@Test
public void testApply() throws Exception {
    File file = new File("target/generation-test/fileHeader.json");
    FileUtils.copyFile(new File(getClass().getResource("/validators/json/validJson.json").toURI()), file);

    List<String> lines = ImmutableList.of("Der Jodelkaiser", "aus dem Oetztal", "ist wieder daheim.");
    FileHeaderContext context = new FileHeaderContext().commentLines(lines);
    FileContext fileContext = new FileContext().file(file);

    assertTrue(underTest.accepts(fileContext, context));
    underTest.apply(fileContext, context);

    assertTrue(StringUtils.contains(FileUtils.readFileToString(file),
            "Der Jodelkaiser\naus dem Oetztal\nist wieder daheim.\n"));

    FileHeaderContext extractContext = underTest.extract(fileContext);
    assertEquals(lines, extractContext.getCommentLines());

    file.delete();//from  w  ww . j  a  va2s. c o  m
}

From source file:de.knightsoftnet.mtwidgets.client.ui.widget.oracle.PhoneNumberDin5008RestOracle.java

@Override
protected boolean needSuggest(final String pentry) {
    return StringUtils.isNotEmpty(pentry)
            && (pentry.charAt(0) != '0' && StringUtils.countMatches(pentry, " ") < 2
                    || pentry.charAt(0) == '0' && !StringUtils.contains(pentry, ' '));
}

From source file:com.eryansky.common.orm.core.spring.data.jpa.specification.Specifications.java

/**
 * ???//from  www  .ja  va2 s.c om
 * 
 * @param propertyName ??
 * @param root Query roots always reference entities
 * 
 * @return {@link javax.persistence.criteria.Path}
 */
public static Path<?> getPath(String propertyName, Root<?> root) {

    Path<?> path = null;

    if (StringUtils.contains(propertyName, ".")) {
        String[] propertys = StringUtils.splitByWholeSeparator(propertyName, ".");
        path = root.get(propertys[0]);
        for (int i = 1; i < propertys.length; i++) {
            path = path.get(propertys[i]);
        }
    } else {
        path = root.get(propertyName);
    }

    return path;
}

From source file:io.wcm.devops.conga.generator.plugins.fileheader.UnixShellScriptFileHeaderTest.java

@Test
public void testApply() throws Exception {
    File file = new File("target/generation-test/fileHeader.sh");
    FileUtils.write(file, "#!/bin/bash\n" + "myscript");

    List<String> lines = ImmutableList.of("Der Jodelkaiser", "aus dem Oetztal", "ist wieder daheim.");
    FileHeaderContext context = new FileHeaderContext().commentLines(lines);
    FileContext fileContext = new FileContext().file(file);

    assertTrue(underTest.accepts(fileContext, context));
    underTest.apply(fileContext, context);

    String content = FileUtils.readFileToString(file);
    assertTrue(StringUtils.contains(content, "# Der Jodelkaiser\n# aus dem Oetztal\n# ist wieder daheim.\n"));
    assertTrue(StringUtils.endsWith(content, "\nmyscript"));
    assertTrue(StringUtils.startsWith(content, "#!/bin/bash\n"));

    FileHeaderContext extractContext = underTest.extract(fileContext);
    assertEquals(lines, extractContext.getCommentLines());

    file.delete();//  w  w  w .  j  av  a 2 s.  co m
}

From source file:io.wcm.devops.conga.plugins.sling.fileheader.ProvisioningFileHeaderTest.java

@Test
public void testApply() throws Exception {
    File file = new File("target/generation-test/fileHeader.txt");
    FileUtils.copyFile(new File(getClass().getResource("/validProvisioning.txt").toURI()), file);

    List<String> lines = ImmutableList.of("Der Jodelkaiser", "aus dem Oetztal", "ist wieder daheim.");
    FileHeaderContext context = new FileHeaderContext().commentLines(lines);
    FileContext fileContext = new FileContext().file(file);

    assertTrue(underTest.accepts(fileContext, context));
    underTest.apply(fileContext, context);

    assertTrue(StringUtils.contains(FileUtils.readFileToString(file, StandardCharsets.UTF_8),
            "# Der Jodelkaiser\n# aus dem Oetztal\n# ist wieder daheim.\n"));

    FileHeaderContext extractContext = underTest.extract(fileContext);
    assertEquals(lines, extractContext.getCommentLines());

    file.delete();/*from  w w  w.  java 2  s  .c o m*/
}