Example usage for java.lang Character isUpperCase

List of usage examples for java.lang Character isUpperCase

Introduction

In this page you can find the example usage for java.lang Character isUpperCase.

Prototype

public static boolean isUpperCase(int codePoint) 

Source Link

Document

Determines if the specified character (Unicode code point) is an uppercase character.

Usage

From source file:com.webcohesion.enunciate.modules.php_xml_client.PHPXMLClientModule.java

protected boolean usesUnmappableElements() {
    boolean usesUnmappableElements = false;

    if (this.jaxbModule != null && this.jaxbModule.getJaxbContext() != null
            && !this.jaxbModule.getJaxbContext().getSchemas().isEmpty()) {
        for (SchemaInfo schemaInfo : this.jaxbModule.getJaxbContext().getSchemas().values()) {
            for (TypeDefinition complexType : schemaInfo.getTypeDefinitions()) {
                if (!Character.isUpperCase(complexType.getClientSimpleName().charAt(0))) {
                    warn("%s: PHP requires your class name to be upper-case. Please rename the class or apply the @org.codehaus.enunciate.ClientName annotation to the class.",
                            positionOf(complexType));
                    usesUnmappableElements = true;
                }//from  w ww . j  ava2  s. c om

                for (Element element : complexType.getElements()) {
                    if (element instanceof ElementRef && element.isElementRefs()) {
                        info("%s: The PHP client library doesn't fully support the @XmlElementRefs annotation. The items in the collection will be read-only and will only be available to PHP clients in the form of a Hash. Consider redesigning using a collection of a single type.",
                                positionOf(element));
                    } else if (element.getAnnotation(XmlElements.class) != null) {
                        info("%s: The PHP client library doesn't fully support the @XmlElements annotation. The items in the collection will be read-only and will only be available to PHP clients in the form of a Hash. Consider redesigning using a collection of a single type.",
                                positionOf(element));
                    }
                }
            }
        }
    }

    return usesUnmappableElements;
}

From source file:com.smart.utils.ReflectionUtils.java

/**
 * ?pojoset/*ww  w . ja  v  a 2 s . co m*/
 * 
 * @param fieldName
 * @return
 */
public static String getSetMethodName(String fieldName) {
    StringBuffer result = new StringBuffer("set");
    String firstChar = fieldName.substring(0, 1);
    char firstCh = fieldName.charAt(0);
    // if(firstCh)
    if (Character.isUpperCase(firstCh)) {
        result.append(firstCh);
    } else {
        result.append(firstChar.toUpperCase());

    }
    result.append(fieldName.substring(1, fieldName.length()));
    return result.toString();
}

From source file:de.micromata.genome.gwiki.auth.GWikiSimpleUserAuthorization.java

/**
 * /*w w w  .j  a v a  2  s  .  com*/
 * @param plainText
 * @return possible combinations of password.
 */
public static long getPasswortCombinations(String plainText) {
    if (plainText == null) {
        return 0;
    }
    int r = 0;
    boolean lc = false;
    boolean uc = false;
    boolean dig = false;
    boolean other = false;
    char[] chars = plainText.toCharArray();
    for (int c : chars) {
        if (Character.isLowerCase(c) == true) {
            if (lc == false) {
                r += 26;
            }
            lc = true;
        } else if (Character.isUpperCase(c) == true) {
            if (uc == false) {
                r += 26;
                uc = true;
            }
        } else if (Character.isDigit(c) == true) {
            if (dig == false) {
                r += 10;
                dig = true;
            }
        } else {
            if (other == false) {
                r += 50;
                other = true;
            }
        }
    }
    return (long) Math.pow(r, plainText.length());
}

From source file:org.locationtech.udig.processingtoolbox.ToolboxView.java

@SuppressWarnings("nls")
private String getWindowTitle(String processName) {
    String windowTitle = Character.toUpperCase(processName.charAt(0)) + processName.substring(1);
    if (!processName.contains("ST_")) {
        if (windowTitle.substring(2, 3).equalsIgnoreCase("_")) {
            windowTitle = windowTitle.substring(3);
        }/* ww w.  j  a  v a  2 s  . c o m*/

        StringBuffer sb = new StringBuffer();
        for (int index = 0; index < windowTitle.length(); index++) {
            char cat = windowTitle.charAt(index);
            if (index > 0 && Character.isUpperCase(cat)) {
                sb.append(" ").append(cat);
            } else {
                sb.append(cat);
            }
        }
        return sb.toString();
    } else {
        return windowTitle;
    }
}

