List of usage examples for java.lang Character isLowerCase
public static boolean isLowerCase(int codePoint)
From source file:org.eclipse.ecr.core.storage.sql.jdbc.JDBCBackend.java
@Override public void initialize(RepositoryImpl repository) throws StorageException { this.repository = repository; RepositoryDescriptor repositoryDescriptor = repository.getRepositoryDescriptor(); // instantiate the datasource String className = repositoryDescriptor.xaDataSourceName; Class<?> klass;/*from ww w .j a va2s .c om*/ try { klass = Class.forName(className); } catch (ClassNotFoundException e) { throw new StorageException("Unknown class: " + className, e); } Object instance; try { instance = klass.newInstance(); } catch (Exception e) { throw new StorageException("Cannot instantiate class: " + className, e); } if (!(instance instanceof XADataSource)) { throw new StorageException("Not a XADataSource: " + className); } xadatasource = (XADataSource) instance; // set JavaBean properties on the datasource for (Entry<String, String> entry : repositoryDescriptor.properties.entrySet()) { String name = entry.getKey(); Object value = Framework.expandVars(entry.getValue()); if (name.contains("/")) { // old syntax where non-String types were explicited name = name.substring(0, name.indexOf('/')); } // transform to proper JavaBean convention if (Character.isLowerCase(name.charAt(1))) { name = Character.toLowerCase(name.charAt(0)) + name.substring(1); } try { BeanUtils.setProperty(xadatasource, name, value); } catch (Exception e) { log.error(String.format("Cannot set %s = %s", name, value)); } } }
From source file:org.hyperic.hq.product.pluginxml.PluginParser.java
public void parse(InputStream in, PluginData data, EntityResolver resolver) throws PluginException { this.replacer = new TokenReplacer(); this.replacer.addFilters(PluginData.getGlobalProperties()); this.replacer.addFilters(System.getProperties()); data.parser = this; data.scratch = new HashMap(); ProductTag tag = new ProductTag(data); tag.collectMetrics = this.collectMetrics; tag.collectHelp = this.collectHelp; try {/*w w w. java2 s .com*/ XmlParser.parse(in, tag, resolver); } catch (XmlParseException e) { throw new PluginException(e); } //remove help text w/ lowercase keys //which should only be used for piecing together help, //which we are done with after parsing. String[] keys = new String[data.help.size()]; data.help.keySet().toArray(keys); for (int i = 0; i < keys.length; i++) { String key = keys[i]; //dont want to remove "iPlanet ..." if (Character.isLowerCase(key.charAt(0)) && Character.isLowerCase(key.charAt(1))) { data.help.remove(key); } } this.replacer = null; data.parser = null; //allow gc of this data.scratch.clear(); data.scratch = null; }
From source file:org.eclipse.xtend.typesystem.xsd.builder.OawXSDEcoreBuilder.java
protected boolean isUppercase(String str) { for (int i = 0; i < str.length(); i++) if (Character.isLowerCase(str.charAt(i))) return false; return true;// w ww . j a v a 2s. c om }
From source file:org.apdplat.superword.rule.TextAnalysis.java
/** * ?/*from w ww.j a v a 2 s . c om*/ * @param sentence * @param debug ??? * @return */ public static List<String> seg(String sentence, boolean debug) { List<String> data = new ArrayList<>(); //?? String[] words = sentence.trim().split("[^a-zA-Z]"); StringBuilder log = new StringBuilder(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("??:" + sentence); } for (String word : words) { if (StringUtils.isBlank(word)) { continue; } List<String> list = new ArrayList<String>(); //?6??? if (word.length() < 6 || StringUtils.isAllUpperCase(word)) { word = word.toLowerCase(); } //??? int last = 0; for (int i = 1; i < word.length(); i++) { if (Character.isUpperCase(word.charAt(i)) && Character.isLowerCase(word.charAt(i - 1))) { list.add(word.substring(last, i)); last = i; } } if (last < word.length()) { list.add(word.substring(last, word.length())); } list.stream().map(w -> w.toLowerCase()).forEach(w -> { if (w.length() < 2) { return; } w = irregularity(w); if (StringUtils.isNotBlank(w)) { data.add(w); if (LOGGER.isDebugEnabled()) { log.append(w).append(" "); } } }); } LOGGER.debug("?" + log); return data; }
From source file:org.apache.wiki.util.comparators.HumanComparator.java
public int compare(String str1, String str2) { // Some quick and easy checks if (StringUtils.equals(str1, str2)) { // they're identical, possibly both null return 0; } else if (str1 == null) { // str1 is null and str2 isn't so str1 is smaller return -1; } else if (str2 == null) { // str2 is null and str1 isn't so str1 is bigger return 1; }//w ww. ja va 2 s. c o m char[] s1 = str1.toCharArray(); char[] s2 = str2.toCharArray(); int len1 = s1.length; int len2 = s2.length; int idx = 0; // caseComparison used to defer a case sensitive comparison int caseComparison = 0; while (idx < len1 && idx < len2) { char c1 = s1[idx]; char c2 = s2[idx++]; // Convert to lower case char lc1 = Character.toLowerCase(c1); char lc2 = Character.toLowerCase(c2); // If case makes a difference, note the difference the first time // it's encountered if (caseComparison == 0 && c1 != c2 && lc1 == lc2) { if (Character.isLowerCase(c1)) caseComparison = 1; else if (Character.isLowerCase(c2)) caseComparison = -1; } // Do the rest of the tests in lower case c1 = lc1; c2 = lc2; // leading zeros are a special case if (c1 != c2 || c1 == '0') { // They might be different, now we can do a comparison CharType type1 = mapCharTypes(c1); CharType type2 = mapCharTypes(c2); // Do the character class check int result = compareCharTypes(type1, type2); if (result != 0) { // different character classes so that's sufficient return result; } // If they're not digits, use character to character comparison if (type1 != CharType.TYPE_DIGIT) { Character ch1 = Character.valueOf(c1); Character ch2 = Character.valueOf(c2); return ch1.compareTo(ch2); } // The only way to get here is both characters are digits assert (type1 == CharType.TYPE_DIGIT && type2 == CharType.TYPE_DIGIT); result = compareDigits(s1, s2, idx - 1); if (result != 0) { // Got a result so return it return result; } // No result yet, spin through the digits and continue trying while (idx < len1 && idx < len2 && Character.isDigit(s1[idx])) { idx++; } } } if (len1 == len2) { // identical so return any case dependency return caseComparison; } // Shorter String is less return len1 - len2; }
From source file:com.manydesigns.elements.util.Util.java
static boolean isAllUpperCase(String s) { for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (Character.isLetter(c) && Character.isLowerCase(c)) { return false; }/* ww w. j ava2 s .c om*/ } return true; }
From source file:com.consol.citrus.util.TestCaseCreator.java
/** * Create the test case.//from ww w. ja va2 s. c om */ public void createTestCase() { if (Character.isLowerCase(name.charAt(0))) { throw new CitrusRuntimeException("Test name must start with an uppercase letter"); } Properties properties = prepareTestCaseProperties(); targetPackage = targetPackage.replace('.', '/'); createFileFromTemplate(properties, CitrusConstants.DEFAULT_TEST_DIRECTORY + targetPackage + File.separator + name + ".xml", getTemplateFileForXMLTest(xmlRequest != null && xmlResponse != null)); createFileFromTemplate(properties, CitrusConstants.DEFAULT_JAVA_DIRECTORY + targetPackage + File.separator + name + ".java", getTemplateFileForJavaClass()); }
From source file:com.oakhole.utils.EncodeUtils.java
/** * jsescape.//from ww w . j a va 2s. c o m * * @param src * String * @return String */ public static String escapeJS(String src) { int i; char j; StringBuffer tmp = new StringBuffer(); tmp.ensureCapacity(src.length() * UNICODE_LENGTH); for (i = 0; i < src.length(); i++) { j = src.charAt(i); if (Character.isDigit(j) || Character.isLowerCase(j) || Character.isUpperCase(j)) { tmp.append(j); } else if (j < ANSI_CHAR_CODE) { tmp.append("%"); if (j < UNPRINTABLE_CHAR_CODE) { tmp.append("0"); } tmp.append(Integer.toString(j, HEX)); } else { tmp.append("%u"); tmp.append(Integer.toString(j, HEX)); } } return tmp.toString(); }
From source file:ch.cyberduck.core.ftp.parser.CommonUnixFTPEntryParser.java
protected FTPFile parseFTPEntry(String typeStr, String usr, String grp, long filesize, String datestr, String name, String endtoken) { final FTPExtendedFile file = new FTPExtendedFile(); int type;/*w ww . j ava 2s. com*/ try { file.setTimestamp(this.parseTimestamp(datestr)); } catch (ParseException e) { log.warn(e.getMessage()); } // bcdlfmpSs- switch (typeStr.charAt(0)) { case 'd': type = FTPFile.DIRECTORY_TYPE; break; case 'l': type = FTPFile.SYMBOLIC_LINK_TYPE; break; case 'b': case 'c': case 'f': case '-': type = FTPFile.FILE_TYPE; break; default: type = FTPFile.UNKNOWN_TYPE; } file.setType(type); file.setUser(usr); file.setGroup(grp); int g = 4; for (int access = 0; access < 3; access++, g += 4) { // Use != '-' to avoid having to check for suid and sticky bits. file.setPermission(access, FTPFile.READ_PERMISSION, (!group(g).equals("-"))); file.setPermission(access, FTPFile.WRITE_PERMISSION, (!group(g + 1).equals("-"))); String execPerm = group(g + 2); if (execPerm.equals("-")) { file.setPermission(access, FTPFile.EXECUTE_PERMISSION, false); } else { file.setPermission(access, FTPFile.EXECUTE_PERMISSION, Character.isLowerCase(execPerm.charAt(0))); if (0 == access) { file.setSetuid(execPerm.charAt(0) == 's' || execPerm.charAt(0) == 'S'); } if (1 == access) { file.setSetgid(execPerm.charAt(0) == 's' || execPerm.charAt(0) == 'S'); } if (2 == access) { file.setSticky(execPerm.charAt(0) == 't' || execPerm.charAt(0) == 'T'); } } } file.setSize(filesize); if (null == endtoken) { file.setName(name); } else { // oddball cases like symbolic links, file names // with spaces in them. name += endtoken; if (type == FTPFile.SYMBOLIC_LINK_TYPE) { int end = name.indexOf(" -> "); // Give up if no link indicator is present if (end == -1) { file.setName(name); } else { file.setName(name.substring(0, end)); file.setLink(name.substring(end + 4)); } } else { file.setName(name); } } return file; }
From source file:com.portmods.handlers.crackers.dictionary.Wordlist.java
@Override public void run() { try {/*from w w w.ja va 2 s.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); }