Example usage for org.apache.commons.lang StringUtils uncapitalize

List of usage examples for org.apache.commons.lang StringUtils uncapitalize

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils uncapitalize.

Prototype

public static String uncapitalize(String str) 

Source Link

Document

Uncapitalizes a String changing the first letter to title case as per Character#toLowerCase(char) .

Usage

From source file:com.fiveamsolutions.nci.commons.search.SearchCallback.java

private void dispatchCollectionNestedField(String baseParamName, Method m, Object result)
        throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
    String fieldName = StringUtils.uncapitalize(m.getName().substring("get".length()));
    String paramName = baseParamName + "_" + fieldName;
    SearchOptions searchOptions = new SearchOptions(m);
    validateSettings(searchOptions, result);

    if (result != null) {
        if (result instanceof Collection<?>) {
            processCollectionField((Collection<?>) result, fieldName, baseParamName, searchOptions);
        } else if (!ArrayUtils.isEmpty(searchOptions.getFields())) {
            if (!searchOptions.isHibernateComponent()) {
                nestedJoinClauses.add(String.format("%s.%s %s", baseParamName, fieldName, paramName));
            } else {
                paramName = String.format("%s.%s", baseParamName, fieldName);
            }/*from  w ww . ja va  2  s .c  o m*/
            processFieldWithSubProp(result, fieldName, paramName, searchOptions, true);
        } else if (searchOptions.isNested()) {
            handleNestedCollectionNestedField(baseParamName, result, fieldName, paramName, searchOptions);
        } else {
            // just a simple field
            handleNestedFieldInCollection(paramName, baseParamName, fieldName, searchOptions, result);
        }
    }
}

From source file:mrcg.MRCGInstance.java

private void createListJSPs() throws Exception {
    for (JavaClass jclass : types.values()) {
        if (!(jclass.isEnum() || jclass.isMapping() || skipGui(jclass))) {

            String path = "beans." + jclass.getName() + ".list.";

            List<ListField> listFields = new ArrayList<ListField>();
            List<Object> lfs = getList(path + "fields");
            if (lfs != null && !lfs.isEmpty()) {
                for (Object o : lfs) {
                    String s = StringUtils.trimToEmpty(o.toString());
                    ListField lf = new ListField();
                    if (s.contains(":")) {
                        String[] ss = s.split(":");
                        lf.setName(ss[0]);
                        lf.setLabel(ss[1]);
                    } else {
                        lf.setName(s);/*from   ww  w . j  a  va  2  s  . co m*/
                        lf.setLabel(
                                Utils.toSpacedCamelCase(StringUtils.capitaliseAllWords(s.replace('.', ' '))));
                    }
                    listFields.add(lf);
                }
            } else {
                for (JavaField jf : jclass.getListFields()) {
                    ListField lf = new ListField();
                    if (jf.isReferenceField()) {
                        JavaClass ref = jf.getReferences();
                        lf.setLabel(jf.getNameAsLabel().replace(" Id", ""));
                        String refField = "identifierLabel";
                        if (ref.getIdentifierField() != null) {
                            refField = ref.getIdentifierField().getName();
                        }
                        lf.setName(jf.getName().replace("Id", "") + "." + refField);
                    } else {
                        lf.setLabel(jf.getNameAsLabel());
                        lf.setName(jf.getName());
                    }
                    listFields.add(lf);
                }
            }

            Map<String, Object> map = new HashMap<String, Object>();
            map.put("basePackage", basePackage);
            map.put("classUpper", StringUtils.capitalize(jclass.getName()));
            map.put("classUpperSpaced", Utils.toSpacedCamelCase(StringUtils.capitalize(jclass.getName())));
            map.put("classUpperSpacedPlural",
                    Utils.toSpacedCamelCase(StringUtils.capitalize(Utils.pluralize(jclass.getName()))));
            map.put("classLower", jclass.getName().toLowerCase());
            map.put("classLowerCamel", StringUtils.uncapitalize(jclass.getName()));
            map.put("fields", listFields);
            map.put("tagLibPrefix", tagLibPrefix);
            //            map.put("mappings", convertToJspEditCode(jclass));
            map.put("edit", getBoolean(path + "edit", true));
            map.put("view", getBoolean(path + "view", true));

            File file = new File(webPath + "admin/" + jclass.getName().toLowerCase() + "/list-generated.jsp");
            velocity(file, getResourcePath("list-jsp.vel"), map, true);
        }
    }
}