From source file:com.puppetlabs.geppetto.pp.dsl.contentassist.PPProposalsGenerator.java

private String toInitialUpperCase(String s) {
    if (s == null || s.length() < 1)
        return s;
    char c = s.charAt(0);
    if (Character.isUpperCase(c))
        return s;
    return Character.toString(c).toUpperCase() + s.substring(1);
}

From source file:net.paoding.rose.web.impl.module.ModulesBuilderImpl.java

private boolean checkController(final XmlWebApplicationContext context, String beanName, ModuleImpl module)
        throws IllegalAccessException {
    AbstractBeanDefinition beanDefinition = (AbstractBeanDefinition) context.getBeanFactory()
            .getBeanDefinition(beanName);
    String beanClassName = beanDefinition.getBeanClassName();
    String controllerSuffix = null;
    for (String suffix : RoseConstants.CONTROLLER_SUFFIXES) {
        if (beanClassName.length() > suffix.length() && beanClassName.endsWith(suffix)) {
            if (suffix.length() == 1 && Character
                    .isUpperCase(beanClassName.charAt(beanClassName.length() - suffix.length() - 1))) {
                continue;
            }/*from   w  w w . ja v a2s  .c o m*/
            controllerSuffix = suffix;
            break;
        }
    }
    if (controllerSuffix == null) {
        if (beanDefinition.hasBeanClass()) {
            Class<?> beanClass = beanDefinition.getBeanClass();
            if (beanClass.isAnnotationPresent(Path.class)) {
                throw new IllegalArgumentException(
                        "@" + Path.class.getSimpleName() + " is only allowed in Resource/Controller, "
                                + "is it a Resource/Controller? wrong spelling? : " + beanClassName);
            }
        }
        // ?l?r?uer?or???
        if (beanClassName.endsWith("Controler") || beanClassName.endsWith("Controllor")
                || beanClassName.endsWith("Resouce") || beanClassName.endsWith("Resorce")) {
            // ?throw???
            logger.error("", new IllegalArgumentException(
                    "invalid class name end wrong spelling? : " + beanClassName));
        }
        return false;
    }
    String[] controllerPaths = null;
    if (!beanDefinition.hasBeanClass()) {
        try {
            beanDefinition.resolveBeanClass(Thread.currentThread().getContextClassLoader());
        } catch (ClassNotFoundException e) {
            throw new CannotLoadBeanClassException("", beanName, beanDefinition.getBeanClassName(), e);
        }
    }
    final Class<?> clazz = beanDefinition.getBeanClass();
    final String controllerName = StringUtils.removeEnd(ClassUtils.getShortNameAsProperty(clazz),
            controllerSuffix);
    Path reqMappingAnnotation = clazz.getAnnotation(Path.class);
    if (reqMappingAnnotation != null) {
        controllerPaths = reqMappingAnnotation.value();
    }
    if (controllerPaths != null) {
        // controllerPaths.length==0path?controller
        for (int i = 0; i < controllerPaths.length; i++) {
            if ("#".equals(controllerPaths[i])) {
                controllerPaths[i] = "/" + controllerName;
            } else if (controllerPaths[i].equals("/")) {
                controllerPaths[i] = "";
            } else if (controllerPaths[i].length() > 0 && controllerPaths[i].charAt(0) != '/') {
                controllerPaths[i] = "/" + controllerPaths[i];
            }
            if (controllerPaths[i].length() > 1 && controllerPaths[i].endsWith("/")) {
                if (controllerPaths[i].endsWith("//")) {
                    throw new IllegalArgumentException("invalid path '" + controllerPaths[i]
                            + "' for controller " + beanClassName + ": don't end with more than one '/'");
                }
                controllerPaths[i] = controllerPaths[i].substring(0, controllerPaths[i].length() - 1);
            }
        }
    } else {
        // TODO: ?0.91.0?201007??
        if (controllerName.equals("index") || controllerName.equals("home")
                || controllerName.equals("welcome")) {
            // ??IndexController/HomeController/WelcomeController@Path("")
            throw new IllegalArgumentException("please add @Path(\"\") to " + clazz.getName());
        } else {
            controllerPaths = new String[] { "/" + controllerName };
        }
    }
    // Controller??Context??
    // Context???
    Object controller = context.getBean(beanName);
    module.addController(//
            controllerPaths, clazz, controllerName, controller);
    if (Proxy.isProxyClass(controller.getClass())) {
        if (logger.isDebugEnabled()) {
            logger.debug("module '" + module.getMappingPath() + "': add controller "
                    + Arrays.toString(controllerPaths) + "= proxy of " + clazz.getName());
        }
    } else {
        if (logger.isDebugEnabled()) {
            logger.debug("module '" + module.getMappingPath() //
                    + "': add controller " + Arrays.toString(controllerPaths) + "= "
                    + controller.getClass().getName());
        }
    }
    return true;
}

