List of usage examples for org.apache.commons.lang3 StringUtils capitalize
public static String capitalize(final String str)
Capitalizes a String changing the first letter to title case as per Character#toTitleCase(char) .
From source file:org.javabeanstack.util.Strings.java
/** * Convierte el primer carcter de la variable a mayscula. * @param text variable alfanumrica./*from w ww . j a va2 s .com*/ * @return variable con el primer carcter convertido a mayscula. */ public static String capitalize(String text) { if (text == null) { return null; } return StringUtils.capitalize(text); }
From source file:org.jboss.dashboard.commons.misc.ReflectionUtils.java
public static Method getGetter(Object obj, String propertyName) { Method getter = null;//from w w w . j a v a 2 s .c o m String propertyAccessorSuffix = StringUtils.capitalize(propertyName); String getterName = "get" + propertyAccessorSuffix; try { getter = obj.getClass().getMethod(getterName, new Class[0]); } catch (NoSuchMethodException e) { String booleanGetterName = "is" + propertyAccessorSuffix; try { getter = obj.getClass().getMethod(booleanGetterName, new Class[0]); } catch (NoSuchMethodException e1) { } } return getter; }
From source file:org.jboss.dashboard.commons.misc.ReflectionUtils.java
public static Method getSetter(Object obj, Method getter, String propertyName) { Method setter = null;//w ww .j a va2s. c om String propertyAccessorSuffix = StringUtils.capitalize(propertyName); String setterName = "set" + propertyAccessorSuffix; Class returnType = getter.getReturnType(); try { setter = obj.getClass().getMethod(setterName, new Class[] { returnType }); } catch (NoSuchMethodException e) { } return setter; }
From source file:org.jboss.dashboard.ui.components.BeanHandler.java
/** * Get the action name for given action name. If there is a shortcut, it will be returned, otherwise, the same name applies. * * @param actionName action name//from www.j a v a 2 s. c om * @return the action name for given action name */ public String getActionName(String actionName) { actionName = StringUtils.capitalize(actionName); return actionsShortcuts.getProperty(actionName, actionName); }
From source file:org.jboss.dashboard.ui.components.BeanHandler.java
public synchronized CommandResponse handle(CommandRequest request, String action) throws Exception { if (log.isDebugEnabled()) log.debug("Entering handle " + getBeanName() + " action: " + action); // Calculate the action to invoke. action = StringUtils.capitalize(action); action = reverseActionsShortcuts.getProperty(action, action); // Double click control. if (isEnableDoubleClickControl() && !isEnabledForActionHandling()) { // Duplicates can only be prevented in session components, and if they are enabled for that purpose log.warn("Discarding duplicated execution in component " + getBeanName() + ", action: " + action + ". User should be advised not to double click!"); return null; }/*from w w w.j a v a 2 s . c o m*/ // Invoke the component's action and keep track of the execution. CodeBlockTrace trace = new HandlerTrace(this, action).begin(); try { String methodName = "action" + action; beforeInvokeAction(request, action); CommandResponse response = null; Method handlerMethod = this.getClass().getMethod(methodName, new Class[] { CommandRequest.class }); if (log.isDebugEnabled()) log.debug("Invoking method " + methodName + " on " + getBeanName()); response = (CommandResponse) handlerMethod.invoke(this, new Object[] { request }); afterInvokeAction(request, action); if (response == null || !(response instanceof SendStreamResponse)) { setEnabledForActionHandling(false); } if (log.isDebugEnabled()) log.debug("Leaving handle " + getBeanName() + " - " + action); return response; } finally { trace.end(); } }
From source file:org.jboss.dashboard.ui.panel.advancedHTML.HTMLDriverEditFormatter.java
public void service(HttpServletRequest request, HttpServletResponse response) throws FormatterException { HTMLDriver htmlDriver = (HTMLDriver) getPanel().getProvider().getDriver(); String[] langs = getLocaleManager().lookup().getPlatformAvailableLangs(); setAttribute("url", UIServices.lookup().getUrlMarkupGenerator().getLinkToPanelAction(getPanel(), "saveChanges", true)); renderFragment("outputStart"); if (langs != null) { renderFragment("languagesOutputStart"); for (int i = 0; i < langs.length; i++) { String lang = langs[i]; setAttribute("langId", lang); setAttribute("langName", StringUtils.capitalize(LocaleManager.lookup().getLangDisplayName(lang))); setAttribute("langParamName", HTMLDriver.PARAMETER_EDITING_LANG); setAttribute("url", UIServices.lookup().getUrlMarkupGenerator().getLinkToPanelAction(getPanel(), "changeEditingLanguage", HTMLDriver.PARAMETER_EDITING_LANG + "=" + lang, true)); if (htmlDriver.getEditingLanguage(getPanel()).equals(lang)) { renderFragment("selectedLanguageOutput"); } else { renderFragment("languageOutput"); }//www . ja v a 2 s . c o m } renderFragment("languagesOutputEnd"); String content = htmlDriver.getHtmlCode(getPanel()).get(htmlDriver.getEditingLanguage(getPanel())); setAttribute("content", content == null ? "" : content); setAttribute("contentParamName", HTMLDriver.PARAMETER_HTML); renderFragment("output"); } renderFragment("outputEnd"); }
From source file:org.jboss.dashboard.ui.panel.navigation.menu.RenderMenuFormatter.java
protected void renderLanguage(HttpServletRequest request, HttpServletResponse response, MenuDriver menuDriver) { renderOutputStart();/*from w w w . j a va 2 s. co m*/ String[] langs = LocaleManager.lookup().getPlatformAvailableLangs(); List<String> selectedLangIds = menuDriver.getSelectedLangIds(getPanel()); boolean isEditMode = getPanel().getPanelSession().isEditMode(); for (int i = 0; i < langs.length; i++) { String lang = langs[i]; MenuItem menuItem = new LangMenuItem(); menuItem.setId(lang); Map<String, String> text = new HashMap<String, String>(); text.put(LocaleManager.currentLang(), StringUtils.capitalize(LocaleManager.lookup().getLangDisplayName(lang))); menuItem.setText(text); menuItem.setUrl(menuDriver.getChangeLanguageLink(getPanel().getSection(), lang)); menuItem.setSelected(selectedLangIds.contains(lang)); menuItem.setVisible(Boolean.TRUE); if (lang.equals(getLang())) { menuItem.setCurrent(Boolean.TRUE); } else { menuItem.setCurrent(Boolean.FALSE); } renderItem(menuItem, selectedLangIds.contains(MenuDriver.PARAMETER_ALL_ITEMS), isEditMode); } if (isEditMode) renderOutputEndButtons(selectedLangIds.contains(MenuDriver.PARAMETER_ALL_ITEMS), MenuDriver.ATTRIBUTE_SELECTED_LANG); renderOutputEnd(); }
From source file:org.jboss.forge.roaster.model.impl.PropertyImpl.java
private static String methodName(String prefix, String property) { return prefix + StringUtils.capitalize(property); }
From source file:org.jbpm.formModeler.components.editor.FieldTypePropertyFormatter.java
public void service(HttpServletRequest request, HttpServletResponse response) throws FormatterException { Field field = (Field) getParameter("field"); FieldType type = (FieldType) getParameter("type"); try {//from ww w . ja v a 2s . c om String propertyName = field.getFieldName(); // TODO: fix that! if (type.getPropertyNames().contains(propertyName)) { Method getter = type.getClass().getMethod("get" + StringUtils.capitalize(propertyName)); Object typeValue = getter.invoke(type); FieldHandler handler = FormProcessingServices.lookup().getFieldHandlersManager() .getHandler(field.getFieldType()); String displayPage = handler.getPageToIncludeForDisplaying(); setAttribute(FormRenderingFormatter.ATTR_VALUE, typeValue); setAttribute(FormRenderingFormatter.ATTR_NAME, "_$default_" + propertyName); includePage(displayPage); } } catch (Exception e) { log.error("Error: ", e); } }
From source file:org.jbpm.formModeler.core.processing.BindingManagerImpl.java
@Override public Object getPropertyValue(Object obj, String propName) { Object value = null;/*from w w w . ja v a 2s .c o m*/ try { Method getter = obj.getClass().getMethod("get" + StringUtils.capitalize(propName)); value = getter.invoke(obj); return value; } catch (Exception e) { } return value; }