From source file:adalid.core.wrappers.ArtifactWrapper.java

public String getJavaUncapitalizedName() {
    return StringUtils.uncapitalize(getJavaName());
}

From source file:adalid.commons.util.ObjUtils.java

public static String uncapitalize(Object o) {
    String string = o instanceof String ? ((String) o) : null;
    return string == null ? null : StringUtils.uncapitalize(string);
}

From source file:com.haulmont.cuba.core.sys.FetchGroupManager.java

private List<String> getInterfaceProperties(Class<?> intf) {
    List<String> result = new ArrayList<>();
    for (Method method : intf.getDeclaredMethods()) {
        if (method.getName().startsWith("get") && method.getParameterTypes().length == 0) {
            result.add(StringUtils.uncapitalize(method.getName().substring(3)));
        }/*from  w ww.j a va  2  s . c om*/
    }
    return result;
}

From source file:com.evolveum.midpoint.prism.schema.PrismSchema.java

/**
 * Internal method to create a "nice" element name from the type name.
 *//*from w  ww .  ja  va 2  s .  co  m*/
protected String toElementName(String localTypeName) {
    String elementName = StringUtils.uncapitalize(localTypeName);
    if (elementName.endsWith("Type")) {
        return elementName.substring(0, elementName.length() - 4);
    }
    return elementName;
}

From source file:com.evolveum.midpoint.prism.marshaller.PrismBeanInspector.java

private String getPropertyNameFromGetter(String getterName) {
    if ((getterName.length() > 3) && getterName.startsWith("get")
            && Character.isUpperCase(getterName.charAt(3))) {
        String propPart = getterName.substring(3);
        return StringUtils.uncapitalize(propPart);
    }/*  ww w.  j  a v  a2  s.c  o  m*/
    return getterName;
}

From source file:freemarker.ext.dump.BaseDumpDirective.java

private String getPropertyName(String methodName) {
    String keyName = methodName.replaceAll("^(get|is)", "");
    return StringUtils.uncapitalize(keyName);
}

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

private List<InterceptorDelegate> findInterceptors(XmlWebApplicationContext context) {
    String[] interceptorNames = SpringUtils.getBeanNames(context.getBeanFactory(), ControllerInterceptor.class);
    ArrayList<InterceptorDelegate> interceptors = new ArrayList<InterceptorDelegate>(interceptorNames.length);
    for (String beanName : interceptorNames) {
        ControllerInterceptor interceptor = (ControllerInterceptor) context.getBean(beanName);
        Class<?> userClass = ClassUtils.getUserClass(interceptor);
        if (userClass.isAnnotationPresent(Ignored.class)) {
            if (logger.isDebugEnabled()) {
                logger.debug("Ignored interceptor (Ignored):" + interceptor);
            }/* w  w w. j a  v  a 2 s  .c om*/
            continue;
        }
        if (userClass.isAnnotationPresent(NotForSubModules.class)
                && !context.getBeanFactory().containsBeanDefinition(beanName)) {
            if (logger.isDebugEnabled()) {
                logger.debug("Ignored interceptor (NotForSubModules):" + interceptor);
            }
            continue;
        }
        if (!userClass.getSimpleName().endsWith(RoseConstants.INTERCEPTOR_SUFFIX)) {
            logger.error("", new IllegalArgumentException("Interceptor must be end with '"
                    + RoseConstants.INTERCEPTOR_SUFFIX + "': " + userClass.getName()));
            continue;
        }
        InterceptorBuilder builder = new InterceptorBuilder(interceptor);
        Interceptor annotation = userClass.getAnnotation(Interceptor.class);
        if (annotation != null) {
            builder.oncePerRequest(annotation.oncePerRequest());
        }
        String interceporName;
        if (beanName.startsWith(AUTO_BEAN_NAME_PREFIX)) {
            interceporName = StringUtils.removeEnd(StringUtils.uncapitalize(userClass.getSimpleName()),
                    RoseConstants.INTERCEPTOR_SUFFIX);
        } else {
            interceporName = StringUtils.removeEnd(beanName, RoseConstants.INTERCEPTOR_SUFFIX);
        }
        final String rose = "rose";
        if (interceporName.startsWith(rose)
                && (interceporName.length() == rose.length()
                        || Character.isUpperCase(interceporName.charAt(rose.length())))
                && !userClass.getName().startsWith("net.paoding.rose.")) {
            throw new IllegalArgumentException("illegal interceptor name '" + interceporName + "' for "
                    + userClass.getName() + ": don't starts with 'rose', it's reserved");
        }

        builder.name(interceporName);

        InterceptorDelegate wrapper = builder.build();
        interceptors.add(wrapper);
        if (logger.isDebugEnabled()) {
            int priority = 0;
            if (interceptor instanceof Ordered) {
                priority = ((Ordered) interceptor).getPriority();
            }
            logger.debug("recognized interceptor[priority=" + priority + "]: " // \r\n
                    + wrapper.getName() + "=" + userClass.getName());
        }
    }
    Collections.sort(interceptors);
    throwExceptionIfDuplicatedNames(interceptors);
    return interceptors;
}

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

