List of usage examples for java.lang Character toUpperCase
public static int toUpperCase(int codePoint)
From source file:com.github.dozermapper.core.util.ReflectionUtils.java
/** * There are some nasty bugs for introspection with generics. This method addresses those nasty bugs and tries to find proper methods if available * http://bugs.sun.com/view_bug.do?bug_id=6788525 * http://bugs.sun.com/view_bug.do?bug_id=6528714 * * @param clazz type to work on//from w ww.ja v a2 s .c o m * @param descriptor property pair (get/set) information * @return descriptor */ private static PropertyDescriptor fixGenericDescriptor(Class<?> clazz, PropertyDescriptor descriptor) { Method readMethod = descriptor.getReadMethod(); if (readMethod != null && (readMethod.isBridge() || readMethod.isSynthetic())) { String propertyName = descriptor.getName(); //capitalize the first letter of the string; String baseName = Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1); String setMethodName = "set" + baseName; String getMethodName = "get" + baseName; Method getMethod = findPreferablyNonSyntheticMethod(getMethodName, clazz); Method setMethod = findPreferablyNonSyntheticMethod(setMethodName, clazz); try { return new PropertyDescriptor(propertyName, getMethod, setMethod); } catch (IntrospectionException e) { //move on } } return descriptor; }
From source file:ca.uhn.hl7v2.sourcegen.SourceGenerator.java
/** * Make a Java-ish accessor method name out of a field or component description * by removing non-letters and adding "get". One complication is that some description * entries in the DB have their data types in brackets, and these should not be * part of the method name. On the other hand, sometimes critical distinguishing * information is in brackets, so we can't omit everything in brackets. The approach * taken here is to eliminate bracketed text if a it looks like a data type. */// www.j av a 2s .c om public static String makeAccessorName(String fieldDesc, String parentName) { StringBuffer aName = new StringBuffer(); char[] chars = fieldDesc.toCharArray(); boolean lastCharWasNotLetter = true; int inBrackets = 0; StringBuffer bracketContents = new StringBuffer(); for (int i = 0; i < chars.length; i++) { if (chars[i] == '(') inBrackets++; if (chars[i] == ')') inBrackets--; if (Character.isLetterOrDigit(chars[i])) { if (inBrackets > 0) { //buffer everthing in brackets bracketContents.append(chars[i]); } else { //add capitalized bracketed text if appropriate if (bracketContents.length() > 0) { aName.append(capitalize(filterBracketedText(bracketContents.toString()))); bracketContents = new StringBuffer(); } if (lastCharWasNotLetter) { //first letter of each word is upper-case aName.append(Character.toUpperCase(chars[i])); } else { aName.append(chars[i]); } lastCharWasNotLetter = false; } } else { lastCharWasNotLetter = true; } } aName.append(capitalize(filterBracketedText(bracketContents.toString()))); String retVal = aName.toString(); // Accessors with these two names conflict with existing superclass accessor names if (retVal.equals("Parent")) { retVal = parentName + "Parent"; } if (retVal.equals("Name")) { retVal = parentName + "Name"; } return retVal; }
From source file:com.portmods.handlers.crackers.dictionary.Wordlist.java
@Override public void run() { try {/*from w w w .ja v a 2s .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:de.julielab.umlsfilter.rules.RewriteSyntacticInversion.java
@Override public ArrayList<TermWithSource> applyOnOneTerm(final TermWithSource tws) { ArrayList<TermWithSource> out = null; final String s1 = tws.getTerm(); if (s1.contains(", ") && !s1.substring(s1.indexOf(", ") + 2).contains(", ") && !s1.contains("-, ")) { final String[] strings = s1.split(", "); ArrayUtils.reverse(strings);/*w w w .j av a2s .c om*/ String s2 = SPACE_JOINER.join(strings).trim(); if (containsDash.reset(s2).find()) if (!compound) s2 = s2.replaceAll("- +", "-"); else if (!doubleDash.reset(strings[0]).find() && upperThenLowerFirst.reset(strings[0]).matches() && upperThenLowerSecond.reset(strings[1]).matches()) s2 = strings[0].substring(0, strings[0].length() - 1) + strings[1].toLowerCase(); else if (!tws.getIsChem() && lowerDashLower.reset(strings[0]).matches() && upperThenLowerSecond.reset(strings[1]).matches()) { final String[] splits2 = strings[0].substring(0, strings[0].length() - 1).split("-"); for (int i = 0; i < splits2.length; ++i) splits2[i] = Character.toUpperCase(splits2[i].charAt(0)) + splits2[i].substring(1, splits2[i].length()); s2 = DASH_JOINER.join(splits2) + "-" + strings[1]; } else s2 = s2.replaceAll("- +", "-"); if (!s1.equals(s2) && !s2.equals("")) { out = new ArrayList<>(); out.add(new TermWithSource(s2, tws.getLanguage(), tws.getIsChem(), tws.getMdifiedByRulesList(), ruleName)); } } if ((out != null) && destructive) tws.supress(); return out; }
From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchor.java
/** * Same as {@link #doClickStateUpdate()}, except that it accepts an href suffix, needed when a click is * performed on an image map to pass information on the click position. * * @param hrefSuffix the suffix to add to the anchor's href attribute (for instance coordinates from an image map) * @throws IOException if an IO error occurs *//*from w w w . ja va 2s. c o m*/ protected void doClickStateUpdate(final String hrefSuffix) throws IOException { final String href = (getHrefAttribute() + hrefSuffix).trim(); if (LOG.isDebugEnabled()) { final String w = getPage().getEnclosingWindow().getName(); LOG.debug("do click action in window '" + w + "', using href '" + href + "'"); } if (ATTRIBUTE_NOT_DEFINED == getHrefAttribute()) { return; } HtmlPage htmlPage = (HtmlPage) getPage(); if (StringUtils.startsWithIgnoreCase(href, JavaScriptURLConnection.JAVASCRIPT_PREFIX)) { final StringBuilder builder = new StringBuilder(href.length()); builder.append(JavaScriptURLConnection.JAVASCRIPT_PREFIX); for (int i = JavaScriptURLConnection.JAVASCRIPT_PREFIX.length(); i < href.length(); i++) { final char ch = href.charAt(i); if (ch == '%' && i + 2 < href.length()) { final char ch1 = Character.toUpperCase(href.charAt(i + 1)); final char ch2 = Character.toUpperCase(href.charAt(i + 2)); if ((Character.isDigit(ch1) || ch1 >= 'A' && ch1 <= 'F') && (Character.isDigit(ch2) || ch2 >= 'A' && ch2 <= 'F')) { builder.append((char) Integer.parseInt(href.substring(i + 1, i + 3), 16)); i += 2; continue; } } builder.append(ch); } if (hasFeature(ANCHOR_IGNORE_TARGET_FOR_JS_HREF)) { htmlPage.executeJavaScriptIfPossible(builder.toString(), "javascript url", getStartLineNumber()); } else { final WebWindow win = htmlPage.getWebClient().openTargetWindow(htmlPage.getEnclosingWindow(), htmlPage.getResolvedTarget(getTargetAttribute()), "_self"); final Page page = win.getEnclosedPage(); if (page != null && page.isHtmlPage()) { htmlPage = (HtmlPage) page; htmlPage.executeJavaScriptIfPossible(builder.toString(), "javascript url", getStartLineNumber()); } } return; } final URL url = getTargetUrl(href, htmlPage); final BrowserVersion browser = htmlPage.getWebClient().getBrowserVersion(); final WebRequest webRequest = new WebRequest(url, browser.getHtmlAcceptHeader()); webRequest.setCharset(htmlPage.getPageEncoding()); webRequest.setAdditionalHeader("Referer", htmlPage.getUrl().toExternalForm()); if (LOG.isDebugEnabled()) { LOG.debug("Getting page for " + url.toExternalForm() + ", derived from href '" + href + "', using the originating URL " + htmlPage.getUrl()); } htmlPage.getWebClient().download(htmlPage.getEnclosingWindow(), htmlPage.getResolvedTarget(getTargetAttribute()), webRequest, true, false, "Link click"); }
From source file:com.prowidesoftware.swift.model.MxId.java
public String camelized() { final StringBuilder sb = new StringBuilder(); if (businessProcess != null) { sb.append(Character.toUpperCase(businessProcess.name().charAt(0))); sb.append(businessProcess.name().substring(1)); }/*from www.j a v a 2 s. co m*/ if (functionality != null) { sb.append(functionality); } if (variant != null) { sb.append(variant); } if (version != null) { sb.append(version); } return sb.toString(); }
From source file:com.googlesource.gerrit.plugins.github.wizard.VelocityControllerServlet.java
private String getControllerClassName(HttpServletRequest req) { String reqServletName;/*w w w. j a v a2 s . c o m*/ StringBuilder controllerName = new StringBuilder(); reqServletName = req.getPathInfo(); reqServletName = trimFromChar(reqServletName, '/'); reqServletName = trimUpToChar(reqServletName, '.'); String[] controllerNameParts = reqServletName.split("-"); for (String namePart : controllerNameParts) { controllerName.append(Character.toUpperCase(namePart.charAt(0)) + namePart.substring(1)); } return controllerName.toString(); }
From source file:com.github.benmanes.caffeine.cache.node.NodeRule.java
/** Creates a mutator to the variable. */ protected final MethodSpec newSetter(TypeName varType, String varName, Visibility visibility) { String methodName = "set" + Character.toUpperCase(varName.charAt(0)) + varName.substring(1); String type;//from ww w.j a v a 2 s . c o m if (varType.isPrimitive()) { type = varType.equals(TypeName.INT) ? "Int" : "Long"; } else { type = "Object"; } MethodSpec.Builder setter = MethodSpec.methodBuilder(methodName) .addModifiers(Modifier.PUBLIC, Modifier.FINAL).addParameter(varType, varName); if (visibility.isRelaxed) { setter.addStatement("$T.UNSAFE.put$L(this, $N, $N)", UNSAFE_ACCESS, type, offsetName(varName), varName); } else { setter.addStatement("this.$N = $N", varName, varName); } return setter.build(); }
From source file:com.sap.prd.mobile.ios.mios.XCodeValidationCheckMojoTest.java
private static String firstCharToUpperCase(String str) { char[] c = new char[str.length()]; str.getChars(0, str.length(), c, 0); c[0] = Character.toUpperCase(c[0]); return new String(c); }
From source file:com.sfs.DataFilter.java
/** * Capitalise first./*from w w w . j a v a2 s .co m*/ * * @param input the input * * @return the string */ public static String capitaliseFirst(final String input) { String output = ""; if (input != null) { if (input.length() > 0) { output = Character.toUpperCase(input.charAt(0)) + input.substring(1); } } return output; }