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:reconf.server.FlywayService.java
private String getDbMigration(String dataSourceUrl) { Pattern pattern = Pattern.compile("jdbc:([^:]+):.*"); Matcher matcher = pattern.matcher(StringUtils.lowerCase(dataSourceUrl)); if (!matcher.matches()) { throw new RuntimeException("spring.datasource.url does not match a known database"); }//from w ww . j a v a2 s . c o m String database = StringUtils.lowerCase(matcher.group(1)); if (clobIncompatible.contains(database)) { return "sql/" + database; } return "sql/" + "clob"; }
From source file:reconf.server.services.property.ClientReadPropertyService.java
private boolean isMatch(String instance, Property each) { Map<String, Object> params = new HashMap<>(); params.put("regexp", StringUtils.defaultString(each.getRuleRegexp())); params.put("instance", StringUtils.lowerCase(instance)); return (boolean) engine.eval(JS, params, "result"); }
From source file:scan.Scan.java
/** * cleanString method. This method is passed a string of text, the 'dirty string' and returns a * 'cleaned string'. The cleaning process involves removing white spaces, accents and making all * characters lowercase. This process could be extend to remove punctuation as well. * //ww w. jav a 2 s .c o m * The purpose of this process is simplify matching between two strings. * * @param dirtySrString a string that is unprocessed and is to be cleaned * @return returns a string that has been cleaned */ protected String cleanString(String dirtySrString) { String cleanString; cleanString = StringUtils.lowerCase(dirtySrString); cleanString = StringUtils.deleteWhitespace(cleanString); cleanString = StringUtils.stripAccents(cleanString); return cleanString; }
From source file:spdxedit.PackageEditor.java
/** * Opens the modal package editor for the provided package. * * @param pkg The package to edit. * @param relatablePackages Packages to which the edited package may optionally have defined relationships * @param parentWindow The parent window. *//*www. j ava2s.co m*/ public static void editPackage(final SpdxPackage pkg, final List<SpdxPackage> relatablePackages, SpdxDocumentContainer documentContainer, Window parentWindow) { final PackageEditor packageEditor = new PackageEditor(pkg, relatablePackages, documentContainer); final Stage dialogStage = new Stage(); dialogStage.setTitle("Edit SPDX Package: " + pkg.getName()); dialogStage.initStyle(StageStyle.DECORATED); dialogStage.initModality(Modality.APPLICATION_MODAL); dialogStage.setY(parentWindow.getX() + parentWindow.getWidth() / 2); dialogStage.setY(parentWindow.getY() + parentWindow.getHeight() / 2); dialogStage.setResizable(false); try { FXMLLoader loader = new FXMLLoader(NewPackageDialog.class.getResource("/PackageEditor.fxml")); loader.setController(packageEditor); Pane pane = loader.load(); Scene scene = new Scene(pane); dialogStage.setScene(scene); dialogStage.getIcons().clear(); dialogStage.getIcons().add(UiUtils.ICON_IMAGE_VIEW.getImage()); //Populate the file list on appearance dialogStage.setOnShown(event -> { try { final SpdxFile dummyfile = new SpdxFile(pkg.getName(), null, null, null, null, null, null, null, null, null, null, null, null); TreeItem<SpdxFile> root = new TreeItem<>(dummyfile); packageEditor.filesTable.setRoot(root); //Assume a package without is external //TODO: replace with external packages or whatever alternate mechanism in 2.1 packageEditor.btnAddFile.setDisable(pkg.getFiles().length == 0); root.getChildren() .setAll(Stream.of(pkg.getFiles()) .sorted(Comparator.comparing(file -> StringUtils.lowerCase(file.getName()))) //Sort by file name .map(TreeItem<SpdxFile>::new).collect(Collectors.toList())); } catch (InvalidSPDXAnalysisException e) { logger.error("Unable to get files for package " + pkg.getName(), e); } packageEditor.tabFiles.setExpanded(true); }); //Won't assign this event through FXML - don't want to propagate the stage beyond this point. packageEditor.btnOk.setOnMouseClicked(event -> dialogStage.close()); dialogStage.showAndWait(); } catch (IOException ioe) { throw new RuntimeException("Unable to load dialog", ioe); } }
From source file:spdxedit.SpdxLogic.java
public static FileType[] getTypesForFile(Path path) { String extension = StringUtils .lowerCase(StringUtils.substringAfterLast(path.getFileName().toString(), ".")); ArrayList<FileType> fileTypes = new ArrayList<>(); if (sourceFileExtensions.contains(extension)) { fileTypes.add(SpdxFile.FileType.fileType_source); }/* w ww .ja v a2 s. c om*/ if (binaryFileExtensions.contains(extension)) { fileTypes.add(FileType.fileType_binary); } if (textFileExtensions.contains(extension)) { fileTypes.add(FileType.fileType_text); } if (archiveFileExtensions.contains(extension)) { fileTypes.add(FileType.fileType_archive); } if ("spdx".equals(extension)) { fileTypes.add(FileType.fileType_spdx); } try { String mimeType = Files.probeContentType(path); if (StringUtils.startsWith(mimeType, MediaType.ANY_AUDIO_TYPE.type())) { fileTypes.add(FileType.fileType_audio); } if (StringUtils.startsWith(mimeType, MediaType.ANY_IMAGE_TYPE.type())) { fileTypes.add(FileType.fileType_image); } if (StringUtils.startsWith(mimeType, MediaType.ANY_APPLICATION_TYPE.type())) { fileTypes.add(FileType.fileType_application); } } catch (IOException ioe) { logger.warn("Unable to access file " + path.toString() + " to determine its type.", ioe); } return fileTypes.toArray(new FileType[] {}); }
From source file:spdxedit.SpdxLogic.java
public static String toString(FileType fileType) { Objects.requireNonNull(fileType); return WordUtils.capitalize(StringUtils.lowerCase(fileType.getTag())); }
From source file:spdxedit.SpdxLogic.java
public static String toString(RelationshipType relationshipType) { Objects.requireNonNull(relationshipType); return WordUtils .capitalize(StringUtils.lowerCase(StringUtils.replace(relationshipType.getTag(), "_", " "))); }
From source file:ubic.gemma.core.loader.genome.gene.ExternalFileGeneLoaderServiceImpl.java
/** * Creates a gene, where gene name and official gene symbol is set to gene symbol(from file) and official name is * set to geneName(from file). The gene description is set to a message indicating that the gene was imported from * an external file and the associated uniprot id. * If the gene already exists, then it is not modified, unless it lacks a gene product. In that case we add one and * return it.//from w ww. j ava2 s .c o m * * @param fields A string array containing gene symbol, gene name and uniprot id. * @param taxon Taxon relating to gene * @return Gene with associated gene product for loading into Gemma. Null if no gene was loaded (exists, or * invalid * fields) or modified. */ private Gene createGene(String[] fields, Taxon taxon) { assert fields.length > 1; String geneSymbol = fields[0]; String geneName = fields[1]; String uniProt = ""; if (fields.length > 2) uniProt = fields[2]; Gene gene; // need at least the gene symbol and gene name if (StringUtils.isBlank(geneSymbol) || StringUtils.isBlank(geneName)) { log.warn("Line did not contain valid gene information; GeneSymbol=" + geneSymbol + "GeneName=" + geneName + " UniProt=" + uniProt); return null; } if (log.isDebugEnabled()) log.debug("Creating gene " + geneSymbol); gene = geneService.findByOfficialSymbol(geneSymbol, taxon); if (gene != null) { Collection<GeneProductValueObject> existingProducts = geneService.getProducts(gene.getId()); if (existingProducts.isEmpty()) { log.warn("Gene " + gene + " exists, but has no products; adding one"); gene = geneService.thaw(gene); GeneProduct newgp = createGeneProduct(gene); newgp = geneProductService.create(newgp); gene.getProducts().add(newgp); geneService.update(gene); return gene; } log.info(gene + " already exists and is valid, will not update"); return null; // no need to create it, though we ignore the name. } gene = Gene.Factory.newInstance(); gene.setName(geneSymbol); gene.setOfficialSymbol(geneSymbol); gene.setOfficialName(StringUtils.lowerCase(geneName)); gene.setDescription("Imported from external annotation file"); gene.setTaxon(taxon); gene.getProducts().add(createGeneProduct(gene)); gene = (Gene) persisterHelper.persistOrUpdate(gene); return gene; }
From source file:uk.gov.gchq.koryphe.impl.function.ToLowerCase.java
@Override public String apply(final Object value) { if (null == value) { return null; }// w ww. j ava 2 s . c o m if (value instanceof String) { StringUtils.lowerCase((String) value); } return StringUtils.lowerCase(value.toString()); }
From source file:uk.gov.gchq.koryphe.impl.function.ToLowerCaseTest.java
@Test public void shouldLowerCaseInput() { // Given//ww w.ja va 2 s. c o m final ToLowerCase function = new ToLowerCase(); // When Object output = function.apply(TEST_STRING); assertEquals(StringUtils.lowerCase(TEST_STRING), output); }