List of usage examples for java.lang Character toLowerCase
public static int toLowerCase(int codePoint)
From source file:com.cloud.utils.db.SqlGenerator.java
protected boolean checkMethods(Class<?> clazz, Map<String, Attribute> attrs) { Method[] methods = clazz.getMethods(); for (Method method : methods) { String name = method.getName(); if (name.startsWith("get")) { String fieldName = Character.toLowerCase(name.charAt(3)) + name.substring(4); assert !attrs.containsKey(fieldName) : "Mismatch in " + clazz.getSimpleName() + " for " + name; } else if (name.startsWith("is")) { String fieldName = Character.toLowerCase(name.charAt(2)) + name.substring(3); assert !attrs.containsKey(fieldName) : "Mismatch in " + clazz.getSimpleName() + " for " + name; } else if (name.startsWith("set")) { String fieldName = Character.toLowerCase(name.charAt(3)) + name.substring(4); assert !attrs.containsKey(fieldName) : "Mismatch in " + clazz.getSimpleName() + " for " + name; }// w w w . ja va 2 s. c o m } return true; }
From source file:annis.dao.autogenqueries.AutoSimpleRegexQuery.java
@Override public void analyzingQuery(SaltProject saltProject) { List<String> tokens = new ArrayList<>(); for (SCorpusGraph g : saltProject.getSCorpusGraphs()) { if (g != null) { for (SDocument doc : g.getSDocuments()) { SDocumentGraph docGraph = doc.getSDocumentGraph(); EList<SNode> sNodes = docGraph.getSNodes(); if (sNodes != null) { for (SNode n : sNodes) { if (n instanceof SToken) { tokens.add(CommonHelper.getSpannedText((SToken) n)); }//w ww. j ava 2 s . com } } } } } // try to find a word with which is contained twice with Capitalize letter. text = null; for (int i = 0; i < tokens.size(); i++) { for (int j = i + 1; j < tokens.size(); j++) { if (tokens.get(i).equalsIgnoreCase(tokens.get(j))) { if (tokens.get(i).length() > 1 && ((Character.isLowerCase(tokens.get(i).charAt(0)) && Character.isUpperCase(tokens.get(j).charAt(0))) || (Character.isLowerCase(tokens.get(j).charAt(0)) && Character.isUpperCase(tokens.get(i).charAt(0))))) { text = tokens.get(i); break; } } } } if (text != null) { Character upperLetter = Character.toUpperCase(text.charAt(0)); Character lowerLetter = Character.toLowerCase(text.charAt(0)); String rest = StringUtils.substring(text, -(text.length() - 1)); finalAQL = "/[" + upperLetter + lowerLetter + "]" + rest + "/"; } else { // select one random token from the result int tries = 10; int r = new Random().nextInt(tokens.size() - 1); text = tokens.get(r); while ("".equals(text) && tries > 0) { r = new Random().nextInt(tokens.size() - 1); text = tokens.get(r); tries--; } if (!"".equals(text) && text.length() > 1) { Character upperLetter = Character.toUpperCase(text.charAt(0)); Character lowerLetter = Character.toLowerCase(text.charAt(0)); String rest = StringUtils.substring(text, -(text.length() - 1)); finalAQL = "/[" + upperLetter + lowerLetter + "]" + rest + "/"; } else { finalAQL = ""; } } }
From source file:org.apache.sshd.SshServerDevelopment.java
protected static final void testSftpAccess(BufferedReader in, PrintStream out, SshServer sshd) throws Exception { for (;;) {/*from w ww.ja v a 2 s. c o m*/ String ans = getval(out, in, "root folder [u]ser/c(w)d/(r)oot/XXX path/(q)uit"); if (isQuit(ans)) { break; } char op = StringUtils.isEmpty(ans) ? '\0' : Character.toLowerCase(ans.charAt(0)); String path = null; switch (op) { case '\0': case 'u': path = SystemUtils.USER_HOME; break; case 'w': path = SystemUtils.USER_DIR; break; case 'r': { File[] roots = File.listRoots(); if (ArrayUtils.isEmpty(roots)) { System.err.println("No roots listed"); break; } if (roots.length == 1) { path = roots[0].getAbsolutePath(); break; } File selected = inputListChoice(out, in, "Roots", Arrays.asList(roots), null); if (selected != null) { path = selected.getAbsolutePath(); } } break; default: // assume a path path = ans; } if (StringUtils.isEmpty(path)) { continue; } final File rootDir = new File(path); NativeFileSystemFactory factory = new ExtendedNativeFileSystemFactory() { @Override protected File getSessionRootDir(Session session) { return rootDir; } }; if (!rootDir.exists()) { ans = getval(out, in, "create " + rootDir + " y/[n]/q"); if (isQuit(ans)) { continue; } if (!StringUtils.isEmpty(ans)) { factory.setCreateHome('y' == Character.toLowerCase(ans.charAt(0))); } } sshd.setFileSystemFactory(factory); break; } sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystem.Factory())); sshd.setCommandFactory(new ScpCommandFactory()); sshd.setShellFactory(ECHO_SHELL); waitForExit(in, out, sshd); }
From source file:org.geoserver.opensearch.eo.store.JDBCOpenSearchAccess.java
private FeatureType buildCollectionFeatureType(DataStore delegate) throws IOException { SimpleFeatureType flatSchema = delegate.getSchema(COLLECTION); TypeBuilder typeBuilder = new TypeBuilder(CommonFactoryFinder.getFeatureTypeFactory(null)); // map the source attributes for (AttributeDescriptor ad : flatSchema.getAttributeDescriptors()) { AttributeTypeBuilder ab = new AttributeTypeBuilder(); String name = ad.getLocalName(); String namespaceURI = this.namespaceURI; if (name.startsWith(EO_PREFIX)) { name = name.substring(EO_PREFIX.length()); char c[] = name.toCharArray(); c[0] = Character.toLowerCase(c[0]); name = new String(c); namespaceURI = EO_NAMESPACE; }/*ww w .j a v a 2 s. c o m*/ // get a more predictable name structure (will have to do something for oracle // like names too I guess) if (StringUtils.isAllUpperCase(name)) { name = name.toLowerCase(); } // map into output type ab.init(ad); ab.name(name).namespaceURI(namespaceURI).userData(SOURCE_ATTRIBUTE, ad.getLocalName()); AttributeDescriptor mappedDescriptor; if (ad instanceof GeometryDescriptor) { GeometryType at = ab.buildGeometryType(); ab.setCRS(((GeometryDescriptor) ad).getCoordinateReferenceSystem()); mappedDescriptor = ab.buildDescriptor(new NameImpl(namespaceURI, name), at); } else { AttributeType at = ab.buildType(); mappedDescriptor = ab.buildDescriptor(new NameImpl(namespaceURI, name), at); } typeBuilder.add(mappedDescriptor); } // adding the metadata property AttributeDescriptor metadataDescriptor = buildSimpleDescriptor(METADATA_PROPERTY_NAME, String.class); typeBuilder.add(metadataDescriptor); // map OGC links AttributeDescriptor linksDescriptor = buildFeatureListDescriptor(OGC_LINKS_PROPERTY_NAME, delegate.getSchema("collection_ogclink")); typeBuilder.add(linksDescriptor); typeBuilder.setName(COLLECTION); typeBuilder.setNamespaceURI(namespaceURI); return typeBuilder.feature(); }
From source file:org.apache.camel.itest.karaf.AbstractFeatureTest.java
public static String extractName(Class clazz) { String name = clazz.getName(); int id0 = name.indexOf("Camel") + "Camel".length(); int id1 = name.indexOf("Test"); StringBuilder sb = new StringBuilder(); for (int i = id0; i < id1; i++) { char c = name.charAt(i); if (Character.isUpperCase(c) && sb.length() > 0) { sb.append("-"); }/*from ww w . j a v a 2 s . c o m*/ sb.append(Character.toLowerCase(c)); } return sb.toString(); }
From source file:com.dgtlrepublic.anitomyj.ParserHelper.java
/** Returns whether or not the {@code string} is a resolution. */ public static boolean isResolution(String string) { if (StringUtils.isEmpty(string)) return false; int minWidthSize = 3; int minHeightSize = 3; // *###x###*/* w ww . j a v a 2 s . c o m*/ if (string.length() >= minWidthSize + 1 + minHeightSize) { int pos = StringUtils.indexOfAny(string, "xX\u00D7"); if (pos != -1 && pos >= minWidthSize && pos <= string.length() - (minHeightSize + 1)) { for (int i = 0; i < string.length(); i++) { if (i != pos && !Character.isDigit(string.charAt(i))) return false; } return true; } // *###p } else if (string.length() >= minHeightSize + 1) { if (Character.toLowerCase(string.charAt(string.length() - 1)) == 'p') { for (int i = 0; i < string.length() - 1; i++) { if (!Character.isDigit(string.charAt(i))) return false; } return true; } } return false; }
From source file:com.portmods.handlers.crackers.dictionary.Wordlist.java
@Override public void run() { try {/*from www . j a v a 2 s. c om*/ 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.ultrapower.eoms.common.plugin.ecside.tag.form.ECSideFormTagUtil.java
public static int indexOfIgnoreCase(String src, String subS, int startIndex) { String sub = subS.toLowerCase(); int sublen = sub.length(); int total = src.length() - sublen + 1; for (int i = startIndex; i < total; i++) { int j = 0;/*ww w. j a va 2 s . c om*/ while (j < sublen) { char source = Character.toLowerCase(src.charAt(i + j)); if (sub.charAt(j) != source) { break; } j++; } if (j == sublen) { return i; } } return -1; }
From source file:ar.com.zauber.commons.spring.servlet.mvc.support.ZauberBeanNameBasedClassNameHandlerMapping.java
/** * <ul>/*from w w w . j a v a2 s .c o m*/ * <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.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();/*w ww .j a v a 2 s . com*/ } } } 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); } } }