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.jodconverter.document.SimpleDocumentFormatRegistry.java
/** * Add a new format to the registry.//from w w w . j a v a 2s .co m * * @param documentFormat The format to add. */ public void addFormat(final DocumentFormat documentFormat) { documentFormat.getExtensions().stream().map(StringUtils::lowerCase) .forEach(ext -> fmtsByExtension.put(ext, documentFormat)); fmtsByMediaType.put(StringUtils.lowerCase(documentFormat.getMediaType()), documentFormat); }
From source file:org.jodconverter.document.SimpleDocumentFormatRegistry.java
@Override public DocumentFormat getFormatByExtension(final String extension) { return extension == null ? null : fmtsByExtension.get(StringUtils.lowerCase(extension)); }
From source file:org.jodconverter.document.SimpleDocumentFormatRegistry.java
@Override public DocumentFormat getFormatByMediaType(final String mediaType) { return mediaType == null ? null : fmtsByMediaType.get(StringUtils.lowerCase(mediaType)); }
From source file:org.kuali.coeus.propdev.impl.person.ProposalPerson.java
/** * set the <code>simpleName</code> & the full name. *//*from w w w. jav a2 s . co m*/ @Override public void setFullName(String fullName) { this.fullName = fullName; setSimpleName(getFullName()); setSimpleName(StringUtils.lowerCase(getSimpleName())); setSimpleName(StringUtils.deleteWhitespace(getSimpleName())); setSimpleName(StringUtils.remove(getSimpleName(), '.')); }
From source file:org.languagetool.rules.de.CompoundInfinitivRule.java
private boolean isException(AnalyzedTokenReadings[] tokens, int n) { if (tokens[n - 2].hasPosTagStartingWith("VER")) { return true; }/* w ww . j ava 2 s . c om*/ if ("sagen".equals(tokens[n + 1].getToken()) && ("weiter".equals(tokens[n - 1].getToken()) || "dazu".equals(tokens[n - 1].getToken()))) { return true; } if (("tragen".equals(tokens[n + 1].getToken()) || "machen".equals(tokens[n + 1].getToken())) && "davon".equals(tokens[n - 1].getToken())) { return true; } if ("geben".equals(tokens[n + 1].getToken()) && "daran".equals(tokens[n - 1].getToken())) { return true; } if ("gehen".equals(tokens[n + 1].getToken()) && "ab".equals(tokens[n - 1].getToken())) { return true; } if ("errichten".equals(tokens[n + 1].getToken()) && "wieder".equals(tokens[n - 1].getToken())) { return true; } String verb = null; for (int i = n - 2; i > 0 && !isPunctuation(tokens[i].getToken()) && verb == null; i--) { if (tokens[i].hasPosTagStartingWith("VER:IMP")) { verb = StringUtils.lowerCase(getLemma(tokens[i])); } else if (tokens[i].hasPosTagStartingWith("VER")) { verb = tokens[i].getToken().toLowerCase(); } else if ("Fang".equals(tokens[i].getToken())) { verb = "fangen"; } if (verb != null) { if (!isMisspelled(tokens[n - 1].getToken() + verb)) { return true; } else { break; } } } if ("aus".equals(tokens[n - 1].getToken()) || "an".equals(tokens[n - 1].getToken())) { for (int i = n - 2; i > 0 && !isPunctuation(tokens[i].getToken()); i--) { if ("von".equals(tokens[i].getToken()) || "vom".equals(tokens[i].getToken())) { return true; } } } if ("her".equals(tokens[n - 1].getToken())) { for (int i = n - 2; i > 0 && !isPunctuation(tokens[i].getToken()); i--) { if ("vor".equals(tokens[i].getToken())) { return true; } } } return false; }
From source file:org.languagetool.tagging.uk.UkrainianTagger.java
@Override protected List<AnalyzedToken> getAnalyzedTokens(String word) { List<AnalyzedToken> tokens = super.getAnalyzedTokens(word); if (tokens.get(0).hasNoTag()) { String origWord = word;/*ww w.j av a2 s . c om*/ if (word.endsWith("") || word.endsWith("")) { word = origWord.substring(0, word.length() - 1); List<AnalyzedToken> newTokens = getAdjustedAnalyzedTokens(origWord, word, Pattern.compile("noun:inanim.*"), null, null); return newTokens.size() > 0 ? newTokens : tokens; } if (word.indexOf('\u2013') > 0 && ALT_DASHES_IN_WORD.matcher(word).find()) { word = origWord.replace('\u2013', '-'); List<AnalyzedToken> newTokens = getAdjustedAnalyzedTokens(origWord, word, null, null, null); if (newTokens.size() > 0) { tokens = newTokens; } } if (word.length() > 7 && word.startsWith("")) { String addPosTag = ""; Matcher matcher = Pattern.compile("(['-]?)(.*)").matcher(word); matcher.matches(); String prefix = matcher.group(1); String adjustedWord = matcher.group(2); List<AnalyzedToken> newTokens = getAdjustedAnalyzedTokens(origWord, adjustedWord, NAPIV_ALLOWED_TAGS_REGEX, null, null); if (newTokens.size() > 0) { if (!addPosTag.contains(":bad:")) { if (word.charAt(5) == '-' && !adjustedWord.matches("[?-?].*")) { addPosTag += ":bad"; } else if (word.charAt(5) != '\'' && adjustedWord.matches("[?].*")) { addPosTag += ":bad"; } } for (int i = 0; i < newTokens.size(); i++) { AnalyzedToken analyzedToken = newTokens.get(i); String lemma = analyzedToken.getLemma(); String posTag = analyzedToken.getPOSTag(); posTag = NAPIV_REMOVE_TAGS_REGEX.matcher(posTag).replaceAll(""); posTag = PosTagHelper.addIfNotContains(posTag, addPosTag); AnalyzedToken newToken = new AnalyzedToken(origWord, posTag, prefix + lemma); newTokens.set(i, newToken); } tokens = newTokens; } } // try instead of else if (word.contains("")) { tokens = convertTokens(tokens, word, "", "", ":alt"); } else if (word.contains("?")) { tokens = convertTokens(tokens, word, "?", "", ":alt"); } else if (word.endsWith("")) { tokens = convertTokens(tokens, word, "", "", ":alt"); } } // try ??? as and as if (word.length() > 2 && StringUtils.isAllUpperCase(word)) { String newWord = StringUtils.capitalize(StringUtils.lowerCase(word)); List<AnalyzedToken> newTokens = getAdjustedAnalyzedTokens(word, newWord, Pattern.compile("noun.*?:prop.*"), null, null); if (newTokens.size() > 0) { if (tokens.get(0).hasNoTag()) { //TODO: add special tags if necessary tokens = newTokens; } else { tokens.addAll(newTokens); } } } // -? as adj from -? if (word.indexOf('-') > 1 && !word.endsWith("-")) { String[] parts = word.split("-"); if (isAllCapitalized(parts)) { String lowerCasedWord = Stream.of(parts).map(String::toLowerCase).collect(Collectors.joining("-")); List<TaggedWord> wdList = wordTagger.tag(lowerCasedWord); if (PosTagHelper.hasPosTagPart2(wdList, "adj")) { List<AnalyzedToken> analyzedTokens = asAnalyzedTokenListForTaggedWordsInternal(word, wdList); analyzedTokens = PosTagHelper.filter(analyzedTokens, Pattern.compile("adj.*")); if (tokens.get(0).hasNoTag()) { tokens = analyzedTokens; } else { // compound tagging has already been performed and may have added tokens for (AnalyzedToken token : analyzedTokens) { if (!tokens.contains(token)) { tokens.add(token); } } } } } } return tokens; }
From source file:org.ligoj.app.http.security.RestAuthenticationProvider.java
@Override public Authentication authenticate(final Authentication authentication) { final String userpassword = StringUtils.defaultString(authentication.getCredentials().toString(), ""); final String userName = StringUtils.lowerCase(authentication.getPrincipal().toString()); // First get the cookie final HttpClientBuilder clientBuilder = HttpClientBuilder.create(); clientBuilder.setDefaultRequestConfig(RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD).build()); final HttpPost httpPost = new HttpPost(getSsoPostUrl()); // Do the POST try (CloseableHttpClient httpClient = clientBuilder.build()) { final String content = String.format(getSsoPostContent(), userName, userpassword); httpPost.setEntity(new StringEntity(content, StandardCharsets.UTF_8)); httpPost.setHeader("Content-Type", "application/json"); final HttpResponse httpResponse = httpClient.execute(httpPost); if (HttpStatus.SC_NO_CONTENT == httpResponse.getStatusLine().getStatusCode()) { // Succeed authentication, save the cookies data inside the authentication return newAuthentication(userName, userpassword, authentication, httpResponse); }/*from ww w . ja v a 2 s. c om*/ log.info("Failed authentication of {}[{}] : {}", userName, userpassword.length(), httpResponse.getStatusLine().getStatusCode()); httpResponse.getEntity().getContent().close(); } catch (final IOException e) { log.warn("Remote SSO server is not available", e); } throw new BadCredentialsException("Invalid user or password"); }
From source file:org.ligoj.app.http.security.TrustedAuthenticationProvider.java
@Override public Authentication authenticate(final Authentication authentication) { final String userName = StringUtils.lowerCase(authentication.getPrincipal().toString()); return new UsernamePasswordAuthenticationToken(userName, "N/A", authentication.getAuthorities()); }
From source file:org.lockss.util.NumberUtil.java
/** * Construct a sequence of Roman numerals. If both start and end are lower * case, the resulting sequence is lower case. * @param start a String representing a Roman numeral * @param end a String representing a Roman numeral * @param delta the magnitude of the increment or decrement, expressed as a positive integer * @return//from w ww .j av a 2 s . co m * @throws NumberFormatException if the start or end argument cannot be parsed as a Roman numeral */ public static List<String> constructRomanSequence(String start, String end, int delta) throws NumberFormatException { List<String> seq = new ArrayList<String>(); // Try and maintain the case - if it is mixed we use the default upper // case as we cannot decide what is appropriate boolean lower = StringUtils.isAllLowerCase(start) && StringUtils.isAllLowerCase(end); int s = parseRomanNumber(start); int e = parseRomanNumber(end); // Construct an int sequence int[] intSeq = constructSequence(s, e, delta); // Convert the numbers back to appropriately-cased Roman, and add to result list for (int i : intSeq) { String rn = toRomanNumber(i); seq.add(lower ? StringUtils.lowerCase(rn) : rn); } return seq; }
From source file:org.mitre.mpf.wfm.util.IoUtils.java
/** * Gets the MediaType associated with the given MIME type. Throws an exception if the MIME type does not map to a * MediaType. Never returns null.//from w ww . jav a 2 s. co m * @param mimeType A String MIME type (generally from {@link #getMimeType(java.net.URL)}. Must not be null. * @return A value from {@link org.mitre.mpf.wfm.enums.MediaType}. Never returns null * @throws WfmProcessingException */ public MediaType getMediaTypeFromMimeType(String mimeType) throws WfmProcessingException { Validate.notNull(mimeType, "The mimeType parameter must not be null."); String type = StringUtils.lowerCase(mimeType); if (type.startsWith("image")) { return MediaType.IMAGE; } else if (type.startsWith("video")) { return MediaType.VIDEO; } else if (type.startsWith("audio")) { return MediaType.AUDIO; } else { log.warn(String.format("The MIME type '%s' does not map to a MediaType.", mimeType)); return MediaType.UNSUPPORTED; } }