private List<InterceptorDelegate> findInterceptors(XmlWebApplicationContext context) {
    String[] interceptorNames = SpringUtils.getBeanNames(context.getBeanFactory(), ControllerInterceptor.class);
    ArrayList<InterceptorDelegate> interceptors = new ArrayList<InterceptorDelegate>(interceptorNames.length);
    for (String beanName : interceptorNames) {
        ControllerInterceptor interceptor = (ControllerInterceptor) context.getBean(beanName);
        Class<?> userClass = ClassUtils.getUserClass(interceptor);
        if (userClass.isAnnotationPresent(Ignored.class)) {
            if (logger.isDebugEnabled()) {
                logger.debug("Ignored interceptor (Ignored):" + interceptor);
            }/*  w w w.  j  a v  a2  s  . c  om*/
            continue;
        }
        if (userClass.isAnnotationPresent(NotForSubModules.class)
                && !context.getBeanFactory().containsBeanDefinition(beanName)) {
            if (logger.isDebugEnabled()) {
                logger.debug("Ignored interceptor (NotForSubModules):" + interceptor);
            }
            continue;
        }
        if (!userClass.getSimpleName().endsWith(BlitzConstants.INTERCEPTOR_SUFFIX)) {
            logger.error("", new IllegalArgumentException("Interceptor must be end with '"
                    + BlitzConstants.INTERCEPTOR_SUFFIX + "': " + userClass.getName()));
            continue;
        }
        InterceptorBuilder builder = new InterceptorBuilder(interceptor);
        Interceptor annotation = userClass.getAnnotation(Interceptor.class);
        if (annotation != null) {
            builder.oncePerRequest(annotation.oncePerRequest());
        }
        String interceporName;
        if (beanName.startsWith(AUTO_BEAN_NAME_PREFIX)) {
            interceporName = StringUtils.removeEnd(StringUtils.uncapitalize(userClass.getSimpleName()),
                    BlitzConstants.INTERCEPTOR_SUFFIX);
        } else {
            interceporName = StringUtils.removeEnd(beanName, BlitzConstants.INTERCEPTOR_SUFFIX);
        }
        final String rose = "rose";
        if (interceporName.startsWith(rose)
                && (interceporName.length() == rose.length()
                        || Character.isUpperCase(interceporName.charAt(rose.length())))
                && !userClass.getName().startsWith("net.paoding.rose.")) {
            throw new IllegalArgumentException("illegal interceptor name '" + interceporName + "' for "
                    + userClass.getName() + ": don't starts with 'rose', it's reserved");
        }

        builder.name(interceporName);

        InterceptorDelegate wrapper = builder.build();
        interceptors.add(wrapper);
        if (logger.isDebugEnabled()) {
            int priority = 0;
            if (interceptor instanceof Ordered) {
                priority = ((Ordered) interceptor).getPriority();
            }
            logger.debug("recognized interceptor[priority=" + priority + "]: " // \r\n
                    + wrapper.getName() + "=" + userClass.getName());
        }
    }
    Collections.sort(interceptors);
    throwExceptionIfDuplicatedNames(interceptors);
    return interceptors;
}