List of usage examples for java.lang Character isUpperCase
public static boolean isUpperCase(int codePoint)
From source file:jdroidremote.ServerFrame.java
public static void typeCharacter(String letter) { System.out.println(letter);//from ww w . ja va 2s . com Robot robot = null; try { robot = new Robot(); } catch (Exception ex) { ex.printStackTrace(); } if (Character.isLetter(letter.charAt(0))) { try { boolean upperCase = Character.isUpperCase(letter.charAt(0)); String variableName = "VK_" + letter.toUpperCase(); KeyEvent ke = new KeyEvent(new JTextField(), 0, 0, 0, 0, ' '); Class clazz = ke.getClass(); Field field = clazz.getField(variableName); int keyCode = field.getInt(ke); //System.out.println(keyCode + " = keyCode"); robot.delay(80); if (upperCase) { robot.keyPress(KeyEvent.VK_SHIFT); } robot.keyPress(keyCode); robot.keyRelease(keyCode); if (upperCase) { robot.keyRelease(KeyEvent.VK_SHIFT); } } catch (Exception e) { System.out.println(e); } } else if (letter.equals(".")) { robot.keyPress(KeyEvent.VK_PERIOD); //keyCode 46 robot.keyRelease(KeyEvent.VK_PERIOD); } else if (letter.equals("!")) { robot.keyPress(KeyEvent.VK_SHIFT); //keyCode 16 robot.keyPress(KeyEvent.VK_1); //keycode 49 robot.keyRelease(KeyEvent.VK_1); robot.keyRelease(KeyEvent.VK_SHIFT); } else if (letter.equals(" ")) { robot.keyPress(KeyEvent.VK_SPACE); robot.keyRelease(KeyEvent.VK_SPACE); } else if (letter.equals("?")) { robot.keyPress(KeyEvent.VK_SHIFT); //keyCode 16 robot.keyPress(KeyEvent.VK_SLASH); //keyCode 47 robot.keyRelease(KeyEvent.VK_SLASH); robot.keyRelease(KeyEvent.VK_SHIFT); } else if (letter.equals(",")) { robot.keyPress(KeyEvent.VK_COMMA); robot.keyRelease(KeyEvent.VK_COMMA); } else if (letter.equals("@enter")) { robot.keyPress(KeyEvent.VK_ENTER); robot.keyRelease(KeyEvent.VK_ENTER); } else if (letter.equals("@backspace")) { robot.keyPress(KeyEvent.VK_BACK_SPACE); robot.keyRelease(KeyEvent.VK_BACK_SPACE); } }
From source file:org.apdplat.superword.extract.PhraseExtractor.java
/** * ??//w w w . j ava2s . c o m * @param html * @return */ public static Set<String> parsePhrase(String html, String word) { Set<String> phrases = new HashSet<>(); LOGGER.info("???" + word); if (Character.isUpperCase(word.charAt(0))) { LOGGER.info("???"); return phrases; } try { o: for (Element element : Jsoup.parse(html).select(PHRASE_CSS_PATH)) { String phrase = element.text().trim(); if (StringUtils.isNotBlank(phrase)) { if (phrase.length() >= 50) { LOGGER.debug(":" + phrase); break o; } String[] attrs = phrase.split("\\s+"); if (attrs == null || attrs.length < 2) { LOGGER.debug(":" + phrase); break o; } for (String attr : attrs) { for (char c : attr.toCharArray()) { if (!(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')) { LOGGER.debug(":" + phrase); break o; } } } phrases.add(phrase); LOGGER.debug("?:" + phrase); } } } catch (Exception e) { LOGGER.error("?", e); } return phrases; }
From source file:org.gradle.model.internal.manage.schema.extract.ImplTypeSchemaExtractionStrategySupport.java
private <R> List<ModelProperty<?>> extractPropertySchemas(ModelSchemaExtractionContext<R> extractionContext, Multimap<String, Method> methodsByName) { List<ModelProperty<?>> properties = Lists.newArrayList(); Set<Method> handledMethods = Sets.newHashSet(); for (String methodName : methodsByName.keySet()) { Collection<Method> methods = methodsByName.get(methodName); List<Method> overloadedMethods = getOverloadedMethods(methods); if (overloadedMethods != null) { handleOverloadedMethods(extractionContext, overloadedMethods); continue; }/*from w w w.j a va2 s. c o m*/ if (methodName.startsWith("get") && !methodName.equals("get")) { PropertyAccessorExtractionContext getterContext = new PropertyAccessorExtractionContext(methods, isGetterDefinedInManagedType(extractionContext, methodName, methods)); Character getterPropertyNameFirstChar = methodName.charAt(3); if (!Character.isUpperCase(getterPropertyNameFirstChar)) { handleInvalidGetter(extractionContext, getterContext, "the 4th character of the getter method name must be an uppercase character"); continue; } String propertyNameCapitalized = methodName.substring(3); String propertyName = StringUtils.uncapitalize(propertyNameCapitalized); String setterName = "set" + propertyNameCapitalized; Collection<Method> setterMethods = methodsByName.get(setterName); PropertyAccessorExtractionContext setterContext = !setterMethods.isEmpty() ? new PropertyAccessorExtractionContext(setterMethods) : null; ModelProperty<?> property = extractPropertySchema(extractionContext, propertyName, getterContext, setterContext, handledMethods); if (property != null) { properties.add(property); handledMethods.addAll(getterContext.getDeclaringMethods()); if (setterContext != null) { handledMethods.addAll(setterContext.getDeclaringMethods()); } } } } validateAllNecessaryMethodsHandled(extractionContext, methodsByName.values(), handledMethods); return properties; }
From source file:de.tudarmstadt.ukp.dkpro.keyphrases.bookindexing.candidate.HeuristicNamedEntityAnnotator.java
/** * Checks if the token is written in all capitals. * * @param token//from w w w. ja v a2s .co m * @return true when token in all-caps, else false */ private boolean isAllCaps(String token) { if (!token.isEmpty()) { for (int i = 0; i < token.length(); i++) { if (!Character.isUpperCase(token.charAt(i))) { return false; } } return true; } else { return false; } }
From source file:com.curl.orb.servlet.InstanceManagementUtil.java
public static boolean isGetter(Method method) { return (method.getName().startsWith("get") && Character.isUpperCase(method.getName().charAt(3)) && method.getParameterTypes().length == 0 && method.getReturnType() != void.class); }
From source file:org.moe.natjgen.CEnumManager.java
/** * Try to trim the prefixes of all constants *///from w w w. jav a 2 s .co m private void trimPrefix() { final String enumName = originalName; if (constants.size() < 2 || INVALID_NAME.equals(enumName)) { return; } final ArrayList<ArrayList<String>> decomposedConstants = new ArrayList<ArrayList<String>>(constants.size()); for (CEnumConstant constant : constants) { final String name = constant.getName(); final int nameLength = name.length(); final ArrayList<String> decomposedConstant = new ArrayList<String>(); decomposedConstants.add(decomposedConstant); // Split by upper-case and underscore characters int start = 0, curr = 0; while (curr < nameLength) { char c = name.charAt(curr); if (c == '_' || Character.isUpperCase(c)) { if (start != curr) { decomposedConstant.add(name.substring(start, curr)); start = curr; } curr++; } else { ++curr; } } decomposedConstant.add(name.substring(start, curr)); // Join single upper-case components curr = 0; while (curr < decomposedConstant.size()) { start = curr; String currStr = decomposedConstant.get(curr); if ((currStr.length() != 1 && !isUpperCaseOrNumber(currStr)) || !Character.isUpperCase(currStr.charAt(0))) { ++curr; continue; } ++curr; if (curr >= decomposedConstant.size()) { break; } while (curr < decomposedConstant.size()) { currStr = decomposedConstant.get(curr); if ((currStr.length() != 1 && !isUpperCaseOrNumber(currStr)) || !Character.isUpperCase(currStr.charAt(0))) { break; } ++curr; } int len = curr - start; if (len > 1) { StringBuilder sb = new StringBuilder(len); for (int i = start; i < curr; ++i) { sb.append(decomposedConstant.remove(start)); } decomposedConstant.add(start, sb.toString()); curr = start + 1; } } } // Lookup common prefixes boolean looping = true; int lastCommonIdx = -1; while (looping) { // Get baseline prefix if (lastCommonIdx + 1 >= decomposedConstants.get(0).size() - 1) { break; } final String baseline = decomposedConstants.get(0).get(lastCommonIdx + 1); for (int i = 1; i < decomposedConstants.size(); ++i) { // Get compare prefix if (lastCommonIdx + 1 >= decomposedConstants.get(i).size() - 1) { looping = false; break; } final String compare = decomposedConstants.get(i).get(lastCommonIdx + 1); // Compare prefixes if (!compare.equals(baseline)) { looping = false; break; } } if (looping) { ++lastCommonIdx; } } // No common prefixes were found if (lastCommonIdx < 0) { return; } StringBuilder sb = new StringBuilder(256); for (int i = 0; i < constants.size(); ++i) { sb.setLength(0); ArrayList<String> list = decomposedConstants.get(i); for (int o = lastCommonIdx + 1; o < list.size(); ++o) { sb.append(list.get(o)); } constants.get(i).setName(sb.toString()); } }
From source file:org.beangle.model.persist.hibernate.support.RailsNamingStrategy.java
/** * Collection Table//from ww w . j av a 2 s. c o m */ public String collectionTableName(String ownerEntity, String ownerEntityTable, String associatedEntity, String associatedEntityTable, String propertyName) { String ownerTable = null; // just for annotation configuration,it;s ownerEntity is classname(not entityName), and // ownerEntityTable is class shortname if (Character.isUpperCase(ownerEntityTable.charAt(0))) { ownerTable = tableNameConfig.classToTableName(ownerEntity); } else { ownerTable = tableName(ownerEntityTable); } String tblName = tableNameConfig.collectionToTableName(ownerEntity, ownerTable, propertyName); if (tblName.length() > MaxLength) { logger.error("{}'s length has greate more then 30, database will not be supported!", tblName); } return tblName; }
From source file:com.redhat.rhn.common.util.StringUtil.java
/** * Convert the passed in bean style string to a underscore separated string. * * For example: someFieldName -> some_field_name * * @param strIn The string to convert// w w w .ja v a 2s .c o m * @return The converted string */ public static String debeanify(String strIn) { String str = strIn.trim(); StringBuilder result = new StringBuilder(str.length()); for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (Character.isUpperCase(c)) { result.append("_"); } result.append(Character.toLowerCase(c)); } return result.toString(); }
From source file:edu.illinois.cs.cogcomp.edison.features.lrec.TestWordTypeInformation.java
public final void test() throws EdisonException { log.debug("WordTypeInformation"); // Using the first TA and a constituent between span of 0 - 20 as a test TextAnnotation ta = tas.get(1);//from w w w. j a v a2s .c om View TOKENS = ta.getView("TOKENS"); log.debug("GOT TOKENS FROM TEXTAnn"); List<Constituent> testlist = TOKENS.getConstituentsCoveringSpan(0, 20); String[] teststrings = new String[5]; int i = 0, start = 1, end = 6; for (Constituent c : testlist) { log.debug(c.getSurfaceForm()); if (i >= start && i < end) { teststrings[i - start] = c.getSurfaceForm(); } i++; } log.debug("Testlist size is " + testlist.size()); Constituent test = testlist.get(3); log.debug("The constituent we are extracting features from in this test is: " + test.getSurfaceForm()); WordTypeInformation wti = new WordTypeInformation("WordTypeInformation"); log.debug("Startspan is " + test.getStartSpan() + " and Endspan is " + test.getEndSpan()); Set<Feature> feats = wti.getFeatures(test); String[] expected_outputs = { "WordTypeInformation:c0(false)", "WordTypeInformation:d0(false)", "WordTypeInformation:c1(false)", "WordTypeInformation:d1(false)", "WordTypeInformation:c2(false)", "WordTypeInformation:d2(false)", "WordTypeInformation:c2(true)", "WordTypeInformation:c3(false)", "WordTypeInformation:d3(false)", "WordTypeInformation:c4(false)", "WordTypeInformation:d4(false)", "WordTypeInformation:c4(true)" }; Set<String> __result = new LinkedHashSet<String>(); String __id; String __value; String classifier = "WordTypeInformation"; if (feats == null) { log.debug("Feats are returning NULL."); assertFalse(true); } log.debug("Printing Set of Features"); for (Feature f : feats) { log.debug(f.getName()); assert (ArrayUtils.contains(expected_outputs, f.getName())); } for (; (start < end && teststrings[start - 1] != null); start++) { boolean allCapitalized = true, allDigits = true, allNonLetters = true; for (int j = 0; j < teststrings[start - 1].length(); ++j) { allCapitalized &= Character.isUpperCase(teststrings[start - 1].charAt(j)); allDigits &= Character.isDigit(teststrings[start - 1].charAt(j)); allNonLetters &= !Character.isLetter(teststrings[start - 1].charAt(j)); } __id = classifier + ":" + ("c" + (start - 1)); __value = "(" + (allCapitalized) + ")"; __result.add(__id + __value); __id = classifier + ":" + ("d" + (start - 1)); __value = "(" + (allDigits) + ")"; __result.add(__id + __value); __id = classifier + ":" + ("c" + (start - 1)); __value = "(" + (allNonLetters) + ")"; __result.add(__id + __value); } for (Feature feat : feats) { if (!__result.contains(feat.getName())) { assertFalse(true); } } // System.exit(0); }
From source file:org.jumpmind.util.FormatUtils.java
public static boolean isMixedCase(String text) { char[] chars = text.toCharArray(); boolean upper = false; boolean lower = false; for (char ch : chars) { upper |= Character.isUpperCase(ch); lower |= Character.isLowerCase(ch); }//from w w w . ja v a 2s . c om return upper && lower; }