Example usage for java.lang String contains

List of usage examples for java.lang String contains

Introduction

In this page you can find the example usage for java.lang String contains.

Prototype

public boolean contains(CharSequence s) 

Source Link

Document

Returns true if and only if this string contains the specified sequence of char values.

Usage

From source file:com.linkedin.pinot.common.TestUtils.java

public static String getFileFromResourceUrl(URL resourceUrl) {
    System.out.println(resourceUrl);
    // Check if we need to extract the resource to a temporary directory
    String resourceUrlStr = resourceUrl.toString();
    if (resourceUrlStr.contains("jar!")) {
        try {/*from   ww w .j a  v a 2s .c  o  m*/
            String extension = resourceUrlStr.substring(resourceUrlStr.lastIndexOf('.'));
            File tempFile = File.createTempFile("pinot-test-temp", extension);
            LOGGER.info("Extractng from " + resourceUrlStr + " to " + tempFile.getAbsolutePath());
            System.out.println("Extractng from " + resourceUrlStr + " to " + tempFile.getAbsolutePath());
            FileUtils.copyURLToFile(resourceUrl, tempFile);
            return tempFile.getAbsolutePath();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    } else {
        System.out.println("Not extracting plain file " + resourceUrl);
        return resourceUrl.getFile();
    }
}

From source file:com.pinterest.deployservice.common.CommonUtils.java

public static String determineScm(String repo) {
    if (repo.contains("/")) {
        return "Github";
    } else {/*from   w w  w  .  j a va 2s .  co  m*/
        return "Phabricator";
    }
}

From source file:Main.java

/**
 * Converts a PEM formatted cert in a given file to the binary DER format.
 *
 * @param pemPathname the location of the certificate to convert.
 * @return array of bytes that represent the certificate in DER format.
 * @throws IOException if the file cannot be read.
 *///from w  ww . ja  v a  2  s .  co  m
public static byte[] pemToDer(String pemPathname) throws IOException {
    BufferedReader reader = new BufferedReader(new FileReader(pemPathname));
    StringBuilder builder = new StringBuilder();

    // Skip past leading junk lines, if any.
    String line = reader.readLine();
    while (line != null && !line.contains(BEGIN_MARKER))
        line = reader.readLine();

    // Then skip the BEGIN_MARKER itself, if present.
    while (line != null && line.contains(BEGIN_MARKER))
        line = reader.readLine();

    // Now gather the data lines into the builder.
    while (line != null && !line.contains(END_MARKER)) {
        builder.append(line.trim());
        line = reader.readLine();
    }

    reader.close();
    return Base64.decode(builder.toString(), Base64.DEFAULT);
}

From source file:Main.java

public static String splitJidAndServer(String account) {
    if (account == null) {
        return null;
    }// ww w.  ja  v a  2  s  .  c  o  m
    if (!account.contains("@")) {
        return account;
    }
    String[] res = account.split("@");
    String name = res[0];
    if (name == null) {
        return "";
    } else {
        return res[0];
    }
}

From source file:Main.java

public static String cleanIdentifier(String id) {
    String cleanId = id;
    for (String s : ILLEGAL_ID_CHARACTERS) {
        if (cleanId.contains(s))
            cleanId = cleanId.replace(s, "");
    }//from w w  w. j a  v  a  2 s  .c  o m
    return cleanId;
}

From source file:com.braffdev.server.core.module.mapping.MappingType.java

/**
 * @param uri//from   w  w  w. j  a  va2  s . c  o  m
 * @return
 */
public static MappingType get(String uri) {
    if (StringUtils.isNotBlank(uri)) {
        if (uri.contains(Constants.Mapping.REGEX_WILDCARD_SECTION)
                || uri.contains(Constants.Mapping.REGEX_WILDCARD)) {
            return WILDCARD;
        }
    }

    return DIRECT;
}

From source file:cz.incad.kramerius.k5.k5velocity.K5APIRetriever.java

private static ForwardServlet.TypeOfCall disectTypeOfCall(String queryString) {
    return queryString.contains("admin") ? ForwardServlet.TypeOfCall.ADMIN : ForwardServlet.TypeOfCall.USER;
}

From source file:iddb.core.util.Validator.java

public static boolean isValidPlayerName(String value) {
    if (StringUtils.isEmpty(value) || value.contains(" "))
        return false;
    for (int i = 0; i < value.length(); i++)
        if (!validPlayerNameChar(value.charAt(i)))
            return false;
    return true;/*ww w  .  ja v a2s  . c  om*/
}

From source file:Main.java

public static String setDeviceName(String inDeviceName) {
    try {/*from ww w. j  a  va 2 s.c o  m*/
        if (null != inDeviceName && !"".equals(inDeviceName) && inDeviceName.contains("#")) {
            return inDeviceName.substring(0, inDeviceName.indexOf("#"));
        } else {
            return inDeviceName;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return inDeviceName;
}

From source file:Main.java

private static String readXsdVersionFromFile(Document doc) {
    final String JBOSS_ESB = "jbossesb";
    NodeList nodes = doc.getChildNodes();
    if (nodes != null) {
        for (int i = 0; i < nodes.getLength(); i++) {
            Node node = nodes.item(i);
            if (JBOSS_ESB.equals(node.getNodeName())) {
                NamedNodeMap attributes = node.getAttributes();
                for (int j = 0; j < attributes.getLength(); j++) {
                    Node attribute = attributes.item(j);
                    if ("xmlns".equals(attribute.getNodeName())) {
                        String value = attribute.getNodeValue();
                        if (value.contains(JBOSS_ESB) && value.endsWith(".xsd"))
                            return value.substring(value.lastIndexOf('/') + 1, value.length());
                        else
                            throw new IllegalStateException(
                                    "The ESB descriptor points to an invalid XSD" + value);
                    }//from   w w  w.j  ava2s .  c  om
                }
            }
        }
        throw new IllegalArgumentException("No root node " + JBOSS_ESB + " found.");
    } else
        throw new IllegalArgumentException("Descriptor has no root element !");
}