List of usage examples for java.lang Character isUpperCase
public static boolean isUpperCase(int codePoint)
From source file:org.emonocot.portal.view.Functions.java
/** * * @param provenance/* w w w. java2s. c om*/ * Set the provenance * @param data * Set the data * @return the provenance initial */ public static String provenanceinitial(ProvenanceManager provenance, BaseData data) { String key = provenance.getKey(data).toUpperCase(); String orgname = data.getAuthority().getTitle(); String initials = ""; for (int i = 0, n = orgname.length(); i < n; i++) { if (Character.isUpperCase(orgname.charAt(i))) { initials += orgname.charAt(i); } } initials += "." + key; return initials; }
From source file:de.aschoerk.javaconv.RustDumpVisitor.java
@Override public void visit(final VariableDeclarator n, final Object arg) { printJavaComment(n.getComment(), arg); String name = acceptAndCut(n.getId(), arg); boolean isConstant = false; if (Character.isUpperCase(name.charAt(0))) { printer.print("const "); isConstant = true;//from w w w .ja va2 s . com } else { printer.print("let "); if (idTracker.isChanged(name, n)) { printer.print("mut "); } } printer.print(name); boolean isInitializedArray = n.getInit() != null && (n.getInit() instanceof ArrayInitializerExpr || n.getInit() instanceof ArrayCreationExpr); if (arg instanceof Type && !isInitializedArray) { printer.print(": "); Type t = (Type) arg; String tmp = acceptAndCut(t, null); if (isConstant && tmp.equals("String")) { printer.print("&'static str"); } else { printer.print(tmp); } } if (n.getInit() != null) { if (!isInitializedArray) printer.print(" = "); n.getInit().accept(this, arg); } }
From source file:de.tudarmstadt.ukp.dkpro.spelling.experiments.errormining.SpellingErrorFilter.java
private boolean haveFirstLettersSameCase(char char1, char char2) { if (Character.isUpperCase(char1) && Character.isLowerCase(char2) || Character.isLowerCase(char1) && Character.isUpperCase(char2)) { return false; }/* ww w. ja v a2s .c om*/ return true; }
From source file:CharUtils.java
/** * True if string contains internal capital letters. * //from ww w. j a v a2 s .c o m * @param s * String to check for having internal capitals. * * @return True if string has internal capitals. */ public static boolean hasInternalCaps(String s) { boolean result = false; for (int i = 1; i < s.length(); i++) { char ch = s.charAt(i); result = result || Character.isLetter(ch) && Character.isUpperCase(ch); if (result) break; } return result; }
From source file:org.mindswap.swoop.renderer.entity.NLVisitor.java
public String getEntityTokens(String entityName) { String[] tokens = new String[10]; String strTokens = ""; int tLen = 0; int prev = 0; for (int i = 1; i < entityName.length(); i++) { if (Character.isUpperCase(entityName.charAt(i))) { //if (entityName.charAt(i) >= 'A' && entityName.charAt(i) <= 'Z') { if (i - prev > 0) { strTokens += (entityName.substring(prev, i) + " "); tokens[tLen++] = entityName.substring(prev, i); prev = i;//from ww w . j ava2 s . co m } } if (i == (entityName.length() - 1)) { // System.out.println(i+":"+prev+":"+entityName+":"+entityName.substring(prev)); tokens[tLen] = entityName.substring(prev); strTokens += entityName.substring(prev); } } return strTokens; }
From source file:opennlp.tools.textsimilarity.TextProcessor.java
public static String trimSentence(String txt, String title) { // iterate backwards looking for the first all cap word.. int numCapWords = 0; int firstIdx = -1; String cleaned = txt;//from w w w . j a v a2 s . co m for (int i = txt.length() - 1; i >= 0; i--) { if (Character.isUpperCase(txt.charAt(i))) { if (numCapWords == 0) { firstIdx = i; } numCapWords++; } else { numCapWords = 0; firstIdx = -1; } if (numCapWords > 3) { if (firstIdx != -1) { cleaned = txt.substring(firstIdx + 1); break; } } } txt = cleaned; // now scrub the start of the string int idx = 0; for (int i = 0; i < txt.length() - 1; i++) { if (!Character.isUpperCase(txt.charAt(i))) { idx++; } else { break; } } txt = txt.substring(idx); // scrub the title if (title.trim().length() > 0 && txt.indexOf(title.trim()) != -1) { txt = txt.substring(txt.indexOf(title.trim()) + title.trim().length() - 1); } // scrub before first - if (txt.indexOf(" ") != -1) { txt = txt.substring(txt.indexOf(" ") + 3); } if (txt.indexOf(" - ") != -1) { txt = txt.substring(txt.indexOf(" - ") + 3); } if (txt.indexOf("del.icio.us") != -1) { txt = txt.substring(txt.indexOf("del.icio.us") + "del.icio.us".length()); } return txt; }
From source file:net.java.sip.communicator.gui.AuthenticationSplash.java
public boolean valid() { int idx;//from w w w . j av a 2s. co m boolean usern = true, pwd = true, nme = true, lnme = true, ml = true; // Username checks // Starts with a letter if (userName.length() == 0) usern = false; else if (!Character.isLetter(userName.charAt(0))) usern = false; // Contains only letters and numbers for (idx = 0; idx < userName.length(); idx++) { if (!Character.isLetterOrDigit(userName.charAt(idx))) usern = false; } // Is between 4 and 10 characters if ((userName.length() < 4) || (userName.length() > 18)) usern = false; // Name and last name checks // Both begin with uppercase if (name.length() == 0) nme = false; else if (!Character.isUpperCase(name.charAt(0))) nme = false; if (lastName.length() == 0) lnme = false; else if (!Character.isUpperCase(lastName.charAt(0))) lnme = false; // Both contain only letters for (idx = 0; idx < name.length(); idx++) { if (!Character.isLetter(name.charAt(idx))) nme = false; } for (idx = 0; idx < lastName.length(); idx++) { if (!Character.isLetter(lastName.charAt(idx))) lnme = false; } // Mail chekcs Pattern ptr = Pattern.compile( "(?:(?:\\r\\n)?[ \\t])*(?:(?:(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\"(?:[^\\\"\\r\\\\]|\\\\.|(?:(?:\\r\\n)?[ \\t]))*\"(?:(?:\\r\\n)?[ \\t])*)(?:\\.(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\"(?:[^\\\"\\r\\\\]|\\\\.|(?:(?:\\r\\n)?[ \\t]))*\"(?:(?:\\r\\n)?[ \\t])*))*@(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\\[([^\\[\\]\\r\\\\]|\\\\.)*\\](?:(?:\\r\\n)?[ \\t])*)(?:\\.(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+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\\n)?[ \\t])*))*@(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\\[([^\\[\\]\\r\\\\]|\\\\.)*\\](?:(?:\\r\\n)?[ \\t])*)(?:\\.(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\\[([^\\[\\]\\r\\\\]|\\\\.)*\\](?:(?:\\r\\n)?[ \\t])*))*\\>(?:(?:\\r\\n)?[ \\t])*))*)?;\\s*)"); if (!ptr.matcher(mail).matches()) ml = false; // Password checks // Check that we have a variety of different characters boolean lower = false, upper = false, number = false, other = false; for (idx = 0; idx < password.length(); idx++) { if (Character.isUpperCase(password.charAt(idx))) upper = true; if (Character.isLowerCase(password.charAt(idx))) lower = true; if (!Character.isLetterOrDigit(password.charAt(idx))) other = true; if (Character.isDigit(password.charAt(idx))) number = true; } if (!(upper && lower && number && other)) pwd = false; // Verify that the size is acceptable if (password.length() < 6 || password.length() > 30) pwd = false; // Change the label colors if (!nme) { nameLabel.setForeground(Color.RED); nameTextField.setText(""); } if (!lnme) { lastNameLabel.setForeground(Color.RED); lastNameTextField.setText(""); } if (!ml) { mailLabel.setForeground(Color.RED); mailTextField.setText(""); } if (!usern) { userNameLabel.setForeground(Color.RED); userNameTextField.setText(""); } if (!pwd) { passwordLabel.setForeground(Color.RED); passwordTextField.setText(""); } if (!(nme && lnme && usern && ml && pwd)) return false; return true; }
From source file:org.codehaus.griffon.commons.GriffonClassUtils.java
/** * Returns true if the name of the method specified and the number of arguments make it a javabean property * * @param name True if its a Javabean property * @param args The arguments//from ww w . j ava 2 s . c om * @return True if it is a javabean property method */ public static boolean isGetter(String name, Class[] args) { if ((StringUtils.isBlank(name)) || (args == null)) return false; if (args.length != 0) return false; if (name.startsWith("get")) { name = name.substring(3); if (name.length() > 0 && Character.isUpperCase(name.charAt(0))) return true; } else if (name.startsWith("is")) { name = name.substring(2); if (name.length() > 0 && Character.isUpperCase(name.charAt(0))) return true; } return false; }
From source file:org.languagetool.tagging.uk.CompoundTagger.java
private List<AnalyzedToken> matchNumberedProperNoun(String word, String leftWord, String rightWord) { // ?-140// ww w. java2 s. c o m if (NOUN_SUFFIX_NUMBER_LETTER.matcher(rightWord).matches()) { Set<AnalyzedToken> newAnalyzedTokens = new LinkedHashSet<>(); for (Map.Entry<String, List<String>> entry : numberedEntities.entrySet()) { if (word.matches(entry.getKey())) { for (String tag : entry.getValue()) { if (tag.contains(":nv")) { String[] tagParts = tag.split(":"); String extraTags = tag.replaceFirst(".*?:nv", "").replace(":np", ""); List<AnalyzedToken> newTokens = PosTagHelper.generateTokensForNv(word, tagParts[1], extraTags); newAnalyzedTokens.addAll(newTokens); if (!tag.contains(":np") && !tag.contains(":p")) { newTokens = PosTagHelper.generateTokensForNv(word, "p", extraTags); newAnalyzedTokens.addAll(newTokens); } } else { newAnalyzedTokens.add(new AnalyzedToken(word, tag, word)); } } } } if (newAnalyzedTokens.size() > 0) return new ArrayList<>(newAnalyzedTokens); } // -2014 if (YEAR_NUMBER.matcher(rightWord).matches()) { List<TaggedWord> leftWdList = tagAsIsAndWithLowerCase(leftWord); if (!leftWdList.isEmpty() && Character.isUpperCase(leftWord.charAt(0))) { List<AnalyzedToken> leftAnalyzedTokens = ukrainianTagger .asAnalyzedTokenListForTaggedWordsInternal(leftWord, leftWdList); List<AnalyzedToken> newAnalyzedTokens = new ArrayList<>(); for (AnalyzedToken analyzedToken : leftAnalyzedTokens) { if (!PosTagHelper.hasPosTagPart(analyzedToken, ":prop") && !WORDS_WITH_YEAR.contains(analyzedToken.getLemma())) continue; String posTag = analyzedToken.getPOSTag(); // only noun - : - // ?-2014 - ?, '? if (posTag == null || !posTag.startsWith("noun:inanim")) continue; if (posTag.contains("v_kly")) continue; if (posTag.contains(":p:") && !Arrays.asList("", "", "") .contains(analyzedToken.getLemma()) && !posTag.contains(":ns")) continue; String lemma = analyzedToken.getLemma(); posTag = posTag.replace(":geo", ""); if (!posTag.contains(":prop")) { posTag += ":prop"; lemma = StringUtils.capitalize(lemma); } newAnalyzedTokens.add(new AnalyzedToken(word, posTag, lemma + "-" + rightWord)); } if (newAnalyzedTokens.size() > 0) return newAnalyzedTokens; } } // -1, -2, -3 if (NOUN_PREFIX_NUMBER.matcher(rightWord).matches()) { List<TaggedWord> leftWdList = tagAsIsAndWithLowerCase(leftWord); if (!leftWdList .isEmpty() /*&& Character.isUpperCase(leftWord.charAt(0)) && leftWord.matches("[?-?][-?'].*")*/ ) { List<AnalyzedToken> leftAnalyzedTokens = ukrainianTagger .asAnalyzedTokenListForTaggedWordsInternal(leftWord, leftWdList); List<AnalyzedToken> newAnalyzedTokens = new ArrayList<>(); for (AnalyzedToken analyzedToken : leftAnalyzedTokens) { String posTag = analyzedToken.getPOSTag(); String lemma = analyzedToken.getLemma(); if (posTag == null || !posTag.startsWith("noun:inanim")) continue; if (posTag.contains("v_kly")) continue; if (!posTag.contains(":prop")) { if (!WORDS_WITH_NUM.contains(lemma)) { posTag += ":prop"; lemma = StringUtils.capitalize(lemma); } } if (!WORDS_WITH_NUM.contains(lemma)) continue; newAnalyzedTokens.add(new AnalyzedToken(word, posTag, lemma + "-" + rightWord)); } if (newAnalyzedTokens.size() > 0) return newAnalyzedTokens; } } return null; }
From source file:models.persistence.lecture.Lecture.java
@JsonIgnore public String getShortName() { StringBuilder sb = new StringBuilder(); for (int i = 0; i < name.length(); i++) { if (Character.isUpperCase(name.charAt(i)) || Character.isDigit(name.charAt(i)) || name.charAt(i) == '/' || name.charAt(i) == ' ' || name.charAt(i) == '+' || name.charAt(i) == '-') { sb.append(name.charAt(i));/*from w w w . j av a 2 s . c o m*/ if (Character.isUpperCase(name.charAt(i))) { for (int j = i; j < i + 3 && j < name.length(); j++) { if (Character.isLowerCase(name.charAt(j))) { sb.append(name.charAt(j)); } } } } } return sb.toString().replaceAll(" ", "").replaceAll("AE", "").replaceAll("OE", "") .replaceAll("UE", "").trim(); //return sb.toString().replaceAll("","AE").replaceAll("","OE").replaceAll("","UE").trim(); }