當前位置: 首頁>>代碼示例>>Java>>正文


Java BooleanUtils類代碼示例

本文整理匯總了Java中org.apache.commons.lang3.BooleanUtils的典型用法代碼示例。如果您正苦於以下問題:Java BooleanUtils類的具體用法?Java BooleanUtils怎麽用?Java BooleanUtils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BooleanUtils類屬於org.apache.commons.lang3包,在下文中一共展示了BooleanUtils類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: call

import org.apache.commons.lang3.BooleanUtils; //導入依賴的package包/類
@Override
public Object call(Element element, List<SyntaxNode> params) {
    if (params.size() == 0) {
        return false;
    }
    Object calc = params.get(0).calc(element);
    if (calc == null) {
        return false;
    }
    if (calc instanceof Boolean) {
        return calc;
    }
    if (calc instanceof String) {
        return BooleanUtils.toBoolean(calc.toString());
    }
    if (calc instanceof Integer) {
        return calc != 0;
    }
    if (calc instanceof Number) {
        return ((Number) calc).doubleValue() > 0D;
    }
    return false;
}
 
開發者ID:virjar,項目名稱:sipsoup,代碼行數:24,代碼來源:BooleanFunction.java

示例2: responseHeadersSecurityFilter

import org.apache.commons.lang3.BooleanUtils; //導入依賴的package包/類
@RefreshScope
@Bean
public FilterRegistrationBean responseHeadersSecurityFilter() {
    final HttpWebRequestProperties.Header header = casProperties.getHttpWebRequest().getHeader();
    final Map<String, String> initParams = new HashMap<>();
    initParams.put("enableCacheControl", BooleanUtils.toStringTrueFalse(header.isCache()));
    initParams.put("enableXContentTypeOptions", BooleanUtils.toStringTrueFalse(header.isXcontent()));
    initParams.put("enableStrictTransportSecurity", BooleanUtils.toStringTrueFalse(header.isHsts()));
    initParams.put("enableXFrameOptions", BooleanUtils.toStringTrueFalse(header.isXframe()));
    initParams.put("enableXSSProtection", BooleanUtils.toStringTrueFalse(header.isXss()));
    final FilterRegistrationBean bean = new FilterRegistrationBean();
    bean.setFilter(new ResponseHeadersEnforcementFilter());
    bean.setUrlPatterns(Collections.singleton("/*"));
    bean.setInitParameters(initParams);
    bean.setName("responseHeadersSecurityFilter");
    bean.setAsyncSupported(true);
    return bean;

}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:20,代碼來源:CasFiltersConfiguration.java

示例3: requestParameterSecurityFilter