From source file:org.jraf.irondad.handler.pixgame.PixGameHandler.java

private static String rot13(String s) {
    int len = s.length();
    StringBuilder res = new StringBuilder(len);
    for (int i = 0; i < len; i++) {
        char ch = s.charAt(i);
        if (!Character.isLetter(ch)) {
            res.append(ch);// www  .j  a v  a  2s  .  c  o m
        } else if (Character.isUpperCase(ch)) {
            res.append((char) ((ch - 'A' + 13) % 26 + 'A'));
        } else {
            res.append((char) ((ch - 'a' + 13) % 26 + 'a'));
        }
    }
    return res.toString();
}

From source file:com.laxser.blitz.web.impl.module.ModulesBuilderImpl.java

private boolean checkController(final XmlWebApplicationContext context, String beanName, ModuleImpl module)
        throws IllegalAccessException {
    AbstractBeanDefinition beanDefinition = (AbstractBeanDefinition) context.getBeanFactory()
            .getBeanDefinition(beanName);
    String beanClassName = beanDefinition.getBeanClassName();
    String controllerSuffix = null;
    for (String suffix : BlitzConstants.CONTROLLER_SUFFIXES) {
        if (beanClassName.length() > suffix.length() && beanClassName.endsWith(suffix)) {
            if (suffix.length() == 1 && Character
                    .isUpperCase(beanClassName.charAt(beanClassName.length() - suffix.length() - 1))) {
                continue;
            }
            controllerSuffix = suffix;/* w ww.j a v a  2s  .  com*/
            break;
        }
    }
    if (controllerSuffix == null) {
        if (beanDefinition.hasBeanClass()) {
            Class<?> beanClass = beanDefinition.getBeanClass();
            if (beanClass.isAnnotationPresent(Path.class)) {
                throw new IllegalArgumentException(
                        "@" + Path.class.getSimpleName() + " is only allowed in Resource/Controller, "
                                + "is it a Resource/Controller? wrong spelling? : " + beanClassName);
            }
        }
        // ?l?r?uer?or???
        if (beanClassName.endsWith("Controler") || beanClassName.endsWith("Controllor")
                || beanClassName.endsWith("Resouce") || beanClassName.endsWith("Resorce")) {
            // ?throw???
            logger.error("", new IllegalArgumentException(
                    "invalid class name end wrong spelling? : " + beanClassName));
        }
        return false;
    }
    String[] controllerPaths = null;
    if (!beanDefinition.hasBeanClass()) {
        try {
            beanDefinition.resolveBeanClass(Thread.currentThread().getContextClassLoader());
        } catch (ClassNotFoundException e) {
            throw new CannotLoadBeanClassException("", beanName, beanDefinition.getBeanClassName(), e);
        }
    }
    final Class<?> clazz = beanDefinition.getBeanClass();
    final String controllerName = StringUtils.removeEnd(ClassUtils.getShortNameAsProperty(clazz),
            controllerSuffix);
    Path reqMappingAnnotation = clazz.getAnnotation(Path.class);
    if (reqMappingAnnotation != null) {
        controllerPaths = reqMappingAnnotation.value();
    }
    if (controllerPaths != null) {
        // controllerPaths.length==0path?controller
        for (int i = 0; i < controllerPaths.length; i++) {
            if ("#".equals(controllerPaths[i])) {
                controllerPaths[i] = "/" + controllerName;
            } else if (controllerPaths[i].equals("/")) {
                controllerPaths[i] = "";
            } else if (controllerPaths[i].length() > 0 && controllerPaths[i].charAt(0) != '/') {
                controllerPaths[i] = "/" + controllerPaths[i];
            }
            if (controllerPaths[i].length() > 1 && controllerPaths[i].endsWith("/")) {
                if (controllerPaths[i].endsWith("//")) {
                    throw new IllegalArgumentException("invalid path '" + controllerPaths[i]
                            + "' for controller " + beanClassName + ": don't end with more than one '/'");
                }
                controllerPaths[i] = controllerPaths[i].substring(0, controllerPaths[i].length() - 1);
            }
        }
    } else {
        // TODO: ?0.91.0?201007??
        if (controllerName.equals("index") || controllerName.equals("home")
                || controllerName.equals("welcome")) {
            // ??IndexController/HomeController/WelcomeController@Path("")
            throw new IllegalArgumentException("please add @Path(\"\") to " + clazz.getName());
        } else {
            controllerPaths = new String[] { "/" + controllerName };
        }
    }
    // Controller??Context??
    // Context???
    Object controller = context.getBean(beanName);
    module.addController(//
            controllerPaths, clazz, controllerName, controller);
    if (Proxy.isProxyClass(controller.getClass())) {
        if (logger.isDebugEnabled()) {
            logger.debug("module '" + module.getMappingPath() + "': add controller "
                    + Arrays.toString(controllerPaths) + "= proxy of " + clazz.getName());
        }
    } else {
        if (logger.isDebugEnabled()) {
            logger.debug("module '" + module.getMappingPath() //
                    + "': add controller " + Arrays.toString(controllerPaths) + "= "
                    + controller.getClass().getName());
        }
    }
    return true;
}

