Example usage for org.springframework.util StringUtils uncapitalize

List of usage examples for org.springframework.util StringUtils uncapitalize

Introduction

In this page you can find the example usage for org.springframework.util StringUtils uncapitalize.

Prototype

public static String uncapitalize(String str) 

Source Link

Document

Uncapitalize a String , changing the first letter to lower case as per Character#toLowerCase(char) .

Usage

From source file:org.sarons.spring4me.web.servlet.DispatcherServlet.java

private void prepareFlashMapForWidget(HttpServletRequest request, Object handler) {
    if (handler instanceof HandlerMethod) {
        HandlerMethod handlerMethod = (HandlerMethod) handler;
        ///*from   w ww .  j  av  a 2s  .  c o m*/
        Widget widget = AnnotationUtils.getAnnotation(handlerMethod.getBeanType(), Widget.class);
        if (widget != null) {
            //
            String widgetName = widget.value();
            if (!StringUtils.hasText(widgetName)) {
                String targetWidget = handlerMethod.getBeanType().getSimpleName();
                widgetName = StringUtils.uncapitalize(targetWidget);
            }
            //
            FlashMap flashMap = RequestContextUtils.getOutputFlashMap(request);
            flashMap.setTargetRequestPath(widgetName);
            FlashMapManager flashMapManager = RequestContextUtils.getFlashMapManager(request);
            flashMapManager.saveOutputFlashMap(flashMap, request, null);
        }
    }
}

From source file:com.agileapes.couteau.context.spring.event.impl.AbstractMappedEventsTranslationScheme.java

@Override
public ApplicationEvent translate(Event originalEvent) throws EventTranslationException {
    final Class<? extends ApplicationEvent> eventClass;
    try {//www .  j a v  a2  s . com
        eventClass = getTargetEvent(originalEvent.getClass());
    } catch (ClassNotFoundException e) {
        throw new EventTranslationException("Failed to locate target class for event", e);
    }
    final ApplicationEvent applicationEvent;
    try {
        applicationEvent = eventClass.getConstructor(Object.class).newInstance(originalEvent.getSource());
    } catch (Exception e) {
        throw new EventTranslationException(
                "Failed to instantiate event from " + eventClass.getCanonicalName());
    }
    for (Method method : originalEvent.getClass().getMethods()) {
        if (!GenericTranslationScheme.isGetter(method)) {
            continue;
        }
        final String fieldName = StringUtils
                .uncapitalize(method.getName().substring(method.getName().startsWith("get") ? 3 : 2));
        final Field field = ReflectionUtils.findField(eventClass, fieldName);
        if (field == null || !field.getType().isAssignableFrom(method.getReturnType())) {
            continue;
        }
        field.setAccessible(true);
        try {
            field.set(applicationEvent, method.invoke(originalEvent));
        } catch (Exception e) {
            throw new EventTranslationException("Failed to set property: " + fieldName, e);
        }
    }
    return applicationEvent;
}

From source file:org.web4thejob.context.ContextUtil.java

@SuppressWarnings("unchecked")
public static <T extends Setting<Serializable>> T getSetting(SettingEnum id, Serializable value) {
    return (T) rootContext.getBean(StringUtils.uncapitalize(DefaultSetting.class.getSimpleName()), id, value);
}

From source file:org.web4thejob.context.ContextUtil.java

@SuppressWarnings("unchecked")
public static <T extends Message> T getMessage(MessageEnum id, Object sender) {
    return (T) rootContext.getBean(StringUtils.uncapitalize(DefaultMessage.class.getSimpleName()), id, sender);
}

From source file:org.synyx.hades.dao.query.QueryMethod.java

/**
 * Returns whether the given field is valid field name and thus a persistent
 * field to the underlying domain class.
 * //from  w w  w  . j av a 2  s .  c  o m
 * @param fieldName
 * @return
 */
boolean isValidField(String fieldName) {

    Class<?> returnType = ClassUtils.getReturnedDomainClass(method);

    if (null != ReflectionUtils.findMethod(returnType, "get" + fieldName)) {
        return true;
    }

    return null != ReflectionUtils.findField(returnType, StringUtils.uncapitalize(fieldName));
}

From source file:org.web4thejob.context.ContextUtil.java

@SuppressWarnings("unchecked")
public static <T extends Message> T getMessage(MessageEnum id, Object sender,
        Map<MessageArgEnum, Object> args) {
    return (T) rootContext.getBean(StringUtils.uncapitalize(DefaultMessage.class.getSimpleName()), id, sender,
            args);/*from w w  w.j av a  2 s  .  c  o m*/
}

From source file:org.zalando.stups.spring.cloud.netflix.feign.OAuth2FeignClientsRegsitrar.java