import org.apache.commons.lang3.BooleanUtils; //導入依賴的package包/類
@RefreshScope
@Bean
public FilterRegistrationBean requestParameterSecurityFilter() {
    final Map<String, String> initParams = new HashMap<>();
    initParams.put(RequestParameterPolicyEnforcementFilter.PARAMETERS_TO_CHECK,
            casProperties.getHttpWebRequest().getParamsToCheck());
    initParams.put(RequestParameterPolicyEnforcementFilter.CHARACTERS_TO_FORBID, "none");
    initParams.put(RequestParameterPolicyEnforcementFilter.ALLOW_MULTI_VALUED_PARAMETERS,
            BooleanUtils.toStringTrueFalse(casProperties.getHttpWebRequest().isAllowMultiValueParameters()));
    initParams.put(RequestParameterPolicyEnforcementFilter.ONLY_POST_PARAMETERS,
            casProperties.getHttpWebRequest().getOnlyPostParams());

    final FilterRegistrationBean bean = new FilterRegistrationBean();
    bean.setFilter(new RequestParameterPolicyEnforcementFilter());
    bean.setUrlPatterns(Collections.singleton("/*"));
    bean.setName("requestParameterSecurityFilter");
    bean.setInitParameters(initParams);
    bean.setAsyncSupported(true);
    return bean;
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:21,代碼來源:CasFiltersConfiguration.java

示例4: getAttributesForSamlRegisteredService

import org.apache.commons.lang3.BooleanUtils; //導入依賴的package包/類
@Override
protected Map<String, Object> getAttributesForSamlRegisteredService(final Map<String, Object> attributes,
                                                                    final SamlRegisteredService service,
                                                                    final ApplicationContext applicationContext,
                                                                    final SamlRegisteredServiceCachingMetadataResolver resolver,
                                                                    final SamlRegisteredServiceServiceProviderMetadataFacade facade,
                                                                    final EntityDescriptor entityDescriptor) {
    final Pattern pattern = RegexUtils.createPattern(this.entityIds);
    final Matcher matcher = pattern.matcher(entityDescriptor.getEntityID());

    LOGGER.debug("Creating pattern [{}] to match against entity id [{}]", pattern.pattern(), entityDescriptor.getEntityID());

    final boolean matched = fullMatch ? matcher.matches() : matcher.find();
    LOGGER.debug("Pattern [{}] matched against [{}]? [{}]", pattern.pattern(), entityDescriptor.getEntityID(),
            BooleanUtils.toStringYesNo(matched));

    if (matched) {
        return authorizeReleaseOfAllowedAttributes(attributes);
    }
    return new HashMap<>();
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:22,代碼來源:PatternMatchingEntityIdAttributeReleasePolicy.java

示例5: buildInternal

import org.apache.commons.lang3.BooleanUtils; //導入依賴的package包/類
@Override
protected WebApplicationService buildInternal(final WebApplicationService service,
                                              final Map<String, String> parameters) {
    final RegisteredService registeredService = this.servicesManager.findServiceBy(service);
    RegisteredServiceAccessStrategyUtils.ensureServiceAccessIsAllowed(service, registeredService);
    final Map.Entry<String, RegisteredServiceProperty> property = registeredService.getProperties()
            .entrySet().stream()
            .filter(entry -> entry.getKey().equalsIgnoreCase(TokenConstants.PROPERTY_NAME_TOKEN_AS_RESPONSE)
                    && BooleanUtils.toBoolean(entry.getValue().getValue()))
            .distinct()
            .findFirst()
            .orElse(null);

    if (property == null) {
        return super.buildInternal(service, parameters);
    }

    final String jwt = generateToken(service, parameters);
    final TokenWebApplicationService jwtService =
            new TokenWebApplicationService(service.getId(), service.getOriginalUrl(), service.getArtifactId());
    jwtService.setFormat(service.getFormat());
    jwtService.setLoggedOutAlready(service.isLoggedOutAlready());
    parameters.put(CasProtocolConstants.PARAMETER_TICKET, jwt);
    return jwtService;
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:26,代碼來源:TokenWebApplicationServiceResponseBuilder.java

示例6: isSatisfiedBy

import org.apache.commons.lang3.BooleanUtils; //導入依賴的package包/類
@Override
public boolean isSatisfiedBy(final Assertion assertion, final HttpServletRequest request) {
    LOGGER.debug("Is validation specification set to enforce [{}] protocol behavior? [{}]. Is assertion issued from a new login? [{}]",
            CasProtocolConstants.PARAMETER_RENEW,
            BooleanUtils.toStringYesNo(this.renew),
            BooleanUtils.toStringYesNo(assertion.isFromNewLogin()));
    
    boolean satisfied = isSatisfiedByInternal(assertion);
    if (!satisfied) {
        LOGGER.warn("[{}] is not internally satisfied by the produced assertion", getClass().getSimpleName());
        return false;
    }
    satisfied = !this.renew || assertion.isFromNewLogin();
    if (!satisfied) {
        LOGGER.warn("[{}] is to enforce the [{}] CAS protocol behavior, yet the assertion is not issued from a new login",
                getClass().getSimpleName(), CasProtocolConstants.PARAMETER_RENEW);
        return false;
    }
    LOGGER.debug("Validation specification is satisfied by the produced assertion");
    return true;
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:22,代碼來源:AbstractCasProtocolValidationSpecification.java

示例7: resolveModifier

import org.apache.commons.lang3.BooleanUtils; //導入依賴的package包/類
private void resolveModifier(
    final GenericAttributeValue<Boolean> attribute,
    final String methodName,
    final List<String> resultList
) {
    if (attribute == null) {
        return;
    }
    final Boolean value = BooleanUtils.toBooleanObject(attribute.getStringValue());
    if (value == null) {
        return;
    }
    if (value) {
        resultList.add(methodName);
    } else {
        resultList.add(methodName + "(false)");
    }

}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:20,代碼來源:TSStructureTreeElement.java

示例8: buildByTokenHolder

import org.apache.commons.lang3.BooleanUtils; //導入依賴的package包/類
private SyntaxNode buildByTokenHolder(TokenHolder tokenHolder) {
    if (tokenHolder.tokenType == TokenType.Expression) {
        return new ExpressionParser(new StringFunctionTokenQueue(tokenHolder.data)).parse();
    }
    if (tokenHolder.tokenType == TokenType.Function) {
        return parseFunction(new StringFunctionTokenQueue(tokenHolder.data));
    }
    if (tokenHolder.tokenType == TokenType.String) {
        return new StringSyntaxNode(tokenHolder.data);
    }
    if (tokenHolder.tokenType == TokenType.Boolean) {
        return new BooleanSyntaxNode(BooleanUtils.toBoolean(tokenHolder.data));
    }
    if (tokenHolder.tokenType == TokenType.Number) {
        if (tokenHolder.data.contains(".")) {
            return new NumberSyntaxNode(NumberUtils.toDouble(tokenHolder.data));
        } else {
            return new NumberSyntaxNode(NumberUtils.toInt(tokenHolder.data));
        }
    }
    throw new IllegalStateException("unknown token type: " + tokenHolder.tokenType);
}
 
開發者ID:virjar,項目名稱:vscrawler,代碼行數:23,代碼來源:ExpressionParser.java

示例9: mafMasterDataSource

import org.apache.commons.lang3.BooleanUtils; //導入依賴的package包/類
@Bean(name = ConfigConstant.NAME_DS_MASTER)
@Primary
@ConfigurationProperties(prefix = ConfigConstant.PREFIX_DS_MASTER)
public DataSource mafMasterDataSource() {
    logger.info("----- MAFIA master data source INIT -----");
    DruidDataSource ds = new DruidDataSource();
    try {
        ds.setFilters(env.getProperty("ds.filters"));
    } catch (SQLException e) {
        logger.warn("Data source set filters ERROR:", e);
    }
    ds.setMaxActive(NumberUtils.toInt(env.getProperty("ds.maxActive"), 90));
    ds.setInitialSize(NumberUtils.toInt(env.getProperty("ds.initialSize"), 10));
    ds.setMaxWait(NumberUtils.toInt(env.getProperty("ds.maxWait"), 60000));
    ds.setMinIdle(NumberUtils.toInt(env.getProperty("ds.minIdle"), 1));
    ds.setTimeBetweenEvictionRunsMillis(NumberUtils.toInt(env.getProperty("ds.timeBetweenEvictionRunsMillis"), 60000));
    ds.setMinEvictableIdleTimeMillis(NumberUtils.toInt(env.getProperty("ds.minEvictableIdleTimeMillis"), 300000));
    ds.setValidationQuery(env.getProperty("ds.validationQuery"));
    ds.setTestWhileIdle(BooleanUtils.toBoolean(env.getProperty("ds.testWhileIdle")));
    ds.setTestOnBorrow(BooleanUtils.toBoolean(env.getProperty("ds.testOnBorrow")));
    ds.setTestOnReturn(BooleanUtils.toBoolean(env.getProperty("ds.testOnReturn")));
    ds.setPoolPreparedStatements(BooleanUtils.toBoolean(env.getProperty("ds.poolPreparedStatements")));
    ds.setMaxOpenPreparedStatements(NumberUtils.toInt(env.getProperty("ds.maxOpenPreparedStatements"), 20));
    return ds;
}
 
開發者ID:slking1987,項目名稱:mafia,代碼行數:26,代碼來源:DsMasterConfig.java

示例10: mafSlaveDataSource

import org.apache.commons.lang3.BooleanUtils; //導入依賴的package包/類
@Bean(name = ConfigConstant.NAME_DS_SLAVE)
@ConfigurationProperties(prefix = ConfigConstant.PREFIX_DS_SLAVE)
public DataSource mafSlaveDataSource() {
    logger.info("----- MAFIA slave data source INIT -----");
    DruidDataSource ds = new DruidDataSource();
    try {
        ds.setFilters(env.getProperty("ds.filters"));
    } catch (SQLException e) {
        logger.warn("Data source set filters ERROR:", e);
    }
    ds.setMaxActive(NumberUtils.toInt(env.getProperty("ds.maxActive"), 90));
    ds.setInitialSize(NumberUtils.toInt(env.getProperty("ds.initialSize"), 10));
    ds.setMaxWait(NumberUtils.toInt(env.getProperty("ds.maxWait"), 60000));
    ds.setMinIdle(NumberUtils.toInt(env.getProperty("ds.minIdle"), 1));
    ds.setTimeBetweenEvictionRunsMillis(NumberUtils.toInt(env.getProperty("ds.timeBetweenEvictionRunsMillis"), 60000));
    ds.setMinEvictableIdleTimeMillis(NumberUtils.toInt(env.getProperty("ds.minEvictableIdleTimeMillis"), 300000));
    ds.setValidationQuery(env.getProperty("ds.validationQuery"));
    ds.setTestWhileIdle(BooleanUtils.toBoolean(env.getProperty("ds.testWhileIdle")));
    ds.setTestOnBorrow(BooleanUtils.toBoolean(env.getProperty("ds.testOnBorrow")));
    ds.setTestOnReturn(BooleanUtils.toBoolean(env.getProperty("ds.testOnReturn")));
    ds.setPoolPreparedStatements(BooleanUtils.toBoolean(env.getProperty("ds.poolPreparedStatements")));
    ds.setMaxOpenPreparedStatements(NumberUtils.toInt(env.getProperty("ds.maxOpenPreparedStatements"), 20));
    return ds;
}
 
開發者ID:slking1987,項目名稱:mafia,代碼行數:25,代碼來源:DsSlaveConfig.java

示例11: AgpInputBrokerDefinitionAdaptor

import org.apache.commons.lang3.BooleanUtils; //導入依賴的package包/類
/**
 * Creates instance of the adaptor.
 * @param def broker definition
 * @throws IllegalArgumentException if invalid broker definition
 */
public AgpInputBrokerDefinitionAdaptor(EntityDefinition def) throws InvalidDefinitionException {
  super(def);
  this.credAdaptor =new CredentialsDefinitionAdaptor(def);
  this.botsAdaptor = new BotsBrokerDefinitionAdaptor(def);
  if (StringUtils.trimToEmpty(def.getType()).isEmpty()) {
    def.setType(AgpInputConnector.TYPE);
  } else if (!AgpInputConnector.TYPE.equals(def.getType())) {
    throw new InvalidDefinitionException("Broker definition doesn't match");
  } else {
    try {
      hostUrl = new URL(get(P_HOST_URL));
    } catch (MalformedURLException ex) {
      throw new InvalidDefinitionException(String.format("Invalid %s: %s", P_HOST_URL,get(P_HOST_URL)), ex);
    }
    folderId = get(P_FOLDER_ID);
    emitXml = BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(get(P_EMIT_XML)), true);
    emitJson = BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(get(P_EMIT_JSON)), false);
  }
}
 
開發者ID:Esri,項目名稱:geoportal-server-harvester,代碼行數:25,代碼來源:AgpInputBrokerDefinitionAdaptor.java

示例12: GptBrokerDefinitionAdaptor

import org.apache.commons.lang3.BooleanUtils; //導入依賴的package包/類
/**
 * Creates instance of the adaptor.
 * @param def broker definition
 */
public GptBrokerDefinitionAdaptor(EntityDefinition def) throws InvalidDefinitionException {
  super(def);
  this.credAdaptor = new CredentialsDefinitionAdaptor(def);
  this.botsAdaptor = new BotsBrokerDefinitionAdaptor(def);
  if (StringUtils.trimToEmpty(def.getType()).isEmpty()) {
    def.setType(GptConnector.TYPE);
  } else if (!GptConnector.TYPE.equals(def.getType())) {
    throw new InvalidDefinitionException("Broker definition doesn't match");
  } else {
    try {
      String sHostUrl = get(P_HOST_URL);
      if (sHostUrl!=null) {
        sHostUrl = sHostUrl.replaceAll("/*$", "/");
      }
      hostUrl = new URL(sHostUrl);
    } catch (MalformedURLException ex) {
      throw new InvalidDefinitionException(String.format("Invalid %s: %s", P_HOST_URL,get(P_HOST_URL)), ex);
    }
    index  = get(P_INDEX);
    emitXml = BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(get(P_EMIT_XML)), true);
    emitJson = BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(get(P_EMIT_JSON)), false);
  }
}
 
