List of usage examples for java.lang Character isLetter
public static boolean isLetter(int codePoint)
From source file:net.yacy.cora.language.phonetic.Soundex.java
/** * Cleans up the input string before Soundex processing by only returning * upper case letters./*from ww w. j av a2 s .com*/ * * @param str * The String to clean. * @return A clean String. */ static String clean(String str) { if (str == null || str.isEmpty()) { return str; } int len = str.length(); char[] chars = new char[len]; int count = 0; for (int i = 0; i < len; i++) { if (Character.isLetter(str.charAt(i))) { chars[count++] = str.charAt(i); } } if (count == len) { return str.toUpperCase(java.util.Locale.ENGLISH); } return new String(chars, 0, count).toUpperCase(java.util.Locale.ENGLISH); }
From source file:eu.crisis_economics.configuration.FromFileConfigurationContext.java
private static boolean containsNameAsWholeWord(String expression, String name) { int cursor = expression.indexOf(name, 0); if (cursor == -1) return false; int nextCharAfterWordIndex = cursor + name.length(); if (nextCharAfterWordIndex == expression.length()) return true; Character nextCharAfterWord = expression.charAt(nextCharAfterWordIndex); if (Character.isLetter(nextCharAfterWord) || nextCharAfterWord == '_') return false; else/*from www. j a v a2s .co m*/ return true; }
From source file:edu.stanford.muse.index.NER.java
private static boolean nameFilterPass(String n) { // if 50% or less of the letters are characters, its not a valid name // e.g. fail "p.s." or "ca 94305" int chars = 0; for (char c : n.toCharArray()) if (Character.isLetter(c)) chars++;/*from w w w . j a va 2 s. c o m*/ return (chars * 2 > n.length()); }
From source file:de.innovationgate.wgpublisher.hdb.HDBModelListener.java
public static String createContentClassJsIdentifier(String contentClass) { // Remove chars not allowed in JS var names: StringBuffer extension = new StringBuffer(); for (int idx = 0; idx < contentClass.length(); idx++) { Character c = contentClass.charAt(idx); if (idx == 0) { if (Character.isLetter(c)) { extension.append(c);/* w ww . j a v a2s . c om*/ } } else { if (Character.isLetter(c) || Character.isDigit(c)) { extension.append(c); } } } // Capitalize return StringUtils.capitalize(extension.toString().toLowerCase()); }
From source file:net.andydvorak.intellij.lessc.ui.configurable.LessProfileConfigurableForm.java
@Nullable private String promptForFilePath(final @Nullable String initial) { @NotNull/* w ww . j av a 2 s .c o m*/ final String initialNN = StringUtils.defaultString(initial); final FileChooserDescriptor d = getFileChooserDescriptor(); final VirtualFile initialFile = StringUtil.isNotEmpty(initialNN) ? LocalFileSystem.getInstance().findFileByPath(initialNN) : null; final VirtualFile file = project != null ? FileChooser.chooseFile(project, d, initialFile) : FileChooser.chooseFile(profileMappingTable, d, initialFile); String path = null; if (file != null) { path = file.getPresentableUrl(); if (SystemInfo.isWindows && path.length() == 2 && Character.isLetter(path.charAt(0)) && path.charAt(1) == ':') { path += "\\"; // make path absolute } } return path; }
From source file:org.exoplatform.webui.commons.UISaveAttachment.java
public static void validate(String s) throws IllegalNameException { StringTokenizer tokens;/* ww w . j a v a2s. c o m*/ if (s == null || s.trim().length() == 0) { throw new IllegalNameException(); } for (int i = 0; i < s.length(); i++) { tokens = new StringTokenizer(invalidCharacters); char c = s.charAt(i); boolean isInvalid = false; while (tokens.hasMoreTokens()) { String test = tokens.nextToken(); isInvalid = test.equals(String.valueOf(c)); if (isInvalid == true) break; } if (Character.isLetter(c) || Character.isDigit(c) || (!isInvalid)) { continue; } else { throw new IllegalNameException(invalidCharacters); } } }
From source file:com.mirth.connect.plugins.datatypes.delimited.DelimitedSerializationProperties.java
private boolean validXMLElementName(String s) { // Reference: http://www.w3.org/TR/REC-xml/#sec-well-formed ///*from w w w .j ava 2s . co m*/ // Simplified requirements for a valid XML element name: // o First character must be a letter, underscore or colon // o Remaining characters must be letter, digit, period, dash, underscore or colon // // Note: this is not 100% complete, as it does not include tests for the so called // "CombiningChar" nor "Extender". // Must not be null or empty string if (s == null || s.length() == 0) { return false; } // First character must be a letter, underscore or colon char ch = s.charAt(0); if (!Character.isLetter(ch) && ch != '_' && ch != ':') { return false; } // Remaining characters must be letter, digit, period, dash, underscore or colon for (int i = 1; i < s.length(); i++) { ch = s.charAt(i); if (!Character.isLetter(ch) && !Character.isDigit(ch) && ch != '.' && ch != '-' && ch != '_' && ch != ':') { return false; } } return true; }
From source file:org.springframework.data.gemfire.client.Interest.java
/** * Determines whether the given {@code character} is an alphanumeric or whitespace character. * * @param character {@link Character} to evaluate. * @return a boolean value indicating whether the given {@code character} is an alphanumeric * or whitespace character./*from w ww . jav a 2s . c o m*/ * @see java.lang.Character#isDigit(char) * @see java.lang.Character#isLetter(char) * @see java.lang.Character#isWhitespace(char) */ protected boolean isAlphaNumericWhitespace(char character) { return (Character.isDigit(character) || Character.isLetter(character) || Character.isWhitespace(character)); }
From source file:com.yek.keyboard.anysoftkeyboard.AnySoftKeyboard.java
private static boolean isBackWordStopChar(int c) { return !Character.isLetter(c); }
From source file:net.spfbl.whois.AutonomousSystem.java
/** * Atualiza os campos do registro com resultado do WHOIS. * @param result o resultado do WHOIS.//from w w w.j a v a2s .c o m * @return o domnio real apresentado no resultado do WHOIS. * @throws QueryException se houver alguma falha da atualizao do registro. */ private void refresh(String result) throws ProcessException { try { boolean reducedLocal = false; String autnumResult = null; BufferedReader reader = new BufferedReader(new StringReader(result)); try { String line; while ((line = reader.readLine()) != null) { line = line.trim(); if (line.startsWith("aut-num:")) { int index = line.indexOf(':') + 1; autnumResult = line.substring(index).trim(); } else if (line.startsWith("owner:")) { int index = line.indexOf(':') + 1; owner = line.substring(index).trim(); } else if (line.startsWith("ownerid:")) { int index = line.indexOf(':') + 1; ownerid = line.substring(index).trim(); } else if (line.startsWith("responsible:")) { int index = line.indexOf(':') + 1; responsible = line.substring(index).trim(); } else if (line.startsWith("country:")) { int index = line.indexOf(':') + 1; country = line.substring(index).trim(); } else if (line.startsWith("owner-c:")) { int index = line.indexOf(':') + 1; owner_c = line.substring(index).trim(); } else if (line.startsWith("routing-c:")) { int index = line.indexOf(':') + 1; routing_c = line.substring(index).trim(); } else if (line.startsWith("abuse-c:")) { int index = line.indexOf(':') + 1; abuse_c = line.substring(index).trim(); } else if (line.startsWith("inetnum:")) { int index = line.indexOf(':') + 1; String inetnum = line.substring(index).trim(); inetnumSet.add(inetnum); } else if (line.startsWith("created:")) { int index = line.indexOf(':') + 1; String valor = line.substring(index).trim(); created = DATE_FORMATTER.parse(valor); } else if (line.startsWith("changed:")) { int index = line.indexOf(':') + 1; String valor = line.substring(index).trim(); changed = DATE_FORMATTER.parse(valor); } else if (line.startsWith("nic-hdl-br:")) { int index = line.indexOf(':') + 1; String nic_hdl_br = line.substring(index).trim(); line = reader.readLine().trim(); index = line.indexOf(':') + 1; String person = line.substring(index).trim(); line = reader.readLine().trim(); index = line.indexOf(':') + 1; String e_mail; if (reducedLocal) { e_mail = null; } else { e_mail = line.substring(index).trim(); line = reader.readLine().trim(); index = line.indexOf(':') + 1; } String created2 = line.substring(index).trim(); line = reader.readLine().trim(); index = line.indexOf(':') + 1; String changed2 = line.substring(index).trim(); Handle handle = Handle.getHandle(nic_hdl_br); handle.setPerson(person); handle.setEmail(e_mail); handle.setCreated(created2); handle.setChanged(changed2); } else if (line.startsWith("% No match for domain")) { throw new ProcessException("ERROR: DOMAIN NOT FOUND"); } else if (line.startsWith("% release process: waiting")) { throw new ProcessException("ERROR: WAITING"); } else if (line.startsWith("% reserved: CG")) { throw new ProcessException("ERROR: RESERVED"); } else if (line.startsWith("% Maximum concurrent connections limit exceeded")) { throw new ProcessException("ERROR: WHOIS CONCURRENT"); } else if (line.startsWith("% Permission denied.")) { throw new ProcessException("ERROR: WHOIS DENIED"); } else if (line.startsWith("% Permisso negada.")) { throw new ProcessException("ERROR: WHOIS DENIED"); } else if (line.startsWith("% Query rate limit exceeded. Reduced information.")) { // Informao reduzida devido ao estouro de limite de consultas. Server.removeWhoisQueryHour(); reducedLocal = true; } else if (line.startsWith("% Query rate limit exceeded")) { // Restrio total devido ao estouro de limite de consultas. Server.removeWhoisQueryDay(); throw new ProcessException("ERROR: WHOIS QUERY LIMIT"); } else if (line.length() > 0 && Character.isLetter(line.charAt(0))) { Server.logError("Linha no reconhecida: " + line); } } } finally { reader.close(); } if (autnumResult == null) { throw new ProcessException("ERROR: AS NOT FOUND"); } else if (!autnumResult.equals(aut_num)) { throw new ProcessException("ERROR: PARSING"); } else { this.lastRefresh = System.currentTimeMillis(); this.reduced = reducedLocal; this.queries = 1; // Atualiza flag de atualizao. AS_CHANGED = true; } } catch (ProcessException ex) { throw ex; } catch (Exception ex) { Server.logError(ex); throw new ProcessException("ERROR: PARSING", ex); } }