private BeanDefinitionHolder createBeanDefinition(final AnnotationMetadata annotationMetadata) {
    Map<String, Object> attributes = annotationMetadata
            .getAnnotationAttributes(FeignClient.class.getCanonicalName());

    String className = annotationMetadata.getClassName();
    BeanDefinitionBuilder definition = BeanDefinitionBuilder
            .genericBeanDefinition(TokensFeignClientFactoryBean.class);

    validate(attributes);//w ww  .j a  va 2  s . c om
    definition.addPropertyValue("url", getUrl(attributes));
    definition.addPropertyValue("name", getServiceId(attributes));
    definition.addPropertyValue("type", className);

    String beanName = StringUtils.uncapitalize(className.substring(className.lastIndexOf(".") + 1));
    return new BeanDefinitionHolder(definition.getBeanDefinition(), beanName);
}

From source file:org.web4thejob.web.dialog.DefaultSelectPanelDialog.java

private void drawPanelsTab() {
    Tab tab = new Tab(L10N_TAB_TITLE_PANELS.toString());
    tab.setParent(tabbox.getTabs());// w w  w . j  a va2  s .  c o  m
    Tabpanel tabpanel = new Tabpanel();
    tabpanel.setParent(tabbox.getTabpanels());

    listboxPanels = new Listbox();
    listboxPanels.setParent(tabpanel);
    listboxPanels.setHflex("true");
    listboxPanels.setVflex("true");
    listboxPanels.setSpan(true);
    listboxPanels.addEventListener(Events.ON_DOUBLE_CLICK, this);

    new Listhead().setParent(listboxPanels);
    listboxPanels.getListhead().setSizable(true);
    Listheader header = new Listheader(L10N_HEADER_NAME.toString());
    header.setParent(listboxPanels.getListhead());
    header.setSort("auto");
    header = new Listheader(L10N_HEADER_DESCRIPTION.toString());
    header.setParent(listboxPanels.getListhead());
    header.setSort("auto");
    header = new Listheader(L10N_HEADER_TYPE.toString());
    header.setParent(listboxPanels.getListhead());
    header.setSort("auto");

    for (org.web4thejob.web.panel.Panel panel : ContextUtil.getSessionContext().getPanels(ContentPanel.class)) {
        if (panel != null) {
            Listitem item = new Listitem();
            item.setParent(listboxPanels);
            item.setAttribute(ATTRIB_BEANID, panel.getBeanName());

            String name;
            String descr;
            if (panel.isPersisted()) {
                PanelDefinition panelDefinition = ORMUtil.getPanelDefinition(panel.getBeanName());
                name = panelDefinition.getName();
                descr = panelDefinition.getDescription();
            } else {
                name = panel.getBeanName();
                descr = L10N_MSG_SYSTEM_DEFINED.toString();
            }

            boolean featured = name.equals(StringUtils.uncapitalize(DefaultListViewPanel.class.getSimpleName()))
                    || name.equals(
                            StringUtils.uncapitalize(DefaultMutableEntityViewPanel.class.getSimpleName()));

            Listcell cell = new Listcell(name);
            cell.setParent(item);
            cell.setImage(panel.getImage());
            if (featured) {
                cell.setStyle("font-weight:bold;font-style:italic;");
            }

            cell = new Listcell(descr);
            cell.setParent(item);
            if (featured) {
                cell.setStyle("font-weight:bold;font-style:italic;");
            }

            cell = new Listcell(panel.getClass().getSimpleName());
            cell.setParent(item);
            if (featured) {
                cell.setStyle("font-weight:bold;font-style:italic;");
            }

        }
    }
}

From source file:org.web4thejob.context.ContextUtil.java

@SuppressWarnings("unchecked")
public static <T extends Message> T getMessage(MessageEnum id, Object sender, MessageArgEnum key,
        Object value) {/*from   w  w  w .j av  a2 s .c  o m*/
    return (T) rootContext.getBean(StringUtils.uncapitalize(DefaultMessage.class.getSimpleName()), id, sender,
            key, value);
}

From source file:com.agileapes.couteau.context.spring.event.impl.AbstractMappedEventsTranslationScheme.java

@Override
public void fillIn(Event originalEvent, ApplicationEvent translated) throws EventTranslationException {
    for (Method method : originalEvent.getClass().getMethods()) {
        if (!method.getName().matches("set[A-Z].*") || !Modifier.isPublic(method.getModifiers())
                || !method.getReturnType().equals(void.class) || method.getParameterTypes().length != 1) {
            continue;
        }//from  www  . ja v a 2s  . co m
        final String propertyName = StringUtils.uncapitalize(method.getName().substring(3));
        final Field field = ReflectionUtils.findField(translated.getClass(), propertyName);
        if (field == null || !method.getParameterTypes()[0].isAssignableFrom(field.getType())) {
            continue;
        }
        field.setAccessible(true);
        try {
            method.invoke(originalEvent, field.get(translated));
        } catch (Exception e) {
            throw new EventTranslationException("Failed to set property on original event: " + propertyName, e);
        }
    }
}