開發者ID:Esri,項目名稱:geoportal-server-harvester,代碼行數:28,代碼來源:GptBrokerDefinitionAdaptor.java

示例13: AgsBrokerDefinitionAdaptor

import org.apache.commons.lang3.BooleanUtils; //導入依賴的package包/類
/**
 * Creates instance of the adaptor.
 * @param def broker definition
 * @throws InvalidDefinitionException if invalid broker definition
 */
public AgsBrokerDefinitionAdaptor(EntityDefinition def) throws InvalidDefinitionException {
  super(def);
  this.credAdaptor =new CredentialsDefinitionAdaptor(def);
  this.botsAdaptor = new BotsBrokerDefinitionAdaptor(def);
  if (StringUtils.trimToEmpty(def.getType()).isEmpty()) {
    def.setType(AgsConnector.TYPE);
  } else if (!AgsConnector.TYPE.equals(def.getType())) {
    throw new InvalidDefinitionException("Broker definition doesn't match");
  } else {
    try {
      hostUrl = new URL(get(P_HOST_URL));
    } catch (MalformedURLException ex) {
      throw new InvalidDefinitionException(String.format("Invalid %s: %s", P_HOST_URL,get(P_HOST_URL)), ex);
    }
    enableLayers = BooleanUtils.toBoolean(get(P_ENABLE_LAYERS));
    emitXml = BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(get(P_EMIT_XML)), true);
    emitJson = BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(get(P_EMIT_JSON)), false);
  }
}
 
