List of usage examples for java.lang Character isUpperCase
public static boolean isUpperCase(int codePoint)
From source file:org.jannocessor.model.bean.NameBean.java
private void fixCamelCaseStart(List<String> parts, String deletedStart) { String start = parts.get(0);/* w w w. ja va 2 s .c o m*/ if (Character.isUpperCase(deletedStart.charAt(0))) { start = start.substring(0, 1).toUpperCase() + start.substring(1); } else { start = start.toLowerCase(); } parts.set(0, start); }
From source file:org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.EmfCodeGenUtil.java
/** * This method breaks sourceName into words delimited by separator and/or mixed-case naming. *//* w ww . j a v a2s .c o m*/ public static List<String> parseName(String sourceName, char separator) { List<String> result = new ArrayList<String>(); if (sourceName != null) { StringBuilder currentWord = new StringBuilder(); boolean lastIsLower = false; for (int index = 0, length = sourceName.length(); index < length; ++index) { char curChar = sourceName.charAt(index); if (Character.isUpperCase(curChar) || !lastIsLower && Character.isDigit(curChar) || curChar == separator) { if (lastIsLower && currentWord.length() > 1 || curChar == separator && currentWord.length() > 0) { result.add(currentWord.toString()); currentWord = new StringBuilder(); } lastIsLower = false; } else { if (!lastIsLower) { int currentWordLength = currentWord.length(); if (currentWordLength > 1) { char lastChar = currentWord.charAt(--currentWordLength); currentWord.setLength(currentWordLength); result.add(currentWord.toString()); currentWord = new StringBuilder(); currentWord.append(lastChar); } } lastIsLower = true; } if (curChar != separator) { currentWord.append(curChar); } } result.add(currentWord.toString()); } return result; }
From source file:ar.com.zauber.commons.spring.servlet.mvc.support.ZauberBeanNameBasedClassNameHandlerMapping.java
/** * <ul>//from ww w. ja v a 2 s . com * <li>ChangePassword -> password/change</li> * <li>changePassword -> password/change</li> * <li>login -> login</li> * </ul> * */ protected final String getCompoundPath(final String s) { final Stack<String> stack = new Stack<String>(); final int n = s.length(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { final char c = s.charAt(i); if (Character.isUpperCase(c)) { if (sb.length() > 0) { stack.push(sb.toString()); sb = new StringBuilder(); } sb.append(Character.toLowerCase(c)); } else { sb.append(c); } } if (sb.length() > 0) { stack.push(sb.toString()); sb = new StringBuilder(); } while (!stack.isEmpty()) { sb.append(stack.pop()); sb.append('/'); } return sb.toString(); }
From source file:com.maddyhome.idea.vim.helper.StringHelper.java
public static boolean containsUpperCase(@NotNull String text) { for (int i = 0; i < text.length(); i++) { if (Character.isUpperCase(text.charAt(i)) && (i == 0 || text.charAt(i - 1) == '\\')) { return true; }//from w w w . j av a 2s. c o m } return false; }
From source file:com.portmods.handlers.crackers.dictionary.Wordlist.java
@Override public void run() { try {/*from w w w. ja v a2s . c o m*/ System.out.println("Loading Dictionary"); InputStream fileStream = null; if (config.getUseCustomDictionary()) { try { fileStream = new FileInputStream(config.getCustomDictionary()); } catch (Exception e) { JOptionPane.showMessageDialog(null, e, "Error with Dictonary File.", JOptionPane.ERROR_MESSAGE); System.exit(1); } } else { fileStream = Main.class.getResourceAsStream("/com/portmods/files/words.txt"); } BufferedReader reader = new BufferedReader(new InputStreamReader(fileStream, "UTF-8")); /* declaring storage list */ wordlist = new ArrayList<String>(); String text = ""; String line = reader.readLine(); while (line != null) //wait for ever { text = line; line = reader.readLine(); if (text.length() < 9 && text.length() > 2) { wordlist.add(text); } } } catch (UnsupportedEncodingException e) { System.out.println("Error Loading Dictionary"); } catch (IOException e) { System.out.println("Error Loading Dictionary"); } System.out.println("Finished Loading Dictionary"); System.out.println("Rule 1 : Do nothing to word"); for (String s : wordlist) { String hash = UnixCrypt.crypt(s, "aa"); for (User u : pw.getUsers()) { if (u.getHash().equals(hash)) { System.out.println("Found password " + s + " for user " + u.getUserName()); fp.addPassword(u.getUserName(), s); } } } System.out.println("Rule 2 : Toggle case of every character"); /* Chaning word characters one at time lowerecase to Uppercase and vice Veser. */ for (String s : wordlist) { for (int i = 0; i < s.length(); i++) { char C = s.charAt(i); //take character from the word StringBuilder sbuilder = new StringBuilder(s); //word we want to inject the character into if (Character.isUpperCase(C)) { sbuilder.setCharAt(i, Character.toLowerCase(C)); //changing the character to lowercase } else if (Character.isLowerCase(C)) { sbuilder.setCharAt(i, Character.toUpperCase(C)); // change to uppercase } String hash = UnixCrypt.crypt(sbuilder.toString(), "aa"); for (User u : pw.getUsers()) { if (u.getHash().equals(hash)) { System.out .println("Found password " + sbuilder.toString() + " for user " + u.getUserName()); fp.addPassword(u.getUserName(), sbuilder.toString()); } } } } System.out.println("Rule 3 : adding random numbers and leters into the word"); /* generating number and adding to the words*/ for (String s : wordlist) { for (int i = 0; i < 10; i++) { StringBuilder sb = new StringBuilder(s); sb.append(i); //add an integer to each word. String out = sb.toString(); if (out.length() <= 8) { String hash = UnixCrypt.crypt(out, "aa"); for (User u : pw.getUsers()) { if (u.getHash().equals(hash)) { System.out.println("Found password " + sb.toString() + " for user " + u.getUserName()); fp.addPassword(u.getUserName(), sb.toString()); } } } } } System.out.println("Rule 4: Toggle one charater at a time and replace a number"); /* trying to toggle one charater at a time and replace a number*/ for (String s : wordlist) { for (int j = 0; j < s.length(); j++) { for (int i = 0; i < 10; i++) { char C = s.charAt(j); //take character from the word StringBuilder sbuilder = new StringBuilder(s); //word we want to inject the character into if (Character.isAlphabetic(C)) { sbuilder.deleteCharAt(j); //remove character sbuilder.insert(j, i); // add digit String hash = UnixCrypt.crypt(sbuilder.toString(), "aa"); for (User u : pw.getUsers()) { if (u.getHash().equals(hash)) { System.out.println( "Found password " + sbuilder.toString() + " for user " + u.getUserName()); fp.addPassword(u.getUserName(), sbuilder.toString()); } } } } for (int x = 65; x < 123; x++) { char C1 = (char) x; char C = s.charAt(j); //take character from the word StringBuilder sbuilder = new StringBuilder(s); //word we want to inject the character into if (Character.isDigit(C)) { sbuilder.setCharAt(j, C1); String hash = UnixCrypt.crypt(sbuilder.toString(), "aa"); for (User u : pw.getUsers()) { if (u.getHash().equals(hash)) { System.out.println( "Found password " + sbuilder.toString() + " for user " + u.getUserName()); fp.addPassword(u.getUserName(), sbuilder.toString()); } } } } } } System.out.println("Rule 5 : Adding random letters and numbers to the end"); /* adding ascii values to a text string */ for (String s : wordlist) { int x = 1; StringBuilder sb = new StringBuilder(s); for (int i = 33; i < 123; i++) { char L1 = (char) i; String out = sb.toString(); String out1 = out + L1; if (out1.length() > 8) { break; } else { String hash = UnixCrypt.crypt(out1, "aa"); for (User u : pw.getUsers()) { if (u.getHash().equals(hash)) { System.out.println("Found password " + out1 + " for user " + u.getUserName()); fp.addPassword(u.getUserName(), out1); } } } for (int j = 33; j < 123; j++) { char L2 = (char) j; String out2 = out + L1 + L2; if (out2.length() > 8) { break; } else { String hash = UnixCrypt.crypt(out2, "aa"); for (User u : pw.getUsers()) { if (u.getHash().equals(hash)) { System.out.println("Found password " + out2 + " for user " + u.getUserName()); fp.addPassword(u.getUserName(), out2); } } } for (int k = 33; k < 123; k++) { char L3 = (char) k; String out3 = out + L1 + L2 + L3; if (out3.length() > 8) { break; } else { String hash = UnixCrypt.crypt(out3, "aa"); for (User u : pw.getUsers()) { if (u.getHash().equals(hash)) { System.out.println("Found password " + out3 + " for user " + u.getUserName()); fp.addPassword(u.getUserName(), out3); } } } for (int l = 33; l < 123; l++) { char L4 = (char) l; String out4 = out + L1 + L2 + L3 + L4; if (out4.length() > 8) { break; } else { String hash = UnixCrypt.crypt(out4, "aa"); for (User u : pw.getUsers()) { if (u.getHash().equals(hash)) { System.out .println("Found password " + out4 + " for user " + u.getUserName()); fp.addPassword(u.getUserName(), out4); } } } } } } if (out.length() < 8) { } else { System.out.println(out); break; } } } config.setDicModeFin(true); }
From source file:com.emc.ecs.sync.config.ConfigUtil.java
public static String labelize(String name) { StringBuilder label = new StringBuilder(); for (char c : name.toCharArray()) { if (Character.isUpperCase(c) && label.length() > 0) label.append(' '); label.append(label.length() == 0 ? Character.toUpperCase(c) : c); }/* w w w. j a va 2 s .com*/ return label.toString(); }
From source file:org.azyva.dragom.util.Util.java
/** * Converts a PascalCase (or camelCase) string to lowercase with dashes. * * @param stringPascalCase See description. * @return See description.//from w ww. j a va 2 s . c om */ public static String convertPascalCaseToLowercaseWithDashes(String stringPascalCase) { StringBuilder stringBuilder; int charCount; stringBuilder = new StringBuilder(); charCount = stringPascalCase.length(); for (int i = 0; i < charCount; i++) { char character = stringPascalCase.charAt(i); if (Character.isUpperCase(character)) { if (i != 0) { stringBuilder.append('-'); } stringBuilder.append(Character.toLowerCase(character)); } else { stringBuilder.append(character); } } return stringBuilder.toString(); }
From source file:graphene.util.StringUtils.java
/** * If the input contains a fraction of uppercase characters above the * threshold, we will apply title case to all the words in the string. * /*from www .j a v a 2 s.co m*/ * @param input * @param threshold * @return */ public static String cleanUpAllCaps(final String input, final double threshold) { int numUpper = 0; for (int i = 0; i < input.length(); i++) { if (Character.isUpperCase(input.charAt(i))) { numUpper++; } } final float fractionUpper = (float) numUpper / (float) input.length(); if (fractionUpper >= threshold) { return WordUtils.capitalizeFully(input); } else { return input; } }
From source file:eu.crisis_economics.configuration.TypeDeclarationExpression.java
public static List<String> isExpressionOfType(String rawExpression, FromFileConfigurationContext context) { String expression = rawExpression.trim(); if (expression.length() == 0) return null; boolean beginsWithUppercase = Character.isUpperCase(expression.charAt(0)); if (!beginsWithUppercase) return null; int endOfTypename = -1; for (int i = 0; i < expression.length(); ++i) { Character charNow = expression.charAt(i); if (Character.isLetter(charNow) || charNow == '_') continue; endOfTypename = i;//ww w. j av a 2s. com break; } if (endOfTypename == -1) return Arrays.asList(expression); // no indexing if (expression.charAt(endOfTypename) == '[') { if (expression.charAt(expression.length() - 1) != ']') return null; String typeDeclExpression = expression.substring(0, endOfTypename); String indexExpression = expression.substring(endOfTypename + 1, expression.length() - 1); if (IntegerPrimitiveExpression.isExpressionOfType(indexExpression, context) == null) return null; // with indexing return Arrays.asList(typeDeclExpression, indexExpression); } else return null; }
From source file:com.gargoylesoftware.htmlunit.general.HostExtractor.java
private static void ensure(final File file, final Set<String> set) throws IOException { final Set<String> unusedNames = new HashSet<>(set); final List<String> lines = FileUtils.readLines(file); for (final String line : lines) { for (final Iterator<String> it = unusedNames.iterator(); it.hasNext();) { if (line.contains("(\"" + it.next() + "\")")) { it.remove();//from w w w . j av a 2s . c om } } } unusedNames.remove("this"); unusedNames.remove("Boolean"); unusedNames.remove("null"); if (!unusedNames.isEmpty()) { for (final String name : unusedNames) { if (name.contains(" ")) { continue; } System.out.println(""); System.out.println(" /**"); System.out.println(" * @throws Exception if the test fails"); System.out.println(" */"); System.out.println(" @Test"); System.out.println(" @Alerts(\"exception\")"); String methodName = name; for (final String prefix : PREFIXES_) { if (methodName.startsWith(prefix)) { methodName = prefix.toLowerCase(Locale.ROOT) + methodName.substring(prefix.length()); break; } } if (Character.isUpperCase(methodName.charAt(0))) { methodName = Character.toLowerCase(methodName.charAt(0)) + methodName.substring(1); } methodName = methodName.replace(".", "_"); System.out.println(" public void " + methodName + "() throws Exception {"); System.out.println(" test(\"" + name + "\");"); System.out.println(" }"); } } for (final String name : unusedNames) { if (name.contains(" ")) { System.out.println("Ignoring: " + name); } } }