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:Main.java

/**
 * This device's SN/*from ww  w. ja v  a  2 s .c  om*/
 *
 * @return SerialNumber
 */
public static String getSerialNumber() {
    String serialNumber = android.os.Build.SERIAL;
    if ((serialNumber == null || serialNumber.length() == 0 || serialNumber.contains("unknown"))) {
        String[] keys = new String[] { "ro.boot.serialno", "ro.serialno" };
        for (String key : keys) {
            try {
                Method systemProperties_get = Class.forName("android.os.SystemProperties").getMethod("get",
                        String.class);
                serialNumber = (String) systemProperties_get.invoke(null, key);
                if (serialNumber != null && serialNumber.length() > 0 && !serialNumber.contains("unknown"))
                    break;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    return serialNumber;
}

From source file:springfox.documentation.swagger2.web.HostNameProvider.java

static UriComponents componentsFrom(HttpServletRequest request) {
    ServletUriComponentsBuilder builder = ServletUriComponentsBuilder.fromServletMapping(request);

    ForwardedHeader forwarded = ForwardedHeader.of(request.getHeader(ForwardedHeader.NAME));
    String proto = hasText(forwarded.getProto()) ? forwarded.getProto()
            : request.getHeader("X-Forwarded-Proto");
    String forwardedSsl = request.getHeader("X-Forwarded-Ssl");

    if (hasText(proto)) {
        builder.scheme(proto);//from w  w w. ja  v a2s . co m
    } else if (hasText(forwardedSsl) && forwardedSsl.equalsIgnoreCase("on")) {
        builder.scheme("https");
    }

    String host = forwarded.getHost();
    host = hasText(host) ? host : request.getHeader("X-Forwarded-Host");

    if (!hasText(host)) {
        return builder.build();
    }

    String[] hosts = commaDelimitedListToStringArray(host);
    String hostToUse = hosts[0];

    if (hostToUse.contains(":")) {

        String[] hostAndPort = split(hostToUse, ":");

        builder.host(hostAndPort[0]);
        builder.port(Integer.parseInt(hostAndPort[1]));

    } else {
        builder.host(hostToUse);
        builder.port(-1); // reset port if it was forwarded from default port
    }

    String port = request.getHeader("X-Forwarded-Port");

    if (hasText(port)) {
        builder.port(Integer.parseInt(port));
    }

    return builder.build();
}

From source file:org.eclipse.lyo.ldp.sample.loaders.Loader.java

static BasicAuthSecurityHandler getCredentials(String[] args) {
    BasicAuthSecurityHandler basicAuthSecHandler = new BasicAuthSecurityHandler();
    argsCheck(args);//from   ww  w .  j a  v  a 2  s. c  om
    String auth = args[1];
    if (auth.contains(":")) {
        String[] split = auth.split(":");
        if (split.length == 2) {
            basicAuthSecHandler.setUserName(split[0]);
            basicAuthSecHandler.setPassword(split[1]);

        } else {
            System.err.println("ERROR: Usage: invalid basic authentication credentials");
        }
    } else {
        System.err.println("ERROR: Usage: invalid basic authentication credentials");
    }
    return basicAuthSecHandler;
}

From source file:com.palantir.atlasdb.keyvalue.api.TableReference.java

public static boolean isFullyQualifiedName(String tableName) {
    return tableName.contains(".");
}

From source file:de.monticore.templateclassgenerator.Modelfinder.java

private static String getDotSeperatedFQNModelName(String FQNModelPath, String FQNFilePath,
        String fileExtension) {/* w w w  . ja  va2 s .c om*/
    if (FQNFilePath.contains(FQNModelPath)) {
        String fqnModelName = FQNFilePath.substring(FQNModelPath.length() + 1);
        fqnModelName = fqnModelName.replace("." + fileExtension, "");
        if (fqnModelName.contains("\\")) {
            fqnModelName = fqnModelName.replaceAll("\\\\", ".");
        } else if (fqnModelName.contains("/")) {
            fqnModelName = fqnModelName.replaceAll("/", ".");
        }

        return fqnModelName;
    }
    return FQNFilePath;
}

From source file:Main.java

public static QName resolveQName(String qNameWithPrefix, Element element) {
    String nsPrefix;/*from  w  ww .  java 2s  . c  om*/
    String localName;
    if (qNameWithPrefix.contains(":")) {
        String[] parts = qNameWithPrefix.split(":");
        nsPrefix = parts[0];
        localName = parts[1];
    } else {
        nsPrefix = "";
        localName = qNameWithPrefix;
    }

    return new QName(resolveNamespacePrefix(nsPrefix, element), localName);
}

From source file:Main.java

public static String resolveFileNameForPath(String filePath) {
    int index = 0;
    String fileName = "";
    if ((index = filePath.lastIndexOf("/")) != -1)
        fileName = filePath.substring(index + 1);
    return fileName.contains(".") ? fileName : "";
}

From source file:Main.java

/**
 * returns a canonical line of a obj or mtl file.
 * e.g. it removes multiple whitespaces or comments from the given string.
 * @param line/*from w  w w .j  a va2 s .com*/
 * @return
 */
public static final String getCanonicalLine(String line) {
    line = trimWhiteSpaces.matcher(line).replaceAll(" ");
    if (line.contains("#")) {
        String[] parts = removeInlineComments.split(line);
        if (parts.length > 0)
            line = parts[0];//remove inline comments
    }
    return line;
}

From source file:Main.java

/**
 * Returns the ciphers preferred to use during tests. They may be chosen because they are widely
 * available or because they are fast. There is no requirement that they provide confidentiality
 * or integrity.//w w  w. j a v a 2 s .  co  m
 */
public static List<String> preferredCiphers() {
    String[] ciphers;
    try {
        ciphers = SSLContext.getDefault().getDefaultSSLParameters().getCipherSuites();
    } catch (NoSuchAlgorithmException ex) {
        throw new RuntimeException(ex);
    }
    List<String> ciphersMinusGcm = new ArrayList<String>();
    for (String cipher : ciphers) {
        // The GCM implementation in Java is _very_ slow (~1 MB/s)
        if (cipher.contains("_GCM_")) {
            continue;
        }
        ciphersMinusGcm.add(cipher);
    }
    return Collections.unmodifiableList(ciphersMinusGcm);
}

From source file:Main.java

private static String getRealPathFromURI(Context context, Uri contentUri) {
    String uriString = String.valueOf(contentUri);
    boolean goForKitKat = uriString.contains("com.android.providers");

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && goForKitKat) {
        return getPathForV19AndUp(context, contentUri);
    } else {//ww  w  . j  a  v  a2 s .com

        return getPathForPreV19(context, contentUri);
    }
}