開發者ID:Esri,項目名稱:geoportal-server-harvester,代碼行數:25,代碼來源:AgsBrokerDefinitionAdaptor.java

示例14: read

import org.apache.commons.lang3.BooleanUtils; //導入依賴的package包/類
@Override
public Boolean read(JsonReader in) throws IOException {
  JsonToken peek = in.peek();
  switch (peek) {
    case BOOLEAN:
      return in.nextBoolean();
    case NULL:
      in.nextNull();
      return null;
    case NUMBER:
      return BooleanUtils.toBoolean(in.nextInt());
    case STRING:
      return BooleanUtils.toBoolean(in.nextString());
    default:
      throw new JsonParseException("Expected BOOLEAN or NUMBER but was " + peek);
  }
}
 
開發者ID:binarywang,項目名稱:weixin-java-tools,代碼行數:18,代碼來源:WxBooleanTypeAdapter.java

示例15: execute

import org.apache.commons.lang3.BooleanUtils; //導入依賴的package包/類
protected <T> ResponseEntity<T> execute(String url,
                                        HttpMethod httpMethod,
                                        HttpEntity<?> httpEntity,
                                        ParameterizedTypeReference<T> typeReference,
                                        Map<String, String> uriVariables) {
    if (Objects.isNull(uriVariables)) {
        uriVariables = Maps.newHashMap();
    }

    if (BooleanUtils.isTrue(swallowException)) {
        try {
            return doExecute(url, httpMethod, httpEntity, typeReference, uriVariables);
        } catch (Exception e) {
            // camouflage exception
            log.error("http call failed, url [{}], http method [{}], http entity [{}], uri vars [{}]",
                    url, httpMethod, httpEntity, uriVariables, e);
            return doCamouflageException();
        }
    } else {
        return doExecute(url, httpMethod, httpEntity, typeReference, uriVariables);
    }
}
 
開發者ID:srarcbrsent,項目名稱:tc,代碼行數:23,代碼來源:TcHttpxService.java


注:本文中的org.apache.commons.lang3.BooleanUtils類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。