当前位置: 首页>>代码示例>>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;未经允许,请勿转载。