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:com.ottogroup.bi.spqr.pipeline.MicroPipelineManagerTest.java
/** * Test case for {@link MicroPipelineManager#executePipeline(MicroPipelineConfiguration)} being provided a * valid configuration which leads to a registered {@link MicroPipeline} instance */// w w w .ja v a 2 s .co m @Test public void testExecutePipeline_withValidConfiguration() throws Exception { MicroPipelineConfiguration cfg = new MicroPipelineConfiguration(); cfg.setId("testExecutePipeline_withValidConfiguration"); MicroPipeline pipeline = Mockito.mock(MicroPipeline.class); Mockito.when(pipeline.getId()).thenReturn(cfg.getId()); MicroPipelineFactory factory = Mockito.mock(MicroPipelineFactory.class); Mockito.when(factory.instantiatePipeline(cfg, executorService)).thenReturn(pipeline); MicroPipelineManager manager = new MicroPipelineManager("id", factory, executorService); Assert.assertEquals("Values must be equal", StringUtils.lowerCase(StringUtils.trim(cfg.getId())), manager.executePipeline(cfg)); Assert.assertEquals("Values must be equal", 1, manager.getNumOfRegisteredPipelines()); Mockito.verify(factory).instantiatePipeline(cfg, executorService); }
From source file:com.adguard.android.commons.RawResources.java
/** * Cleans up language code, leaves only first part of it * * @param language Language code (like en_US) * @return language (like en)/*from ww w . j a va 2 s . c o m*/ */ private static String cleanUpLanguageCode(String language) { String languageCode = StringUtils.substringBefore(language, "_"); return StringUtils.lowerCase(languageCode); }
From source file:fr.scc.elo.controller.manager.impl.EloManagerImpl.java
@Override public MatchMaking matchMaker(String playersString, String eloType, Boolean createPlayers) throws EloException { if (StringUtils.isBlank(playersString)) { return null; }//from w ww .j a va 2 s . co m List<String> playerList = Arrays.asList(StringUtils.lowerCase(playersString).split(",")); List<Player> players = new ArrayList<>(); playerList.forEach(p -> players.add(eloService.createPlayer(p))); Team teamBlue = Team.builder().members(new ArrayList<>()).build(); Team teamRed = Team.builder().members(new ArrayList<>()).build(); players.forEach(p -> addPlayer(p, teamBlue, teamRed)); return equilibrage(teamBlue, teamRed, EloType.fromName(eloType)); }
From source file:com.bekwam.resignator.ResignatorAppMainViewController.java
@FXML public void initialize() { try {//from w w w . jav a 2 s. co m miHelp.setAccelerator(KeyCombination.keyCombination("F1")); cbType.getItems().add(SigningArgumentsType.JAR); cbType.getItems().add(SigningArgumentsType.FOLDER); cbType.getSelectionModel().select(SigningArgumentsType.JAR); cbType.setConverter(new StringConverter<SigningArgumentsType>() { @Override public String toString(SigningArgumentsType type) { return StringUtils.capitalize(StringUtils.lowerCase(String.valueOf(type))); } @Override public SigningArgumentsType fromString(String type) { return Enum.valueOf(SigningArgumentsType.class, StringUtils.upperCase(type)); } }); activeConfiguration.activeProfileProperty().bindBidirectional(activeProfile.profileNameProperty()); tfSourceFile.textProperty().bindBidirectional(activeProfile.sourceFileFileNameProperty()); tfTargetFile.textProperty().bindBidirectional(activeProfile.targetFileFileNameProperty()); ckReplace.selectedProperty().bindBidirectional(activeProfile.replaceSignaturesProperty()); cbType.valueProperty().bindBidirectional(activeProfile.argsTypeProperty()); miSave.disableProperty().bind(needsSave.not()); tfSourceFile.textProperty().addListener(new WeakInvalidationListener(needsSaveListener)); tfTargetFile.textProperty().addListener(new WeakInvalidationListener(needsSaveListener)); ckReplace.selectedProperty().addListener(new WeakInvalidationListener(needsSaveListener)); cbType.valueProperty().addListener(new WeakInvalidationListener(needsSaveListener)); lblSource.setText(SOURCE_LABEL_JAR); lblTarget.setText(TARGET_LABEL_JAR); cbType.getSelectionModel().selectedItemProperty().addListener((ov, old_v, new_v) -> { if (new_v == SigningArgumentsType.FOLDER) { if (!lblSource.getText().equalsIgnoreCase(SOURCE_LABEL_FOLDER)) { lblSource.setText(SOURCE_LABEL_FOLDER); } if (!lblSource.getText().equalsIgnoreCase(TARGET_LABEL_FOLDER)) { lblTarget.setText(TARGET_LABEL_FOLDER); } } else { if (!lblSource.getText().equalsIgnoreCase(SOURCE_LABEL_JAR)) { lblSource.setText(SOURCE_LABEL_JAR); } if (!lblSource.getText().equalsIgnoreCase(TARGET_LABEL_JAR)) { lblTarget.setText(TARGET_LABEL_JAR); } } }); lvProfiles.getSelectionModel().selectedItemProperty().addListener((ov, old_v, new_v) -> { if (new_v == null) { // coming from clearSelection or sort return; } if (needsSave.getValue()) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Discard unsaved profile?"); alert.setHeaderText("Unsaved profile"); Optional<ButtonType> response = alert.showAndWait(); if (!response.isPresent() || response.get() != ButtonType.OK) { if (logger.isDebugEnabled()) { logger.debug("[SELECT] discard canceled"); } return; } } if (logger.isDebugEnabled()) { logger.debug("[SELECT] nv={}", new_v); } doLoadProfile(new_v); }); lvProfiles.setCellFactory(TextFieldListCell.forListView()); Task<Void> t = new Task<Void>() { @Override protected Void call() throws Exception { updateMessage("Loading configuration"); configurationDS.loadConfiguration(); if (!configurationDS.isSecured()) { if (logger.isDebugEnabled()) { logger.debug("[CALL] config not secured; getting password"); } NewPasswordController npc = newPasswordControllerProvider.get(); if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] npc id={}", npc.hashCode()); } Platform.runLater(() -> { try { npc.showAndWait(); } catch (Exception exc) { logger.error("error showing npc", exc); } }); synchronized (npc) { try { npc.wait(MAX_WAIT_TIME); // 10 minutes to enter the password } catch (InterruptedException exc) { logger.error("new password operation interrupted", exc); } } if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] npc={}", npc.getHashedPassword()); } if (StringUtils.isNotEmpty(npc.getHashedPassword())) { activeConfiguration.setHashedPassword(npc.getHashedPassword()); activeConfiguration.setUnhashedPassword(npc.getUnhashedPassword()); activeConfiguration.setLastUpdatedDateTime(LocalDateTime.now()); configurationDS.saveConfiguration(); configurationDS.loadConfiguration(); configurationDS.decrypt(activeConfiguration.getUnhashedPassword()); } else { Platform.runLater(() -> { Alert noPassword = new Alert(Alert.AlertType.INFORMATION, "You'll need to provide a password to save your keystore credentials."); noPassword.showAndWait(); }); return null; } } else { PasswordController pc = passwordControllerProvider.get(); Platform.runLater(() -> { try { pc.showAndWait(); } catch (Exception exc) { logger.error("error showing pc", exc); } }); synchronized (pc) { try { pc.wait(MAX_WAIT_TIME); // 10 minutes to enter the password } catch (InterruptedException exc) { logger.error("password operation interrupted", exc); } } Platform.runLater(() -> { if (pc.getStage().isShowing()) { // ended in timeout timeout pc.getStage().hide(); } if (pc.wasCancelled() || pc.wasReset() || !pc.doesPasswordMatch()) { if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] was cancelled or the number of retries was exceeded"); } String msg = ""; if (pc.wasCancelled()) { msg = "You must provide a password to the datastore. Exitting..."; } else if (pc.wasReset()) { msg = "Data file removed. Exitting..."; } else { msg = "Exceeded maximum number of retries. Exitting..."; } Alert alert = new Alert(Alert.AlertType.WARNING, msg); alert.setOnCloseRequest((evt) -> { Platform.exit(); System.exit(1); }); alert.showAndWait(); } else { // // save password for later decryption ops // activeConfiguration.setUnhashedPassword(pc.getPassword()); configurationDS.decrypt(activeConfiguration.getUnhashedPassword()); // // init profileBrowser // if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] loading profiles from source"); } long startTimeMillis = System.currentTimeMillis(); final List<String> profileNames = configurationDS.getProfiles().stream() .map(Profile::getProfileName).sorted((o1, o2) -> o1.compareToIgnoreCase(o2)) .collect(Collectors.toList()); final List<String> recentProfiles = configurationDS.getRecentProfileNames(); if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] loading profiles into UI"); } lvProfiles.setItems(FXCollections.observableArrayList(profileNames)); if (CollectionUtils.isNotEmpty(recentProfiles)) { mRecentProfiles.getItems().clear(); mRecentProfiles.getItems().addAll( FXCollections.observableArrayList(recentProfiles.stream().map((s) -> { MenuItem mi = new MenuItem(s); mi.setOnAction(recentProfileLoadHandler); return mi; }).collect(Collectors.toList()))); } // // #31 preload the last active profile // if (StringUtils.isNotEmpty(activeConfiguration.getActiveProfile())) { if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] preloading last active profile={}", activeConfiguration.getActiveProfile()); } doLoadProfile(activeConfiguration.getActiveProfile()); } long endTimeMillis = System.currentTimeMillis(); if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] loading profiles took {} ms", (endTimeMillis - startTimeMillis)); } } }); } return null; } @Override protected void succeeded() { super.succeeded(); updateMessage(""); lblStatus.textProperty().unbind(); } @Override protected void cancelled() { super.cancelled(); logger.error("task cancelled", getException()); updateMessage(""); lblStatus.textProperty().unbind(); } @Override protected void failed() { super.failed(); logger.error("task failed", getException()); updateMessage(""); lblStatus.textProperty().unbind(); } }; lblStatus.textProperty().bind(t.messageProperty()); new Thread(t).start(); } catch (Exception exc) { logger.error("can't load configuration", exc); String msg = "Verify that the user has access to the directory '" + configFile + "' under " + System.getProperty("user.home") + "."; Alert alert = new Alert(Alert.AlertType.ERROR, msg); alert.setHeaderText("Can't load config file"); alert.showAndWait(); Platform.exit(); } }
From source file:com.ottogroup.bi.spqr.metrics.MetricsHandler.java
/** * {@link ScheduledReporter#stop() Stops} the referenced {@link ScheduledReporter} and removes it from * map of managed scheduled reporters//from ww w . ja v a 2 s. com * @param id */ public void removeScheduledReporter(final String id) { String key = StringUtils.lowerCase(StringUtils.trim(id)); ScheduledReporter scheduledReporter = this.scheduledReporters.get(key); if (scheduledReporter != null) { scheduledReporter.stop(); this.scheduledReporters.remove(key); } }
From source file:fr.scc.elo.controller.PlayerController.java
@GET @Path("/setelo/name/{n}/elo/{e}/type/{t}") @ApiOperation(value = "affecte un elo a un joueur", notes = "save=false si le joueur n'existe pas il y a une erreur", response = Player.class) public Response setEloToPlayerNoSave(@BeanParam PlayerRequest request, @Context HttpServletRequest http) throws EloException { try {//from ww w .j a v a 2 s . c o m if (!connectionService.acceptIPUpdate(http.getRemoteAddr())) { throw new EloException("Unauthorized IP: " + http.getRemoteAddr()); } Player player = eloManager.setEloToPlayer(StringUtils.lowerCase(request.getName()), request.getElo(), request.getTypeMatch(), request.getCreatePlayers()); return Response.ok().entity(player).build(); } catch (Exception e) { return Response.serverError().entity(e.getMessage()).build(); } }
From source file:com.ottogroup.bi.asap.pipeline.MicroPipelineManager.java
/** * Returns the referenced pipeline - used for testing purpose only ... at the moment ;-) * @param pipelineId// ww w. j a v a 2 s . c o m * @return */ protected MicroPipeline getPipeline(final String pipelineId) { return this.microPipelines.get(StringUtils.lowerCase(StringUtils.trim(pipelineId))); }
From source file:com.ottogroup.bi.spqr.node.server.SPQRNodeServer.java
/** * Initializes the log4j framework by pointing it to the configuration file referenced by parameter * @param log4jConfigurationFile// w w w . j av a 2 s.c o m */ protected void initializeLog4j(final String log4jConfigurationFile) { String log4jPropertiesFile = StringUtils.lowerCase(StringUtils.trim(log4jConfigurationFile)); if (StringUtils.isNoneBlank(log4jConfigurationFile)) { File log4jFile = new File(log4jPropertiesFile); if (log4jFile.isFile()) { try { PropertyConfigurator.configure(new FileInputStream(log4jFile)); } catch (FileNotFoundException e) { System.out.println("No log4j configuration found at '" + log4jConfigurationFile + "'"); } } else { System.out.println("No log4j configuration found at '" + log4jConfigurationFile + "'"); } } else { System.out.println("No log4j configuration file provided"); } }
From source file:com.yiji.openapi.sdk.util.Servlets.java
@SuppressWarnings("unchecked") public static Map<String, String> getHeaders(HttpServletRequest request, String prefixName) { Enumeration<String> names = request.getHeaderNames(); String name = null;/*from w w w.ja va 2 s.c o m*/ Map<String, String> map = Maps.newLinkedHashMap(); while (names.hasMoreElements()) { name = names.nextElement(); if (StringUtils.isNotBlank(prefixName)) { if (StringUtils.startsWithIgnoreCase(name, prefixName)) { map.put(StringUtils.lowerCase(name), getHeaderValue(request, name)); } } else { map.put(StringUtils.lowerCase(name), getHeaderValue(request, name)); } } return map; }
From source file:com.ottogroup.bi.asap.resman.node.ProcessingNodeManager.java
/** * Updates or instantiates a pipeline on remote processing nodes * @param deploymentProfile/*from w ww . j a v a 2 s . co m*/ * @return * @throws RequiredInputMissingException */ public PipelineDeploymentProfile updateOrInstantiatePipeline(final PipelineDeploymentProfile deploymentProfile) throws RequiredInputMissingException { /////////////////////////////////////////////////////// // validate input if (deploymentProfile == null) throw new RequiredInputMissingException("Missing required pipeline configuration"); // TODO validate even more // /////////////////////////////////////////////////////// for (final ProcessingNode pn : this.processingNodes.values()) { try { pn.updateOrInstantiatePipeline(deploymentProfile.getConfiguration()); deploymentProfile.addProcessingNode(StringUtils.lowerCase(StringUtils.trim(pn.getId()))); } catch (RemoteClientConnectionFailedException | IOException e) { logger.error("Failed to update or deploy pipeline '" + deploymentProfile.getId() + "' on processing node '" + pn.getId() + "'. Error: " + e.getMessage()); } } return deploymentProfile; }