java.lang.Boolean.parseBoolean()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(195)

本文整理了Java中java.lang.Boolean.parseBoolean()方法的一些代码示例,展示了Boolean.parseBoolean()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Boolean.parseBoolean()方法的具体详情如下:
包路径:java.lang.Boolean
类名称:Boolean
方法名:parseBoolean

Boolean.parseBoolean介绍

[英]Parses the specified string as a boolean.
[中]将指定的字符串解析为布尔值。

代码示例

代码示例来源:origin: apache/incubator-dubbo

private static String convertLegacyValue(String key, String value) {
  if (value != null && value.length() > 0) {
    if ("dubbo.service.max.retry.providers".equals(key)) {
      return String.valueOf(Integer.parseInt(value) - 1);
    } else if ("dubbo.service.allow.no.provider".equals(key)) {
      return String.valueOf(!Boolean.parseBoolean(value));
    }
  }
  return value;
}

代码示例来源:origin: apache/incubator-dubbo

private static String convertLegacyValue(String key, String value) {
  if (value != null && value.length() > 0) {
    if ("dubbo.service.max.retry.providers".equals(key)) {
      return String.valueOf(Integer.parseInt(value) - 1);
    } else if ("dubbo.service.allow.no.provider".equals(key)) {
      return String.valueOf(!Boolean.parseBoolean(value));
    }
  }
  return value;
}

代码示例来源:origin: ReactiveX/RxJava

void load(Properties properties) {
    if (properties.containsKey(PURGE_ENABLED_KEY)) {
      purgeEnable = Boolean.parseBoolean(properties.getProperty(PURGE_ENABLED_KEY));
    } else {
      purgeEnable = true;
    }
    if (purgeEnable && properties.containsKey(PURGE_PERIOD_SECONDS_KEY)) {
      try {
        purgePeriod = Integer.parseInt(properties.getProperty(PURGE_PERIOD_SECONDS_KEY));
      } catch (NumberFormatException ex) {
        purgePeriod = 1;
      }
    } else {
      purgePeriod = 1;
    }
  }
}

代码示例来源:origin: spring-projects/spring-framework

private static void useClassProxyingIfNecessary(BeanDefinitionRegistry registry, @Nullable Element sourceElement) {
  if (sourceElement != null) {
    boolean proxyTargetClass = Boolean.parseBoolean(sourceElement.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE));
    if (proxyTargetClass) {
      AopConfigUtils.forceAutoProxyCreatorToUseClassProxying(registry);
    }
    boolean exposeProxy = Boolean.parseBoolean(sourceElement.getAttribute(EXPOSE_PROXY_ATTRIBUTE));
    if (exposeProxy) {
      AopConfigUtils.forceAutoProxyCreatorToExposeProxy(registry);
    }
  }
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Retrieve the flag for the given property key.
 * @param key the property key
 * @return {@code true} if the property is set to "true",
 * {@code} false otherwise
 */
public static boolean getFlag(String key) {
  return Boolean.parseBoolean(getProperty(key));
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Return the value of the {@code Access-Control-Allow-Credentials} response header.
 */
public boolean getAccessControlAllowCredentials() {
  return Boolean.parseBoolean(getFirst(ACCESS_CONTROL_ALLOW_CREDENTIALS));
}

代码示例来源:origin: spring-projects/spring-framework

private boolean isMultiple() throws JspException {
  Object multiple = getMultiple();
  if (multiple != null) {
    String stringValue = multiple.toString();
    return ("multiple".equalsIgnoreCase(stringValue) || Boolean.parseBoolean(stringValue));
  }
  return forceMultiple();
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Apply the XPath expression and assert the resulting content as a Boolean.
 * @throws Exception if content parsing or expression evaluation fails
 */
public void assertBoolean(byte[] content, @Nullable String encoding, boolean expectedValue) throws Exception {
  String actual = evaluateXpath(content, encoding, String.class);
  AssertionErrors.assertEquals("XPath " + this.expression, expectedValue, Boolean.parseBoolean(actual));
}

代码示例来源:origin: apache/incubator-dubbo

public boolean getBooleanParameter(String key, boolean defaultValue) {
  String value = getParameter(key);
  if (StringUtils.isEmpty(value)) {
    return defaultValue;
  }
  return Boolean.parseBoolean(value);
}

代码示例来源:origin: apache/incubator-dubbo

public boolean getMethodBooleanParameter(String method, String key, boolean defaultValue) {
  String value = getMethodParameter(method, key);
  if (StringUtils.isEmpty(value)) {
    return defaultValue;
  }
  return Boolean.parseBoolean(value);
}

代码示例来源:origin: apache/incubator-dubbo

public boolean getMethodParameter(String method, String key, boolean defaultValue) {
  String value = getMethodParameter(method, key);
  if (StringUtils.isEmpty(value)) {
    return defaultValue;
  }
  return Boolean.parseBoolean(value);
}

代码示例来源:origin: apache/incubator-dubbo

public boolean getMethodParameter(String method, String key, boolean defaultValue) {
  String value = getMethodParameter(method, key);
  if (StringUtils.isEmpty(value)) {
    return defaultValue;
  }
  return Boolean.parseBoolean(value);
}

代码示例来源:origin: apache/incubator-dubbo

public boolean getBooleanParameter(String key) {
  String value = getParameter(key);
  if (StringUtils.isEmpty(value)) {
    return false;
  }
  return Boolean.parseBoolean(value);
}

代码示例来源:origin: apache/incubator-dubbo

public boolean getMethodBooleanParameter(String method, String key) {
  String value = getMethodParameter(method, key);
  if (StringUtils.isEmpty(value)) {
    return false;
  }
  return Boolean.parseBoolean(value);
}

代码示例来源:origin: apache/incubator-dubbo

public boolean getParameter(String key, boolean defaultValue) {
  String value = getParameter(key);
  if (StringUtils.isEmpty(value)) {
    return defaultValue;
  }
  return Boolean.parseBoolean(value);
}

代码示例来源:origin: apache/incubator-dubbo

public boolean getMethodBooleanParameter(String method, String key, boolean defaultValue) {
  String value = getMethodParameter(method, key);
  if (StringUtils.isEmpty(value)) {
    return defaultValue;
  }
  return Boolean.parseBoolean(value);
}

代码示例来源:origin: apache/incubator-dubbo

public boolean getBooleanParameter(String key, boolean defaultValue) {
  String value = getParameter(key);
  if (StringUtils.isEmpty(value)) {
    return defaultValue;
  }
  return Boolean.parseBoolean(value);
}

代码示例来源:origin: apache/incubator-dubbo

public boolean getParameter(String key, boolean defaultValue) {
  String value = getParameter(key);
  if (StringUtils.isEmpty(value)) {
    return defaultValue;
  }
  return Boolean.parseBoolean(value);
}

代码示例来源:origin: apache/incubator-dubbo

public boolean getMethodBooleanParameter(String method, String key) {
  String value = getMethodParameter(method, key);
  if (StringUtils.isEmpty(value)) {
    return false;
  }
  return Boolean.parseBoolean(value);
}

代码示例来源:origin: apache/incubator-dubbo

public boolean getBooleanParameter(String key) {
  String value = getParameter(key);
  if (StringUtils.isEmpty(value)) {
    return false;
  }
  return Boolean.parseBoolean(value);
}

相关文章