List of usage examples for java.lang Character isUpperCase
public static boolean isUpperCase(int codePoint)
From source file:de.homelab.madgaksha.lotsofbs.util.LocaleRootWordUtils.java
/** * <p>/* w w w . j a v a 2s .co m*/ * Swaps the case of a String using a word based algorithm. * </p> * * <ul> * <li>Upper case character converts to Lower case</li> * <li>Title case character converts to Lower case</li> * <li>Lower case character after Whitespace or at start converts to Title * case</li> * <li>Other Lower case character converts to Upper case</li> * </ul> * * <p> * Whitespace is defined by {@link Character#isWhitespace(char)}. A * <code>null</code> input String returns <code>null</code>. * </p> * * <pre> * StringUtils.swapCase(null) = null * StringUtils.swapCase("") = "" * StringUtils.swapCase("The dog has a BONE") = "tHE DOG HAS A bone" * </pre> * * @param str * the String to swap case, may be null * @return the changed String, <code>null</code> if null String input */ public static String swapCase(final String str) { if (StringUtils.isEmpty(str)) { return str; } final char[] buffer = str.toCharArray(); boolean whitespace = true; for (int i = 0; i < buffer.length; i++) { final char ch = buffer[i]; if (Character.isUpperCase(ch)) { buffer[i] = Character.toLowerCase(ch); whitespace = false; } else if (Character.isTitleCase(ch)) { buffer[i] = Character.toLowerCase(ch); whitespace = false; } else if (Character.isLowerCase(ch)) { if (whitespace) { buffer[i] = Character.toTitleCase(ch); whitespace = false; } else { buffer[i] = Character.toUpperCase(ch); } } else { whitespace = Character.isWhitespace(ch); } } return new String(buffer); }
From source file:org.languagetool.rules.de.VerbAgreementRule.java
/** * @return true if the verb @param token (if it is a verb) matches @param person and @param number, and matches no other person/number *///from ww w. j a va2 s .c o m private boolean hasUnambiguouslyPersonAndNumber(AnalyzedTokenReadings tokenReadings, String person, String number) { if (tokenReadings.getToken().length() == 0 || (Character.isUpperCase(tokenReadings.getToken().charAt(0)) && tokenReadings.getStartPos() != 0) || !tokenReadings.hasPosTagStartingWith("VER")) { return false; } for (AnalyzedToken analyzedToken : tokenReadings) { String postag = analyzedToken.getPOSTag(); if (postag == null || postag.endsWith("_END")) { // ignore SENT_END and PARA_END continue; } if (!postag.contains(":" + person + ":" + number)) { return false; } } return true; }
From source file:org.metaservice.core.OntologyToJavaConverter.java
/** * for conflict resolution it must be called from generate * @param uri uri to encode// w w w .ja va 2 s .co m * @param conflictString String to append when there is a nameconflict * @return Upper case, underscore separated java identifier of localname of uri */ String toJavaName(URI uri, String conflictString) { String s = uri.getLocalName(); boolean upper = false; StringBuilder builder = new StringBuilder(); for (char c : s.toCharArray()) { if (Character.isUpperCase(c)) { if (upper) { c = Character.toLowerCase(c); } upper = true; } else { upper = false; } builder.append(c); } s = caseFormat.to(CaseFormat.UPPER_UNDERSCORE, builder.toString()); s = s.replaceAll("[^A-Z0-9]", "_"); while (nameMap.values().contains(s)) { s = s + conflictString; } nameMap.put(uri, s); return s; }
From source file:org.apache.wiki.util.TextUtil.java
private static int getCharKind(int c) { if (c == -1) { return EOI; }/*from ww w . j a va 2 s .c o m*/ char ch = (char) c; if (Character.isLowerCase(ch)) { return LOWER; } else if (Character.isUpperCase(ch)) { return UPPER; } else if (Character.isDigit(ch)) { return DIGIT; } else { return OTHER; } }
From source file:org.executequery.gui.editor.autocomplete.QueryEditorAutoCompletePopupProvider.java
private boolean isAllLowerCase(String text) { for (char character : text.toCharArray()) { if (Character.isUpperCase(character)) { return false; }// w ww .ja v a 2s . c om } return true; }
From source file:org.languagetool.rules.de.VerbAgreementRule.java
/** * @return true if @param token is a finite verb, and it is no participle, pronoun or number *//*from ww w. ja v a 2s . c om*/ private boolean isFiniteVerb(AnalyzedTokenReadings token) { if (token.getToken().length() == 0 || (Character.isUpperCase(token.getToken().charAt(0)) && token.getStartPos() != 0) || !token.hasPosTagStartingWith("VER") || token.hasAnyPartialPosTag("PA2", "PRO:", "ZAL") || "einst".equals(token.getToken())) { return false; } return token.hasAnyPartialPosTag(":1:", ":2:", ":3:"); }
From source file:org.lockss.exporter.biblio.BibliographicUtil.java
/** * Check whether the strings consist of characters of the same case at every * point. If the strings differ in length, false is returned. * @param s1//from w w w. j a va 2 s . co m * @param s2 * @return false if the strings are different lengths or vary in case at any character */ private static boolean areSameCasing(String s1, String s2) { if (s1.length() != s2.length()) return false; char c1, c2; char[] s1arr = s1.toCharArray(); char[] s2arr = s2.toCharArray(); for (int i = 0; i < s1arr.length; i++) { if (Character.isUpperCase(s1arr[i]) != Character.isUpperCase(s2arr[i])) return false; } return true; }
From source file:org.romaframework.core.schema.reflection.SchemaClassReflection.java
private static boolean checkIfFirstCharAfterPrefixIsUpperCase(String methodName, String prefix) { return methodName.length() > prefix.length() ? Character.isUpperCase(methodName.charAt(prefix.length())) : false;//from w w w . j a v a2 s . c om }
From source file:org.lockss.exporter.biblio.BibliographicUtil.java
/** * * @param s// www .j ava 2s . c o m * @return */ private static boolean containsUpperCaseChars(String s) { for (char c : s.toCharArray()) if (Character.isUpperCase(c)) return true; return false; }
From source file:org.candlepin.swagger.CandlepinSwaggerModelConverter.java
private String getPropName(BeanPropertyDefinition propDef, String propName) { // hack to avoid clobbering properties with get/is names // it's ugly but gets around // https://github.com/swagger-api/swagger-core/issues/415 if (propDef.getPrimaryMember() != null) { java.lang.reflect.Member member = propDef.getPrimaryMember().getMember(); if (member != null) { String altName = member.getName(); if (altName != null) { final int length = altName.length(); for (String prefix : Arrays.asList("get", "is")) { final int offset = prefix.length(); if (altName.startsWith(prefix) && length > offset && !Character.isUpperCase(altName.charAt(offset))) { propName = altName; break; }/* w w w. j a va 2 s. co m*/ } } } } return propName; }