From source file:org.apache.cocoon.components.language.programming.java.EclipseJavaCompiler.java

public boolean compile() throws IOException {
    final String targetClassName = makeClassName(sourceFile);
    final ClassLoader classLoader = ClassUtils.getClassLoader();
    String[] fileNames = new String[] { sourceFile };
    String[] classNames = new String[] { targetClassName };
    class CompilationUnit implements ICompilationUnit {

        String className;//from ww  w  .j  ava  2s. c om
        String sourceFile;

        CompilationUnit(String sourceFile, String className) {
            this.className = className;
            this.sourceFile = sourceFile;
        }

        public char[] getFileName() {
            return className.toCharArray();
        }

        public char[] getContents() {
            char[] result = null;
            FileReader fr = null;
            try {
                fr = new FileReader(sourceFile);
                Reader reader = new BufferedReader(fr);
                if (reader != null) {
                    char[] chars = new char[8192];
                    StringBuffer buf = new StringBuffer();
                    int count;
                    while ((count = reader.read(chars, 0, chars.length)) > 0) {
                        buf.append(chars, 0, count);
                    }
                    result = new char[buf.length()];
                    buf.getChars(0, result.length, result, 0);
                }
            } catch (IOException e) {
                handleError(className, -1, -1, e.getMessage());
            }
            return result;
        }

        public char[] getMainTypeName() {
            int dot = className.lastIndexOf('.');
            if (dot > 0) {
                return className.substring(dot + 1).toCharArray();
            }
            return className.toCharArray();
        }

        public char[][] getPackageName() {
            StringTokenizer izer = new StringTokenizer(className, ".");
            char[][] result = new char[izer.countTokens() - 1][];
            for (int i = 0; i < result.length; i++) {
                String tok = izer.nextToken();
                result[i] = tok.toCharArray();
            }
            return result;
        }
    }

    final INameEnvironment env = new INameEnvironment() {

        public NameEnvironmentAnswer findType(char[][] compoundTypeName) {
            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(char[] typeName, char[][] packageName) {
            StringBuffer result = new StringBuffer();
            for (int i = 0; i < packageName.length; i++) {
                if (i > 0) {
                    result.append(".");
                }
                result.append(packageName[i]);
            }
            result.append(".");
            result.append(typeName);
            return findType(result.toString());
        }

        private NameEnvironmentAnswer findType(String className) {

            try {
                if (className.equals(targetClassName)) {
                    ICompilationUnit compilationUnit = new CompilationUnit(sourceFile, className);
                    return new NameEnvironmentAnswer(compilationUnit);
                }
                String resourceName = className.replace('.', '/') + ".class";
                InputStream is = classLoader.getResourceAsStream(resourceName);
                if (is != null) {
                    byte[] classBytes;
                    byte[] buf = new byte[8192];
                    ByteArrayOutputStream baos = new ByteArrayOutputStream(buf.length);
                    int count;
                    while ((count = is.read(buf, 0, buf.length)) > 0) {
                        baos.write(buf, 0, count);
                    }
                    baos.flush();
                    classBytes = baos.toByteArray();
                    char[] fileName = className.toCharArray();
                    ClassFileReader classFileReader = new ClassFileReader(classBytes, fileName, true);
                    return new NameEnvironmentAnswer(classFileReader);
                }
            } catch (IOException exc) {
                handleError(className, -1, -1, exc.getMessage());
            } catch (org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException exc) {
                handleError(className, -1, -1, exc.getMessage());
            }
            return null;
        }

        private boolean isPackage(String result) {
            if (result.equals(targetClassName)) {
                return false;
            }
            String resourceName = result.replace('.', '/') + ".class";
            InputStream is = classLoader.getResourceAsStream(resourceName);
            return is == null;
        }

        public boolean isPackage(char[][] parentPackageName, char[] packageName) {
            StringBuffer result = new StringBuffer();
            if (parentPackageName != null) {
                for (int i = 0; i < parentPackageName.length; i++) {
                    if (i > 0) {
                        result.append(".");
                    }
                    result.append(parentPackageName[i]);
                }
            }
            String str = new String(packageName);
            if (Character.isUpperCase(str.charAt(0)) && !isPackage(result.toString())) {
                return false;
            }
            result.append(".");
            result.append(str);
            return isPackage(result.toString());
        }

        public void cleanup() {
            // EMPTY
        }
    };
    final IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.proceedWithAllProblems();
    final Map settings = new HashMap(9);
    settings.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE);
    settings.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE);
    settings.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.IGNORE);
    settings.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.IGNORE);
    if (sourceEncoding != null) {
        settings.put(CompilerOptions.OPTION_Encoding, sourceEncoding);
    }
    if (debug) {
        settings.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
    }
    // Set the sourceCodeVersion
    switch (this.compilerComplianceLevel) {
    case 150:
        settings.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5);
        settings.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5);
        break;
    case 140:
        settings.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4);
        break;
    default:
        settings.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_3);
    }
    // Set the target platform
    switch (SystemUtils.JAVA_VERSION_INT) {
    case 150:
        settings.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5);
        break;
    case 140:
        settings.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4);
        break;
    default:
        settings.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_3);
    }
    final IProblemFactory problemFactory = new DefaultProblemFactory(Locale.getDefault());

    final ICompilerRequestor requestor = new ICompilerRequestor() {
        public void acceptResult(CompilationResult result) {
            try {
                if (result.hasErrors()) {
                    IProblem[] errors = result.getErrors();
                    for (int i = 0; i < errors.length; i++) {
                        IProblem error = errors[i];
                        String name = new String(errors[i].getOriginatingFileName());
                        handleError(name, error.getSourceLineNumber(), -1, error.getMessage());
                    }
                } else {
                    ClassFile[] classFiles = result.getClassFiles();
                    for (int i = 0; i < classFiles.length; i++) {
                        ClassFile classFile = classFiles[i];
                        char[][] compoundName = classFile.getCompoundName();
                        StringBuffer className = new StringBuffer();
                        for (int j = 0; j < compoundName.length; j++) {
                            if (j > 0) {
                                className.append(".");
                            }
                            className.append(compoundName[j]);
                        }
                        byte[] bytes = classFile.getBytes();
                        String outFile = destDir + "/" + className.toString().replace('.', '/') + ".class";
                        FileOutputStream fout = new FileOutputStream(outFile);
                        BufferedOutputStream bos = new BufferedOutputStream(fout);
                        bos.write(bytes);
                        bos.close();
                    }
                }
            } catch (IOException exc) {
                exc.printStackTrace();
            }
        }
    };
    ICompilationUnit[] compilationUnits = new ICompilationUnit[classNames.length];
    for (int i = 0; i < compilationUnits.length; i++) {
        String className = classNames[i];
        compilationUnits[i] = new CompilationUnit(fileNames[i], className);
    }
    Compiler compiler = new Compiler(env, policy, settings, requestor, problemFactory);
    compiler.compile(compilationUnits);
    return errors.size() == 0;
}

From source file:org.elasticsearch.hadoop.util.StringUtils.java

public static boolean isLowerCase(CharSequence string) {
    for (int index = 0; index < string.length(); index++) {
        if (Character.isUpperCase(string.charAt(index))) {
            return false;
        }/*from   ww w . j  av a 2  s .  c o m*/
    }
    return true;
}