Java Code Examples for org.apache.commons.lang.StringUtils#length()
The following examples show how to use
org.apache.commons.lang.StringUtils#length() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: S2gUtil.java From s2g-zuul with MIT License | 6 votes |
public static String getServerletUrl(HttpServletRequest request) { //String url= request.getServletPath(); String uri = request.getRequestURI(); String contextPath = request.getContextPath(); if (StringUtils.length(contextPath) > 0) { uri = StringUtils.substring(uri, contextPath.length()); } if(StringUtils.length(uri) > 0){ uri=uri.substring(1, StringUtils.length(uri)); } String query= request.getQueryString(); if(!StringUtils.isEmpty(query)){ uri+="?"+query; } return uri; }
Example 2
Source File: CookieHelper.java From ymate-platform-v2 with Apache License 2.0 | 6 votes |
/** * @return 获取全部Cookie */ public Map<String, BlurObject> getCookies() { Map<String, BlurObject> _returnValue = new HashMap<String, BlurObject>(); Cookie[] _cookies = __request.getCookies(); if (_cookies != null) { String _cookiePre = __owner.getModuleCfg().getCookiePrefix(); int _preLength = StringUtils.length(_cookiePre); for (Cookie _cookie : _cookies) { String _name = _cookie.getName(); if (_name.startsWith(_cookiePre)) { String _v = decodeValue(_cookie.getValue()); _returnValue.put(_name.substring(_preLength), new BlurObject(_v)); } } } return _returnValue; }
Example 3
Source File: LetterOfCreditFundServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 6 votes |
@Override public Collection findMatching(Map fieldValues) { AwardMethodOfPaymentDTO criteria = new AwardMethodOfPaymentDTO(); List<AwardMethodOfPaymentDTO> result = null; try { if (fieldValues.containsKey("letterOfCreditFundGroupCode") && StringUtils.length((String) fieldValues.get("letterOfCreditFundGroupCode")) > 0) { result = this.getWebService().getMatchingMethodOfPaymentsForBasisOfPayment((String) fieldValues.get("letterOfCreditFundGroupCode")); } else { criteria.setMethodOfPaymentCode((String) fieldValues.get("letterOfCreditFundCode")); criteria.setDescription((String) fieldValues.get("letterOfCreditFundDescription")); result = this.getWebService().getMatchingMethodOfPayments(criteria); } } catch (WebServiceException ex) { GlobalVariablesExtractHelper.insertError(KcConstants.WEBSERVICE_UNREACHABLE, getConfigurationService().getPropertyValueAsString(KFSConstants.KC_APPLICATION_URL_KEY)); } List<LetterOfCreditFund> methods = new ArrayList<LetterOfCreditFund>(); if (result != null) { for (AwardMethodOfPaymentDTO dto : result) { methods.add(fundFromDTO(dto)); } } return methods; }
Example 4
Source File: DbcpFactory.java From seldon-server with Apache License 2.0 | 5 votes |
@Override public void configUpdated(String configKey, String configValue) { configValue = StringUtils.strip(configValue); logger.info("KEY WAS " + configKey); logger.info("Received new dbcp settings: " + configValue); if (StringUtils.length(configValue) == 0) { logger.warn("*WARNING* no dbcp is set!"); } else { try { logger.info("Processing configs "+configValue); ObjectMapper mapper = new ObjectMapper(); DbcpConfigList configs = mapper.readValue(configValue, DbcpConfigList.class); if (configs != null && configs.dbs != null) { for (DbcpConfig config : configs.dbs) createDbcp(config); } updateInitialised(); logger.info("Successfully set dbcp."); } catch (IOException e){ logger.error("Problem changing dbcp ", e); } } if (dataSources.size() == 0) { logger.error("No DBCP settings. Seldon will not run without a database connection. Please add settings to /config/dbcp"); throw new DbcpUninitialisedException(); } }
Example 5
Source File: ClientAlgorithmStore.java From seldon-server with Apache License 2.0 | 5 votes |
@Override public void configUpdated(String configKey, String configValue) { configValue = StringUtils.strip(configValue); logger.info("KEY WAS " + configKey); logger.info("Received new default strategy: " + configValue); if (StringUtils.length(configValue) == 0) { logger.warn("*WARNING* no default strategy is set!"); } else { try { ObjectMapper mapper = new ObjectMapper(); List<AlgorithmStrategy> strategies = new ArrayList<>(); AlgorithmConfig config = mapper.readValue(configValue, AlgorithmConfig.class); for (Algorithm alg : config.algorithms){ strategies.add(toAlgorithmStrategy(alg)); } AlgorithmResultsCombiner combiner = applicationContext.getBean( config.combiner,AlgorithmResultsCombiner.class); Map<Integer,Double> actionWeightMap = toActionWeightMap(config.actionWeights); ClientStrategy strat = new SimpleClientStrategy(strategies, combiner, config.diversityLevel,"-",actionWeightMap); defaultStrategy = strat; logger.info("Successfully changed default strategy."); } catch (IOException e){ logger.error("Problem changing default strategy ", e); } } }
Example 6
Source File: IMSSender.java From iaf with Apache License 2.0 | 5 votes |
@Override public void configure() throws ConfigurationException { if (StringUtils.isEmpty(getTransactionCode())) { throw new ConfigurationException("transactionCode must be specified"); } if (StringUtils.length(getTransactionCode()) != 8) { throw new ConfigurationException("transactionCode must be 8 positions, current code [" + getTransactionCode() + "] with length [" + StringUtils.length(getTransactionCode()) + "]"); } super.configure(); }
Example 7
Source File: UserController.java From feiqu-opensource with Apache License 2.0 | 4 votes |
@ResponseBody @PostMapping("updateUserInfo") public Object updateUserInfo(FqUser queryUser, HttpServletRequest request, HttpServletResponse response) { BaseResult baseResult = new BaseResult(); FqUserCache currUser = webUtil.currentUser(request,response); if(currUser == null){ baseResult.setResult(ResultEnum.USER_NOT_LOGIN); return baseResult; } if(!currUser.getId().equals(queryUser.getId())){ baseResult.setResult(ResultEnum.USER_NOT_SAME); return baseResult; } if(!Validator.isEmail(queryUser.getUsername())){ baseResult.setResult(ResultEnum.EMAIL_NOT_CORRECT); return baseResult; } if(StringUtils.isBlank(queryUser.getNickname().trim())){ baseResult.setResult(ResultEnum.PARAM_NULL); return baseResult; } if(StringUtils.length(queryUser.getCity()) > 20){ baseResult.setResult(ResultEnum.PARAM_ERROR); baseResult.setMessage("城市不能超过20个字符"); return baseResult; } FqUserExample example = new FqUserExample(); example.createCriteria().andNicknameEqualTo(queryUser.getNickname().trim()).andIdNotEqualTo(queryUser.getId()); FqUser userDB = userService.selectFirstByExample(example); if (null != userDB) { baseResult.setResult(ResultEnum.NICKNAME_EXIST); return baseResult; } example.clear(); example.createCriteria().andUsernameEqualTo(queryUser.getUsername().trim()).andIdNotEqualTo(queryUser.getId()); userDB = userService.selectFirstByExample(example); if (null != userDB) { baseResult.setResult(ResultEnum.USERNAME_EXIST); return baseResult; } if(!queryUser.getUsername().equals(currUser.getUsername())){ queryUser.setIsMailBind(YesNoEnum.NO.getValue()); } userService.updateByPrimaryKeySelective(queryUser); FqUser fqUserNew = userService.selectByPrimaryKey(queryUser.getId()); CacheManager.refreshUserCacheByUser(new FqUserCache(fqUserNew)); return baseResult; }
Example 8
Source File: RESTApiFacadeImpl.java From zstack with Apache License 2.0 | 4 votes |
private static String getApiResult(APIEvent e) { String apiResult = RESTApiDecoder.dump(e); apiResult = StringUtils.length(apiResult) > restResultMaxLength ? StringUtils.left(apiResult, restResultMaxLength) : apiResult; return apiResult; }
Example 9
Source File: TextRenderer.java From objectlabkit with Apache License 2.0 | 4 votes |
private String truncate(int size, String value) { return StringUtils.length(value) <= size ? value : value.substring(0, size); }
Example 10
Source File: ByteUtil.java From heisenberg with Apache License 2.0 | 4 votes |
/** * 比较s1是否大于s2,大于返回正数,等于返回0,小于返回负数;比较规则:长度(长>短),ASCII码(大>小) */ private static int compare(String s1, String s2) { int len1 = StringUtils.length(s1); int len2 = StringUtils.length(s2); return len1 == len2 ? s1.compareTo(s2) : len1 - len2; }
Example 11
Source File: DisbursementPayeeLookupableHelperServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 2 votes |
/** * Determines if a String is "filled enough", i.e. if a wildcard is present, has a length greater than the defined minimum length (3 characters, plus a wildcard). * @param s the String to test * @return true if the given String is "filled" by the definition above, false otherwise */ protected boolean filledEnough(String s) { return !containsLookupWildcard(s) || StringUtils.length(s) >= getNameLengthWithWildcardRequirement(); }