Example usage for org.apache.commons.jci.utils ConversionUtils toJavaCasing

List of usage examples for org.apache.commons.jci.utils ConversionUtils toJavaCasing

Introduction

In this page you can find the example usage for org.apache.commons.jci.utils ConversionUtils toJavaCasing.

Prototype

public static String toJavaCasing(final String pName) 

Source Link

Usage

From source file:org.auroraide.server.jci.JavaCompilerFactory.java

/**
 * Tries to guess the class name by convention. So for compilers
 * following the naming convention//from w  ww  . ja  va2s  .c om
 * 
 *   org.apache.commons.jci.compilers.SomeJavaCompiler
 *   
 * you can use the short-hands "some"/"Some"/"SOME". Otherwise
 * you have to provide the full class name. The compiler is
 * getting instanciated via (cached) reflection.
 * 
 * @param pHint
 * @return JavaCompiler or null
 */
public JavaCompiler createCompiler(final String pHint) {

    final String className;
    if (pHint.indexOf('.') < 0) {
        className = "org.auroraide.server.jci.compilers." + ConversionUtils.toJavaCasing(pHint)
                + "JavaCompiler";
    } else {
        className = pHint;
    }

    Class<?> clazz = (Class<?>) classCache.get(className);

    if (clazz == null) {
        try {
            clazz = Class.forName(className);
            classCache.put(className, clazz);
        } catch (ClassNotFoundException e) {
            clazz = null;
        }
    }

    if (clazz == null) {
        return null;
    }

    try {
        return (JavaCompiler) clazz.newInstance();
    } catch (Throwable t) {
        return null;
    }
}