java.lang.String#startsWith ( )源码实例Demo

下面列出了java.lang.String#startsWith ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dragonwell8_jdk   文件: TestKGParity.java
private void run() throws Exception {
    Provider[] providers = Security.getProviders();
    for (Provider p : providers) {
        String prvName = p.getName();
        if (prvName.startsWith("SunJCE")
                || prvName.startsWith("SunPKCS11-")) {
            for (String algorithm : ALGORITHM_ARR) {
                if (!runTest(p, algorithm)) {
                    throw new RuntimeException(
                            "Test failed with provider/algorithm:"
                                    + p.getName() + "/" + algorithm);
                } else {
                    out.println("Test passed with provider/algorithm:"
                            + p.getName() + "/" + algorithm);
                }
            }
        }
    }
}
 
源代码2 项目: Android-utils   文件: NumberUtils.java
/**
 * <p>Convert a <code>String</code> to a <code>BigInteger</code>;
 * since 3.2 it handles hex (0x or #) and octal (0) notations.</p>
 *
 * <p>Returns <code>null</code> if the string is <code>null</code>.</p>
 *
 * @param str  a <code>String</code> to convert, may be null
 * @return converted <code>BigInteger</code> (or null if the input is null)
 * @throws NumberFormatException if the value cannot be converted
 */
public static BigInteger createBigInteger(final String str) {
    if (str == null) {
        return null;
    }
    int pos = 0; // offset within string
    int radix = 10;
    boolean negate = false; // need to negate later?
    if (str.startsWith("-")) {
        negate = true;
        pos = 1;
    }
    if (str.startsWith("0x", pos) || str.startsWith("0x", pos)) { // hex
        radix = 16;
        pos += 2;
    } else if (str.startsWith("#", pos)) { // alternative hex (allowed by Long/Integer)
        radix = 16;
        pos ++;
    } else if (str.startsWith("0", pos) && str.length() > pos + 1) { // octal; so long as there are additional digits
        radix = 8;
        pos ++;
    } // default is to treat as decimal

    final BigInteger value = new BigInteger(str.substring(pos), radix);
    return negate ? value.negate() : value;
}
 
源代码3 项目: TencentKona-8   文件: TestKGParity.java
private void run() throws Exception {
    Provider[] providers = Security.getProviders();
    for (Provider p : providers) {
        String prvName = p.getName();
        if (prvName.startsWith("SunJCE")
                || prvName.startsWith("SunPKCS11-")) {
            for (String algorithm : ALGORITHM_ARR) {
                if (!runTest(p, algorithm)) {
                    throw new RuntimeException(
                            "Test failed with provider/algorithm:"
                                    + p.getName() + "/" + algorithm);
                } else {
                    out.println("Test passed with provider/algorithm:"
                            + p.getName() + "/" + algorithm);
                }
            }
        }
    }
}
 
源代码4 项目: openjdk-jdk8u   文件: TestKGParity.java
private void run() throws Exception {
    Provider[] providers = Security.getProviders();
    for (Provider p : providers) {
        String prvName = p.getName();
        if (prvName.startsWith("SunJCE")
                || prvName.startsWith("SunPKCS11-")) {
            for (String algorithm : ALGORITHM_ARR) {
                if (!runTest(p, algorithm)) {
                    throw new RuntimeException(
                            "Test failed with provider/algorithm:"
                                    + p.getName() + "/" + algorithm);
                } else {
                    out.println("Test passed with provider/algorithm:"
                            + p.getName() + "/" + algorithm);
                }
            }
        }
    }
}
 
源代码5 项目: openjdk-jdk8u-backup   文件: TestKGParity.java
private void run() throws Exception {
    Provider[] providers = Security.getProviders();
    for (Provider p : providers) {
        String prvName = p.getName();
        if (prvName.startsWith("SunJCE")
                || prvName.startsWith("SunPKCS11-")) {
            for (String algorithm : ALGORITHM_ARR) {
                if (!runTest(p, algorithm)) {
                    throw new RuntimeException(
                            "Test failed with provider/algorithm:"
                                    + p.getName() + "/" + algorithm);
                } else {
                    out.println("Test passed with provider/algorithm:"
                            + p.getName() + "/" + algorithm);
                }
            }
        }
    }
}
 
源代码6 项目: openjdk-jdk9   文件: TestKGParity.java
private void run() throws Exception {
    Provider[] providers = Security.getProviders();
    for (Provider p : providers) {
        String prvName = p.getName();
        if (prvName.startsWith("SunJCE")
                || prvName.startsWith("SunPKCS11-")) {
            for (String algorithm : ALGORITHM_ARR) {
                if (!runTest(p, algorithm)) {
                    throw new RuntimeException(
                            "Test failed with provider/algorithm:"
                                    + p.getName() + "/" + algorithm);
                } else {
                    out.println("Test passed with provider/algorithm:"
                            + p.getName() + "/" + algorithm);
                }
            }
        }
    }
}
 
源代码7 项目: jdk8u-jdk   文件: TestKGParity.java
private void run() throws Exception {
    Provider[] providers = Security.getProviders();
    for (Provider p : providers) {
        String prvName = p.getName();
        if (prvName.startsWith("SunJCE")
                || prvName.startsWith("SunPKCS11-")) {
            for (String algorithm : ALGORITHM_ARR) {
                if (!runTest(p, algorithm)) {
                    throw new RuntimeException(
                            "Test failed with provider/algorithm:"
                                    + p.getName() + "/" + algorithm);
                } else {
                    out.println("Test passed with provider/algorithm:"
                            + p.getName() + "/" + algorithm);
                }
            }
        }
    }
}
 
