List of usage examples for org.apache.commons.lang3 StringUtils lowerCase
public static String lowerCase(final String str)
Converts a String to lower case as per String#toLowerCase() .
A null input String returns null .
StringUtils.lowerCase(null) = null StringUtils.lowerCase("") = "" StringUtils.lowerCase("aBc") = "abc"
Note: As described in the documentation for String#toLowerCase() , the result of this method is affected by the current locale.
From source file:org.owasp.dependencycheck.dependency.Evidence.java
/** * Implements the hashCode for Evidence. * * @return hash code.//w w w .j a v a2 s .c o m */ @Override public int hashCode() { return new HashCodeBuilder(MAGIC_HASH_INIT_VALUE, MAGIC_HASH_MULTIPLIER).append(StringUtils.lowerCase(name)) .append(StringUtils.lowerCase(source)).append(StringUtils.lowerCase(value)).append(confidence) .toHashCode(); }
From source file:org.owasp.webgoat.controller.Start.java
private String getRole() { Collection<GrantedAuthority> authorities = (Collection<GrantedAuthority>) SecurityContextHolder.getContext() .getAuthentication().getAuthorities(); String role = "N/A"; for (GrantedAuthority authority : authorities) { authority.getAuthority();//from ww w .j a va2 s .c om role = authority.getAuthority(); role = StringUtils.lowerCase(role); role = StringUtils.remove(role, "role_"); break; } return role; }
From source file:org.polymap.p4.imports.ShapeFileValidator.java
/** * @param files// w ww. j a v a 2s .c om * @return */ private boolean containsAllRequiredFiles(ShapeFileDescription root) { boolean valid = true; Set<String> fileExtensions = root.getContainedFiles().stream() .map(f -> StringUtils.lowerCase(getFileExtension(f.file.get().getName()))) .collect(Collectors.toSet()); List<String> missing = new ArrayList<String>(); for (String ext : REQUIRED_VALID_SHAPE_FILE_EXTS) { if (!fileExtensions.contains(ext)) { valid = false; missing.add(root + "." + ext); } } if (!valid) { reportError(root, Joiner.on(", ").join(missing) + " must be provided."); } return valid; }
From source file:org.polymap.p4.imports.ShapeFileValidator.java
/** * @param files//ww w .j a v a2 s .c o m * @return */ private boolean containsAllOptionalFiles(ShapeFileDescription root) { boolean valid = true; Set<String> fileExtensions = root.getContainedFiles().stream() .map(f -> StringUtils.lowerCase(getFileExtension(f.file.get().getName()))) .collect(Collectors.toSet()); List<String> missing = new ArrayList<String>(); for (String ext : OPTIONAL_VALID_SHAPE_FILE_EXTS) { if (!fileExtensions.contains(ext)) { missing.add(root.groupName.get() + "." + ext); } } if (missing.size() > 0) { reportWarning(root, Joiner.on(", ").join(missing) + " might be required as well."); } return valid; }
From source file:org.primefaces.extensions.component.calculator.CalculatorRenderer.java
private void encodeScript(final FacesContext context, final Calculator calculator) throws IOException { String target = SearchExpressionFacade.resolveClientIds(context, calculator, calculator.getFor()); if (isValueBlank(target)) { target = calculator.getParent().getClientId(context); }// w w w . j a v a 2s . c o m UIComponent targetComponent = SearchExpressionFacade.resolveComponent(context, calculator, target); if (!(targetComponent instanceof UIInput)) { throw new FacesException("Calculator must use for=\"target\" or be nested inside an input!"); } final WidgetBuilder wb = getWidgetBuilder(context); wb.initWithDomReady("ExtCalculator", calculator.resolveWidgetVar(), calculator.getClientId(context)); wb.attr("target", target); wb.attr("showOn", StringUtils.lowerCase(calculator.getShowOn())); wb.attr("layout", StringUtils.lowerCase(calculator.getLayout())); wb.attr("precision", calculator.getPrecision()); wb.attr("locale", calculator.calculateLocale().toString()); wb.attr("isRTL", ComponentUtils.isRTL(context, calculator)); wb.attr("calculatorClass", calculator.getStyleClass()); if (calculator.getOnopen() != null) { // Define a callback function before the panel is opened wb.callback("onOpen", "function(value, inst)", calculator.getOnopen()); } if (calculator.getOnclose() != null) { // Define a callback function when the panel is closed wb.callback("onClose", "function(value, inst)", calculator.getOnclose()); } if (calculator.getOnbutton() != null) { // Define a callback function when a button is activated wb.callback("onButton", "function(label, value, inst)", calculator.getOnbutton()); } encodeClientBehaviors(context, calculator); wb.finish(); }
From source file:org.primefaces.extensions.component.clipboard.ClipboardRenderer.java
private void encodeScript(final FacesContext context, final Clipboard clipboard) throws IOException { String trigger = SearchExpressionFacade.resolveClientIds(context, clipboard, clipboard.getTrigger()); if (isValueBlank(trigger)) { trigger = clipboard.getParent().getClientId(context); }//from w ww. ja v a 2s . c om final String target = SearchExpressionFacade.resolveClientIds(context, clipboard, clipboard.getTarget()); final WidgetBuilder wb = getWidgetBuilder(context); wb.initWithDomReady("ExtClipboard", clipboard.resolveWidgetVar(), clipboard.getClientId(context)); wb.attr("action", StringUtils.lowerCase(clipboard.getAction())); wb.attr("trigger", trigger); wb.attr("target", target); wb.attr("text", clipboard.getText()); if (clipboard.getOnsuccess() != null) { // Define a callback function if cut/copy succeeds wb.callback("onSuccess", "function(e)", clipboard.getOnsuccess()); } if (clipboard.getOnerror() != null) { // Define a callback function if cut/copy fails wb.callback("onError", "function(e)", clipboard.getOnerror()); } encodeClientBehaviors(context, clipboard); wb.finish(); }
From source file:org.primefaces.extensions.component.slideout.SlideOutRenderer.java
/** * Create the Javascript.//from www . j a v a 2s .c o m */ private void encodeScript(final FacesContext context, final SlideOut slideOut) throws IOException { final WidgetBuilder wb = getWidgetBuilder(context); final String clientId = slideOut.getClientId(context); final String handleId = getHandleId(context, slideOut); wb.initWithDomReady("ExtSlideOut", slideOut.resolveWidgetVar(), clientId); wb.attr("tabLocation", slideOut.getLocation()); wb.attr("tabHandle", handleId); wb.attr("speed", slideOut.getAnimateSpeed()); wb.attr("action", StringUtils.lowerCase(slideOut.getShowOn())); wb.attr("clickScreenToClose", slideOut.isClickScreenToClose()); wb.attr("onLoadSlideOut", slideOut.isAutoOpen()); wb.attr("positioning", slideOut.isSticky() ? "absolute" : "fixed"); wb.attr("offset", slideOut.getOffset()); wb.attr("offsetReverse", slideOut.isOffsetReverse()); wb.attr("handleOffsetReverse", slideOut.isHandleOffsetReverse()); wb.attr("bounceTimes", slideOut.getBounceTimes()); wb.attr("bounceDistance", slideOut.getBounceDistance()); wb.nativeAttr("clickScreenToCloseFilters", "['.ui-slideouttab-panel', 'button', 'a']"); if (slideOut.getHandleOffset() != null) { wb.attr("handleOffset", slideOut.getHandleOffset()); } if (slideOut.getOnopen() != null) { // Define a callback function before the panel is opened wb.callback("onOpen", "function()", slideOut.getOnopen()); } if (slideOut.getOnclose() != null) { // Define a callback function when the panel is closed wb.callback("onClose", "function()", slideOut.getOnclose()); } encodeClientBehaviors(context, slideOut); wb.finish(); }
From source file:org.primefaces.extensions.component.social.SocialRenderer.java
/** * Create the Javascript.//w ww .ja va2 s . c o m */ private void encodeScript(final FacesContext context, final Social social) throws IOException { final WidgetBuilder wb = getWidgetBuilder(context); final String clientId = social.getClientId(context); wb.initWithDomReady("ExtSocial", social.resolveWidgetVar(), clientId); wb.attr("showLabel", social.isShowLabel()); wb.attr("shareIn", social.getShareIn()); if (StringUtils.isNotBlank(social.getUrl())) { wb.attr("url", social.getUrl()); } if (StringUtils.isNotBlank(social.getText())) { wb.attr("text", social.getText()); } final boolean showCount = BooleanUtils.toBoolean(social.getShowCount()); if (showCount) { wb.attr("showCount", showCount); } else { if (social.getShowCount().equalsIgnoreCase("inside")) { wb.attr("showCount", social.getShowCount()); } else { wb.attr("showCount", showCount); } } // shares array wb.append(",shares: ["); final String[] shares = StringUtils.split(social.getShares(), ','); for (int i = 0; i < shares.length; i++) { // { share: "pinterest", media: "http://mysite.com" }, final String share = StringUtils.lowerCase(shares[i]); if (StringUtils.isEmpty(share)) { continue; } if (i != 0) { wb.append(","); } wb.append("{"); addShareProperty(wb, "share", share); if (share.equalsIgnoreCase("twitter")) { wb.attr("via", social.getTwitterUsername()); wb.attr("hashtags", social.getTwitterHashtags()); } if (share.equalsIgnoreCase("email")) { wb.attr("to", social.getEmailTo()); } if (share.equalsIgnoreCase("pinterest")) { wb.attr("media", social.getPinterestMedia()); } wb.append("}"); } wb.append("]"); // javascript wb.append(",on: {"); if (social.getOnclick() != null) { addCallback(wb, "click", "function(e)", social.getOnclick()); } if (social.getOnmouseenter() != null) { addCallback(wb, "mouseenter", "function(e)", social.getOnmouseenter()); } if (social.getOnmouseleave() != null) { addCallback(wb, "mouseleave", "function(e)", social.getOnmouseleave()); } wb.append("}"); encodeClientBehaviors(context, social); wb.finish(); }
From source file:org.sakaiproject.unboundid.UnboundidDirectoryProvider.java
/** * Maps attribites from the specified {@link LdapUserData} onto * a {@link org.sakaiproject.user.api.UserEdit}. Implemented to * delegate to the currently assigned {@link LdapAttributeMapper}. * //from w w w .j a v a2 s.co m * @see LdapAttributeMapper#mapUserDataOntoUserEdit(LdapUserData, UserEdit) * @param userData a non-null user cache entry * @param userEdit a non-null user domain object */ protected void mapUserDataOntoUserEdit(LdapUserData userData, UserEdit userEdit) { // std. UserEdit impl has no meaningful toString() impl log.debug("mapUserDataOntoUserEdit() [userData = {}]", userData); // delegate to the LdapAttributeMapper since it knows the most // about how the LdapUserData instance was originally populated ldapAttributeMapper.mapUserDataOntoUserEdit(userData, userEdit); userEdit.setEid(StringUtils.lowerCase(userData.getEid())); }
From source file:org.wise.portal.presentation.web.controllers.forgotaccount.student.PasswordReminderWizardController.java
/** * Maybe you want to be provided with the _page parameter (in order to map the same method for all), as you have in * AbstractWizardFormController./*w ww . j a va 2s . co m*/ */ @RequestMapping(method = RequestMethod.POST) public String processPage(@RequestParam("_page") final int currentPage, final @ModelAttribute("passwordReminderParameters") PasswordReminderParameters passwordReminderParameters, BindingResult result, SessionStatus status, ModelMap modelMap, final HttpServletResponse response) { switch (currentPage) { case 1: // handle the submit username try { String username = passwordReminderParameters.getUsername(); if (username == null) { result.rejectValue("username", "presentation.web.controllers.forgotaccount.student.PasswordReminderWizardController.errorNoUsername"); } else { username = StringUtils.trimToNull(username); User user = userService.retrieveUserByUsername(username); /* check to see if user exists and ensure that user is a student */ if (user == null || !(user.getUserDetails() instanceof StudentUserDetails)) { result.rejectValue("username", "presentation.web.controllers.forgotaccount.student.PasswordReminderWizardController.errorUsernameNotFound"); } } } catch (EmptyResultDataAccessException e) { result.rejectValue("username", "presentation.web.controllers.forgotaccount.student.PasswordReminderWizardController.errorUsernameNotFound"); } if (result.hasErrors()) { return "forgotaccount/student/passwordreminder"; } // passed validation, put username and account question into page String username = passwordReminderParameters.getUsername(); username = StringUtils.trimToNull(username); User user = userService.retrieveUserByUsername(username); StudentUserDetails userDetails = (StudentUserDetails) user.getUserDetails(); modelMap.put(USERNAME, userDetails.getUsername()); modelMap.put(ACCOUNT_QUESTION, userDetails.getAccountQuestion()); passwordReminderParameters.setAccountQuestion(userDetails.getAccountQuestion()); passwordReminderParameters.setAccountAnswer(userDetails.getAccountAnswer()); return "forgotaccount/student/passwordreminder2"; case 2: // handle the submit with account answer ValidationUtils.rejectIfEmptyOrWhitespace(result, "submittedAccountAnswer", "presentation.web.controllers.forgotaccount.student.PasswordReminderWizardController.errorSubmittedAccountQuestion"); String submittedAccountAnswer = passwordReminderParameters.getSubmittedAccountAnswer(); String accountAnswer = passwordReminderParameters.getAccountAnswer(); accountAnswer = StringUtils.lowerCase(accountAnswer); submittedAccountAnswer = StringUtils.lowerCase(submittedAccountAnswer); if (accountAnswer == null) { /* * the account answer is null perhaps because the session has * timed out so we will redirect them back to the first * password reminder page where they enter their user name */ return "forgotaccount/student/passwordreminder"; } else if (!accountAnswer.equals(submittedAccountAnswer)) { //they have provided an incorrect account answer result.reject( "presentation.web.controllers.forgotaccount.student.PasswordReminderWizardController.errorSubmittedAccountQuestion"); } if (result.hasErrors()) { modelMap.put(USERNAME, passwordReminderParameters.getUsername()); modelMap.put(ACCOUNT_QUESTION, passwordReminderParameters.getAccountQuestion()); return "forgotaccount/student/passwordreminder2"; } // passed validation, go to next page return "forgotaccount/student/passwordreminder3"; case 3: // handle the submit with new passwords ValidationUtils.rejectIfEmptyOrWhitespace(result, "verifyPassword", "presentation.web.controllers.forgotaccount.student.PasswordReminderWizardController.errorVerifyNewPassword"); ValidationUtils.rejectIfEmptyOrWhitespace(result, "newPassword", "presentation.web.controllers.forgotaccount.student.PasswordReminderWizardController.errorVerifyNewPassword"); if (result.hasErrors()) { return "forgotaccount/student/passwordreminder3"; } String newPassword = passwordReminderParameters.getNewPassword(); String verifyPassword = passwordReminderParameters.getVerifyPassword(); if (!verifyPassword.equals(newPassword)) { result.reject( "presentation.web.controllers.forgotaccount.student.PasswordReminderWizardController.errorVerifyNewPassword"); } if (result.hasErrors()) { return "forgotaccount/student/passwordreminder3"; } // passed validation, save new password String usernameSubmitted = passwordReminderParameters.getUsername(); usernameSubmitted = StringUtils.trimToNull(usernameSubmitted); User userSubmitted = userService.retrieveUserByUsername(usernameSubmitted); if (newPassword != null) { userService.updateUserPassword(userSubmitted, newPassword); } //clear the command object from the session status.setComplete(); modelMap.put("username", passwordReminderParameters.get(PasswordReminderParameters.USERNAME)); return "forgotaccount/student/passwordreminder4"; } return null; }