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.asap.operator.json.aggregator.JsonContentAggregatorResult.java
/** * Returns the aggregated value for a given field and value: (field='cs-host', value='www.otto.de', result: 5); * @param field// w w w . j a v a 2 s .c om * @param fieldValue * @return */ public long getAggregatedValue(final String field, final String fieldValue) { String fieldKey = StringUtils.lowerCase(StringUtils.trim(field)); Map<String, Long> fieldAggregationValues = this.aggregatedValues.get(fieldKey); return (fieldAggregationValues != null ? fieldAggregationValues.get(fieldValue) : 0); }
From source file:com.ottogroup.bi.asap.pipeline.MicroPipeline.java
/** * Submits the provided {@link SourceExecutor} to the pipeline instance * @param source/* w ww.j a v a 2 s . c o m*/ * @throws RequiredInputMissingException * @throws ComponentAlreadySubmittedException */ public void submitSourceExecutor(final SourceExecutor sourceExecutor) throws RequiredInputMissingException, ComponentAlreadySubmittedException { /////////////////////////////////////////////////////////////////// // validate input if (sourceExecutor == null) throw new RequiredInputMissingException("Missing required input for 'sourceExecutor'"); if (StringUtils.isBlank(sourceExecutor.getSourceId())) throw new RequiredInputMissingException("Missing required input for source identifier"); // /////////////////////////////////////////////////////////////////// // normalize identifier to lower case String sid = StringUtils.lowerCase(StringUtils.trim(sourceExecutor.getSourceId())); if (this.sourceExecutors.containsKey(sid)) throw new ComponentAlreadySubmittedException( "Component '" + sourceExecutor.getSourceId() + "' already submitted to pipeline '" + id + "'"); // add source executor to internal map and submit it to executor service this.sourceExecutors.put(sid, sourceExecutor); this.executorService.submit(sourceExecutor); if (logger.isDebugEnabled()) logger.debug("source executor submitted [pid=" + id + ", sid=" + sid + ", mb=source has no mailbox]"); }
From source file:com.ottogroup.bi.spqr.metrics.MetricsHandler.java
/** * {@link ScheduledReporter#stop() Stops} the referenced {@link ScheduledReporter} but keeps it referenced * @param id// w w w . j a v a2s . co m */ public void stopScheduledReporter(final String id) { String key = StringUtils.lowerCase(StringUtils.trim(id)); ScheduledReporter scheduledReporter = this.scheduledReporters.get(key); if (scheduledReporter != null) { scheduledReporter.stop(); } }
From source file:fi.foyt.fni.view.gamelibrary.GameLibraryEditPublicationBackingBean.java
public void addTag() { String tag = getAddExistingTag(); if ("_NEW_".equals(tag)) { tag = StringUtils.lowerCase(StringUtils.trim(getAddNewTag())); }// w ww .j a v a2 s. c om if (StringUtils.isNotBlank(tag) && (!tags.contains(tag))) { tags.add(tag); } }
From source file:ch.cyberduck.core.resources.NSImageIconCache.java
/** * @param file File/*from ww w . ja va 2 s . c o m*/ * @param size Requested size * @return Cached icon */ @Override public NSImage fileIcon(final Path file, final Integer size) { if (file.getType().contains(Path.Type.decrypted)) { final NSImage badge = this.iconNamed("unlockedbadge.tiff", size); badge.setName("unlockedbadge"); if (file.isDirectory()) { return this.folderIcon(size, badge); } return this.documentIcon(StringUtils.lowerCase(file.getExtension()), size, badge); } if (file.isSymbolicLink()) { final NSImage badge = this.iconNamed("aliasbadge.tiff", size); badge.setName("aliasbadge"); if (file.isDirectory()) { return this.folderIcon(size, badge); } return this.documentIcon(StringUtils.lowerCase(file.getExtension()), size, badge); } if (file.isFile()) { if (StringUtils.isEmpty(file.getExtension())) { if (file.attributes().getPermission().isExecutable()) { return this.iconNamed("executable.tiff", size); } } return this.documentIcon(StringUtils.lowerCase(file.getExtension()), size); } if (file.isDirectory()) { if (!Permission.EMPTY.equals(file.attributes().getPermission())) { if (!file.attributes().getPermission().isExecutable()) { final NSImage badge = this.iconNamed("privatefolderbadge.tiff", size); badge.setName("privatefolderbadge"); return this.folderIcon(size, badge); } if (!file.attributes().getPermission().isReadable()) { if (file.attributes().getPermission().isWritable()) { final NSImage badge = this.iconNamed("dropfolderbadge.tiff", size); badge.setName("dropfolderbadge"); return this.folderIcon(size, badge); } } if (!file.attributes().getPermission().isWritable()) { final NSImage badge = this.iconNamed("readonlyfolderbadge.tiff", size); badge.setName("readonlyfolderbadge"); return this.folderIcon(size, badge); } } return this.folderIcon(size); } return this.iconNamed("notfound.tiff", size); }
From source file:fr.scc.elo.controller.PlayerController.java
@GET @Path("/show/name/{n}/type/{t}") @ApiOperation(value = "affiche le elo d' joueur", notes = "", response = Player.class) public Response showElo(@BeanParam PlayerRequest request) throws EloException { try {/* w ww . j a v a2 s . c o m*/ Integer elo = eloManager .setEloToPlayer(StringUtils.lowerCase(request.getName()), request.getElo(), request.getTypeMatch(), request.getCreatePlayers()) .getElo(EloType.fromName(request.getTypeMatch())); return Response.ok().entity(elo).build(); } catch (Exception e) { return Response.serverError().entity(e.getMessage()).build(); } }
From source file:com.ottogroup.bi.spqr.pipeline.MicroPipelineManagerTest.java
/** * Test case for {@link MicroPipelineManager#getPipelineIds()} with previously registered {@link MicroPipeline} instance *///from ww w.j av a 2 s . c o m @Test public void testGetPipelineIds_withExistingConfiguration() 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.assertTrue("The result must be empty", manager.getPipelineIds().isEmpty()); Assert.assertEquals("Values must be equal", StringUtils.lowerCase(StringUtils.trim(cfg.getId())), manager.executePipeline(cfg)); Assert.assertEquals("Values must be equal", 1, manager.getNumOfRegisteredPipelines()); Assert.assertEquals("The set must contain 1 element", 1, manager.getPipelineIds().size()); Assert.assertTrue("The set must contain the identifier", manager.getPipelineIds().contains(StringUtils.lowerCase(StringUtils.trim(cfg.getId())))); Mockito.verify(factory).instantiatePipeline(cfg, executorService); }
From source file:com.ottogroup.bi.spqr.metrics.MetricsHandler.java
/** * {@link ScheduledReporter#start(long, java.util.concurrent.TimeUnit) Starts} the referenced {@link ScheduledReporter} * @param id//from w ww .j a va 2 s. c o m * @param period * @param unit */ public void startScheduledReporter(final String id, final int period, final TimeUnit unit) { String key = StringUtils.lowerCase(StringUtils.trim(id)); ScheduledReporter scheduledReporter = this.scheduledReporters.get(key); if (scheduledReporter != null) { scheduledReporter.start(period, unit); } }
From source file:com.xpn.xwiki.plugin.image.ImagePlugin.java
/** * Transforms the given image (i.e. shrinks the image and changes its quality) before it is downloaded. * // w w w . j a v a 2s.c o m * @param image the image to be downloaded * @param width the desired image width; this value is taken into account only if it is greater than zero and less * than the current image width * @param height the desired image height; this value is taken into account only if it is greater than zero and less * than the current image height * @param quality the desired compression quality * @param context the XWiki context * @return the transformed image * @throws Exception if transforming the image fails */ private XWikiAttachment downloadImage(XWikiAttachment image, int width, int height, float quality, XWikiContext context) throws Exception { if (this.imageCache == null) { initCache(context); } boolean keepAspectRatio = Boolean.valueOf(context.getRequest().getParameter("keepAspectRatio")); XWikiAttachment thumbnail = this.imageCache == null ? shrinkImage(image, width, height, keepAspectRatio, quality, context) : downloadImageFromCache(image, width, height, keepAspectRatio, quality, context); // If the image has been transformed, update the file name extension to match the image format. String fileName = thumbnail.getFilename(); String extension = StringUtils.lowerCase(StringUtils.substringAfterLast(fileName, String.valueOf('.'))); if (thumbnail != image && !Arrays.asList("jpeg", "jpg", "png").contains(extension)) { // The scaled image is PNG, so correct the extension in order to output the correct MIME type. thumbnail.setFilename(StringUtils.substringBeforeLast(fileName, ".") + ".png"); } return thumbnail; }
From source file:com.sccl.attech.generate.Generate.java
/** * java file.//from w w w. ja v a 2s . c o m * * @param subModuleName the sub module name * @param separator the separator * @param javaPath the java * @param cfg the cfg * @param model the model * @throws IOException Signals that an I/O exception has occurred. */ private static void createJavaFile(String subModuleName, String separator, String javaPath, Configuration cfg, Map<String, Object> model) throws IOException { Template template; String content; String filePath; template = cfg.getTemplate("controller.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = javaPath + separator + model.get("moduleName") + separator + "web" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Controller.java"; writeFile(content, filePath); logger.info("Controller: {}", filePath); }