List of usage examples for java.lang Character isUpperCase
public static boolean isUpperCase(int codePoint)
From source file:com.screenslicer.core.nlp.Person.java
private static boolean isFullName(String str, boolean strict) { if (!isValidNameChars(str)) { return false; }/*from ww w .j a v a 2s. co m*/ if (str.contains(" ")) { String[] parts = str.split(" "); int upper = 0; int nonDictionary = 0; if (!firstNames.contains(parts[0])) { return false; } for (int i = 0; i < parts.length; i++) { if (Character.isUpperCase(parts[i].charAt(0))) { ++upper; } if (!englishWords.contains(parts[i].toLowerCase()) || (i == 0 && ((strict && firstNamesPopular.contains(parts[i])) || (!strict && firstNames.contains(parts[i])))) || (i > 0 && isLastName(parts[i]))) { ++nonDictionary; } } return upper > 1 && nonDictionary > 0; } return false; }
From source file:com.laxser.blitz.web.impl.module.ControllerRef.java
private boolean ignoresCommonMethod(Method method) { // ? Object //ww w.ja v a 2 s .c o m if (ClassUtils.hasMethod(Object.class, method.getName(), method.getParameterTypes())) { return true; } // ?java bean?? String name = method.getName(); if (name.startsWith("get") && name.length() > 3 && Character.isUpperCase(name.charAt("get".length())) && method.getParameterTypes().length == 0 && method.getReturnType() != void.class) { if (null == method.getAnnotation(Get.class)) { return true; } } if (name.startsWith("is") && name.length() > 3 && Character.isUpperCase(name.charAt("is".length())) && method.getParameterTypes().length == 0 && (method.getReturnType() == boolean.class || method.getReturnType() == Boolean.class)) { if (null == method.getAnnotation(Get.class)) { return true; } } if (name.startsWith("set") && name.length() > 3 && Character.isUpperCase(name.charAt("set".length())) && method.getParameterTypes().length == 1 && method.getReturnType() == void.class) { if (null == method.getAnnotation(Post.class)) { return true; } } return false; }
From source file:com.evolveum.midpoint.model.client.ModelClientUtil.java
public static QName getElementName(Class<? extends ObjectType> type) { String local = type.getSimpleName(); int typeIndex = local.lastIndexOf("Type"); if (typeIndex > 0) { local = local.substring(0, typeIndex); }//from ww w .ja va 2 s .c o m if (Character.isUpperCase(local.charAt(0))) { local = local.substring(0, 1).toLowerCase() + local.substring(1); } return new QName(NS_COMMON, local); }
From source file:org.apdplat.superword.tools.PdfParser.java
private static void addLineToParagraph(String line, String lastLine, String nextLine, StringBuilder paragraph) { if (StringUtils.isBlank(line)) { return;//ww w. ja v a 2s. c om } if (nextLine != null) { //???? if (Character.isDigit(line.charAt(0)) && Character.isAlphabetic(line.charAt(line.length() - 1)) //? && (StringUtils.isBlank(nextLine) || Character.isDigit(nextLine.charAt(0)) || Character.isUpperCase(nextLine.charAt(0)))) { LOGGER.debug("???" + line); return; } } paragraph.append(line).append(" "); }
From source file:com.opengamma.language.object.ObjectFunctionProvider.java
protected String uncapitalize(final String str) { if (str.length() > 1) { if (Character.isUpperCase(str.charAt(0)) && Character.isUpperCase(str.charAt(1))) { return str; }/*from w w w . j a v a 2 s. c om*/ } return StringUtils.uncapitalize(str); }
From source file:com.espertech.esper.event.bean.PropertyHelper.java
/** * Adds to the given list of property descriptors the mapped properties, ie. * properties that have a getter method taking a single String value as a parameter. * @param clazz to introspect/*from w w w. ja va 2 s . c o m*/ * @param result is the list to add to */ protected static void addMappedProperties(Class clazz, List<InternalEventPropDescriptor> result) { Set<String> uniquePropertyNames = new HashSet<String>(); Method[] methods = clazz.getMethods(); for (int i = 0; i < methods.length; i++) { String methodName = methods[i].getName(); if (!methodName.startsWith("get")) { continue; } String inferredName = methodName.substring(3, methodName.length()); if (inferredName.length() == 0) { continue; } Class<?> parameterTypes[] = methods[i].getParameterTypes(); if (parameterTypes.length != 1) { continue; } if (parameterTypes[0] != String.class) { continue; } String newInferredName = null; // Leave uppercase inferred names such as URL if (inferredName.length() >= 2) { if ((Character.isUpperCase(inferredName.charAt(0))) && (Character.isUpperCase(inferredName.charAt(1)))) { newInferredName = inferredName; } } // camelCase the inferred name if (newInferredName == null) { newInferredName = Character.toString(Character.toLowerCase(inferredName.charAt(0))); if (inferredName.length() > 1) { newInferredName += inferredName.substring(1, inferredName.length()); } } inferredName = newInferredName; // if the property inferred name already exists, don't supply it if (uniquePropertyNames.contains(inferredName)) { continue; } result.add(new InternalEventPropDescriptor(inferredName, methods[i], EventPropertyType.MAPPED)); uniquePropertyNames.add(inferredName); } }
From source file:com.opensymphony.webwork.util.classloader.compilers.eclipse.EclipseJavaCompiler.java
public void compile(final String[] pClazzNames, final ResourceReader pReader, final ResourceStore pStore, final CompilationProblemHandler pProblemHandler) { final Map settingsMap = settings.getMap(); final Set clazzIndex = new HashSet(); ICompilationUnit[] compilationUnits = new ICompilationUnit[pClazzNames.length]; for (int i = 0; i < compilationUnits.length; i++) { final String clazzName = pClazzNames[i]; compilationUnits[i] = new CompilationUnit(pReader, clazzName); clazzIndex.add(clazzName);//from w w w .j a v a2 s .co m log.debug("compiling " + clazzName); } final IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.proceedWithAllProblems(); final IProblemFactory problemFactory = new DefaultProblemFactory(Locale.getDefault()); final INameEnvironment nameEnvironment = new INameEnvironment() { public NameEnvironmentAnswer findType(final char[][] compoundTypeName) { final StringBuffer result = new StringBuffer(); for (int i = 0; i < compoundTypeName.length; i++) { if (i != 0) { result.append('.'); } result.append(compoundTypeName[i]); } return findType(result.toString()); } public NameEnvironmentAnswer findType(final char[] typeName, final char[][] packageName) { final StringBuffer result = new StringBuffer(); for (int i = 0; i < packageName.length; i++) { result.append(packageName[i]); result.append('.'); } result.append(typeName); return findType(result.toString()); } private NameEnvironmentAnswer findType(final String clazzName) { byte[] clazzBytes = pStore.read(clazzName); if (clazzBytes != null) { // log.debug("loading from store " + clazzName); final char[] fileName = clazzName.toCharArray(); try { final ClassFileReader classFileReader = new ClassFileReader(clazzBytes, fileName, true); return new NameEnvironmentAnswer(classFileReader, null); } catch (final ClassFormatException e) { log.error("wrong class format", e); } } else { if (pReader.isAvailable(clazzName.replace('.', '/') + ".java")) { log.debug("compile " + clazzName); ICompilationUnit compilationUnit = new CompilationUnit(pReader, clazzName); return new NameEnvironmentAnswer(compilationUnit, null); } final String resourceName = clazzName.replace('.', '/') + ".class"; final InputStream is = this.getClass().getClassLoader().getResourceAsStream(resourceName); if (is != null) { final byte[] buffer = new byte[8192]; final ByteArrayOutputStream baos = new ByteArrayOutputStream(buffer.length); int count; try { while ((count = is.read(buffer, 0, buffer.length)) > 0) { baos.write(buffer, 0, count); } baos.flush(); clazzBytes = baos.toByteArray(); final char[] fileName = clazzName.toCharArray(); ClassFileReader classFileReader = new ClassFileReader(clazzBytes, fileName, true); return new NameEnvironmentAnswer(classFileReader, null); } catch (final IOException e) { log.error("could not read class", e); } catch (final ClassFormatException e) { log.error("wrong class format", e); } finally { try { baos.close(); } catch (final IOException oe) { log.error("could not close output stream", oe); } try { is.close(); } catch (final IOException ie) { log.error("could not close input stream", ie); } } } } return null; } private boolean isPackage(final String clazzName) { final String resourceName = clazzName.replace('.', '/') + ".class"; final URL resource = this.getClass().getClassLoader().getResource(resourceName); return resource == null; } public boolean isPackage(char[][] parentPackageName, char[] packageName) { final StringBuffer result = new StringBuffer(); if (parentPackageName != null) { for (int i = 0; i < parentPackageName.length; i++) { if (i != 0) { result.append('.'); } result.append(parentPackageName[i]); } } if (Character.isUpperCase(packageName[0])) { return false; } if (parentPackageName != null && parentPackageName.length > 0) { result.append('.'); } result.append(packageName); return isPackage(result.toString()); } public void cleanup() { } }; final ICompilerRequestor compilerRequestor = new ICompilerRequestor() { public void acceptResult(CompilationResult result) { if (result.hasProblems()) { if (pProblemHandler != null) { final IProblem[] problems = result.getProblems(); for (int i = 0; i < problems.length; i++) { final IProblem problem = problems[i]; pProblemHandler.handle(new EclipseCompilationProblem(problem)); } } } if (!result.hasErrors()) { final ClassFile[] clazzFiles = result.getClassFiles(); for (int i = 0; i < clazzFiles.length; i++) { final ClassFile clazzFile = clazzFiles[i]; final char[][] compoundName = clazzFile.getCompoundName(); final StringBuffer clazzName = new StringBuffer(); for (int j = 0; j < compoundName.length; j++) { if (j != 0) { clazzName.append('.'); } clazzName.append(compoundName[j]); } pStore.write(clazzName.toString(), clazzFile.getBytes()); } } } }; pProblemHandler.onStart(); try { final Compiler compiler = new Compiler(nameEnvironment, policy, settingsMap, compilerRequestor, problemFactory); compiler.compile(compilationUnits); } finally { pProblemHandler.onStop(); } }
From source file:org.icgc.dcc.release.job.fathmm.core.FathmmPredictor.java
private static String mapPosition(int seqStart, int seqEnd, int hmmBegin, String align, int substitution) { if (substitution < seqStart || substitution > seqEnd) return null; int start = seqStart - 1; int end = hmmBegin - 1; for (char c : align.toCharArray()) { if (Character.isUpperCase(c) || Character.isLowerCase(c)) start++;/* w ww . j a va 2 s.co m*/ if (Character.isUpperCase(c) || c == '-') end++; if (start == substitution && Character.isUpperCase(c)) return String.valueOf(end); } return null; }
From source file:com.fengduo.bee.commons.util.StringUtils.java
/** * ??/*from ww w . j a va 2 s . c o m*/ * * @return toCamelCase("hello_world") == "helloWorld" toCapitalizeCamelCase("hello_world") == "HelloWorld" * toUnderScoreCase("helloWorld") = "hello_world" */ public static String toUnderScoreCase(String s) { if (s == null) { return null; } StringBuilder sb = new StringBuilder(); boolean upperCase = false; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); boolean nextUpperCase = true; if (i < (s.length() - 1)) { nextUpperCase = Character.isUpperCase(s.charAt(i + 1)); } if ((i > 0) && Character.isUpperCase(c)) { if (!upperCase || !nextUpperCase) { sb.append(SEPARATOR); } upperCase = true; } else { upperCase = false; } sb.append(Character.toLowerCase(c)); } return sb.toString(); }
From source file:org.opencms.search.solr.spellchecking.CmsSolrSpellchecker.java
/** * Converts the suggestions from the Solrj format to JSON format. * * @param response The SpellCheckResponse object containing the spellcheck results. * @return The spellcheck suggestions as JSON object or null if something goes wrong. *///from www. j a v a 2s. c om private JSONObject getConvertedResponseAsJson(SpellCheckResponse response) { if (null == response) { return null; } final JSONObject suggestions = new JSONObject(); final Map<String, Suggestion> solrSuggestions = response.getSuggestionMap(); // Add suggestions to the response for (final String key : solrSuggestions.keySet()) { // Indicator to ignore words that are erroneously marked as misspelled. boolean ignoreWord = false; // Suggestions that are in the form "Xxxx" -> "xxxx" should be ignored. if (Character.isUpperCase(key.codePointAt(0))) { final String lowercaseKey = key.toLowerCase(); // If the suggestion map doesn't contain the lowercased word, ignore this entry. if (!solrSuggestions.containsKey(lowercaseKey)) { ignoreWord = true; } } if (!ignoreWord) { try { // Get suggestions as List final List<String> l = solrSuggestions.get(key).getAlternatives(); suggestions.put(key, l); } catch (JSONException e) { LOG.debug("Exception while converting Solr spellcheckresponse to JSON. ", e); } } } return suggestions; }