源代码8 项目: hottub   文件: TestKGParity.java
private void run() throws Exception {
    Provider[] providers = Security.getProviders();
    for (Provider p : providers) {
        String prvName = p.getName();
        if (prvName.startsWith("SunJCE")
                || prvName.startsWith("SunPKCS11-")) {
            for (String algorithm : ALGORITHM_ARR) {
                if (!runTest(p, algorithm)) {
                    throw new RuntimeException(
                            "Test failed with provider/algorithm:"
                                    + p.getName() + "/" + algorithm);
                } else {
                    out.println("Test passed with provider/algorithm:"
                            + p.getName() + "/" + algorithm);
                }
            }
        }
    }
}
 
源代码9 项目: jdk8u_jdk   文件: TestKGParity.java
private void run() throws Exception {
    Provider[] providers = Security.getProviders();
    for (Provider p : providers) {
        String prvName = p.getName();
        if (prvName.startsWith("SunJCE")
                || prvName.startsWith("SunPKCS11-")) {
            for (String algorithm : ALGORITHM_ARR) {
                if (!runTest(p, algorithm)) {
                    throw new RuntimeException(
                            "Test failed with provider/algorithm:"
                                    + p.getName() + "/" + algorithm);
                } else {
                    out.println("Test passed with provider/algorithm:"
                            + p.getName() + "/" + algorithm);
                }
            }
        }
    }
}
 
源代码10 项目: vespa   文件: FieldSetRepo.java
public FieldSet parse(DocumentTypeManager docMan, String fieldSet) {
    if (fieldSet.length() == 0) {
        throw new IllegalArgumentException("Illegal field set value \"\"");
    }

    if (fieldSet.startsWith("[")) {
        return parseSpecialValues(fieldSet);
    }

    StringTokenizer tokenizer = new StringTokenizer(fieldSet, ":");
    if (tokenizer.countTokens() != 2) {
        throw new IllegalArgumentException(
                "The field set list must consist of a document type, " +
                "then a colon (:), then a comma-separated list of field names");
    }

    String type = tokenizer.nextToken();
    String fields = tokenizer.nextToken();

    return parseFieldCollection(docMan, type, fields);
}
 
源代码11 项目: JarBundler   文件: PropertyListWriter.java
private void writeJavaProperties(Hashtable javaProperties, Node appendTo)
{

    writeKey("Properties", appendTo);

    Node propertiesDict = createNode("dict", appendTo);

    for (Iterator i = javaProperties.keySet().iterator(); i.hasNext(); )
    {
        String key = (String) i.next();

        if (key.startsWith("com.apple.") && (bundleProperties.getJavaVersion() >= 1.4))
        {
            System.out.println("Deprecated as of 1.4: " + key);
            continue;
        }

        writeKeyStringPair(key, (String) javaProperties.get(key), propertiesDict);
    }
}
 
源代码12 项目: micro-integrator   文件: OAuthMediator.java
/**
 * Checks if the message contains Authorization header or query strings
 *
 * @param synCtx
 * @return
 */
private boolean validateRequest(MessageContext synCtx) {

    boolean isOauth2 = false;
    String accessToken = null;

    org.apache.axis2.context.MessageContext msgContext = ((Axis2MessageContext) synCtx).getAxis2MessageContext();
    Map headersMap =
            (Map) msgContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
    String authHeader = (String) headersMap.get("Authorization");

    // if we can't find the OAuth header, prompt error
    if (authHeader == null) {
        throw new SynapseException("Not a valid OAuth Request");
    }

    // checking for OAuth 2.0 params
    if (authHeader != null && authHeader.startsWith(OAuthConstants.BEARER)) {
        isOauth2 = true;
        // Do not need do validate an empty OAuth2 token
        if (authHeader.length() > OAuthConstants.BEARER.length()) {
            accessToken = authHeader.substring(OAuthConstants.BEARER.length()).trim();
        }
    }

    // not a valid OAuth 2.0 request
    if (isOauth2 == true && accessToken == null) {
        // Throw a correct descriptive message.
        throw new SynapseException("Invalid or empty OAuth 2.0 token");
    }

    return isOauth2;
}
 
源代码13 项目: micro-integrator   文件: OAuthMediator.java
private String removeLeadingAndTrailingQuatation(String base) {
    String result = base;

    if (base.startsWith("\"") || base.endsWith("\"")) {
        result = base.replace("\"", "");
    }
    return result.trim();
}
 
源代码14 项目: disthene-reader   文件: RenderParameters.java
private static long parseExtendedTime(String timeString, DateTimeZone tz) {
    Matcher matcher = EXTENDED_TIME_PATTERN.matcher(timeString);

    if (matcher.matches()) {
        String value = matcher.group(1);
        String unit = matcher.group(2);
        long unitValue;

        // calc unit value
        if (unit.startsWith("s")) {
            unitValue = 1L;
        } else if (unit.startsWith("min")) {
            unitValue = 60L;
        } else if (unit.startsWith("h")) {
            unitValue = 3600L;
        } else if (unit.startsWith("d")) {
            unitValue = 86400L;
        } else if (unit.startsWith("w")) {
            unitValue = 604800L;
        } else if (unit.startsWith("mon")) {
            unitValue = 2678400L;
        } else if (unit.startsWith("y")) {
            unitValue = 31536000L;
        } else {
            unitValue = 60L;
        }
        // calc offset as (now) - (number * unit value)
        return (System.currentTimeMillis() / 1000L) - (Long.valueOf(value) * unitValue);
    } else if ("now".equals(timeString.toLowerCase())) {
        return System.currentTimeMillis() / 1000L;
    } else {
        return new DateTime(Long.valueOf(timeString) * 1000, tz).getMillis() / 1000L;
    }
}