List of usage examples for org.apache.commons.lang StringUtils capitalize
public static String capitalize(String str)
Capitalizes a String changing the first letter to title case as per Character#toTitleCase(char) .
From source file:com.abiquo.server.core.common.GenericEntityTestBase.java
@SuppressWarnings("unchecked") // We have a typecast to a generic class... private <V> Set<ConstraintViolation<?>> executeGetXXXValidationInformationMethod(Class<?> entityClass, String property, Class<V> valueClass, V value) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException { assert entityClass != null; assert !StringUtils.isEmpty(property); assert valueClass != null; Class<?>[] noGroups = new Class[] {}; Method validationInformationMethod = entityClass.getMethod( "get" + StringUtils.capitalize(property) + "ValidationInformation", valueClass, Class[].class); return (Set<ConstraintViolation<?>>) validationInformationMethod.invoke(null, value, noGroups); }
From source file:com.abiquo.model.util.ModelTransformer.java
private static Method getter(final String prefix, final String fieldName, final Class clazz) throws Exception { String name = prefix + StringUtils.capitalize(fieldName); return clazz.getMethod(name, new Class[0]); }
From source file:com.haulmont.cuba.gui.components.actions.RelatedAction.java
@Inject protected void setMessageTools(MessageTools messageTools) { if (messageTools != null) { setCaption(StringUtils.capitalize(messageTools.getPropertyCaption(metaClass, metaProperty.getName()))); }/*w w w . j a va 2 s .c o m*/ }
From source file:msi.gama.lang.gaml.ui.templates.GamlTemplateFactory.java
public static TemplatePersistenceData from(final usage u, final AbstractProto sp) { boolean isExample = false; String name = u.name();// w ww . j a v a 2 s . c om boolean emptyName = name.isEmpty(); String pattern = u.pattern(); if (pattern.isEmpty()) { for (final example e : u.examples()) { if (emptyName) { name = e.value(); emptyName = false; } if (!e.isPattern()) { isExample = true; } // if ( e.isPattern() ) { pattern += Strings.LN + e.value(); // } } } if (pattern.isEmpty()) { return null; } pattern += Strings.LN; String[] path = u.path(); if (path.length == 0) { path = new String[] { StringUtils.capitalize(sp.getName()) }; } String menuPath = ""; for (final String p : path) { menuPath += p + "."; } String menu = u.menu(); if (menu.equals(usage.NULL)) { menu = ISymbolKind.TEMPLATE_MENU[sp.getKind()]; } String desc = u.value(); if (desc.equals(usage.NULL)) { // Trying to build something that makes sense.. desc = menu + " " + name; desc += Strings.LN; final String doc = sp.getDocumentation(); int index = doc.indexOf(". "); if (index == -1) { index = doc.length(); } desc += doc.substring(0, CmnFastMath.min(index, 150)) + " [...]"; } menuPath = menu + "." + menuPath.substring(0, menuPath.length() - 1); if (isExample) { menuPath = "Examples." + menuPath; } final Template template = new Template(name, desc, getContextId(), pattern, true); final TemplatePersistenceData data = new TemplatePersistenceData(template, true, menuPath); return data; }
From source file:info.magnolia.content2bean.impl.TypeMappingImpl.java
/** * Get a adder method. Transforms name to singular. *///w w w . j a va 2s. com public Method getAddMethod(Class<?> type, String name, int numberOfParameters) { name = StringUtils.capitalize(name); Method method = getExactMethod(type, "add" + name, numberOfParameters); if (method == null) { method = getExactMethod(type, "add" + StringUtils.removeEnd(name, "s"), numberOfParameters); } if (method == null) { method = getExactMethod(type, "add" + StringUtils.removeEnd(name, "es"), numberOfParameters); } if (method == null) { method = getExactMethod(type, "add" + StringUtils.removeEnd(name, "ren"), numberOfParameters); } if (method == null) { method = getExactMethod(type, "add" + StringUtils.removeEnd(name, "ies") + "y", numberOfParameters); } return method; }
From source file:de.forsthaus.webui.calendar.model.CalendarDateFormatter.java
/** * This is for the day/week view, means mold="default" .<br> * EN: Mo 09/12 | Dayshort month/day<br> * DE: Mo 12.09 | Tageskuerzel Tag.Monat<br> */// w ww .j a v a 2 s. c om @Override public String getCaptionByDate(Date date, Locale locale, TimeZone timezone) { String sDate = ZksampleDateFormat.getDayMonthFormater().format(date); String day = null; if (date.getDay() == 0) { day = Labels.getLabel("common.dayname.sunday.2"); } else if (date.getDay() == 1) { day = Labels.getLabel("common.dayname.monday.2"); } else if (date.getDay() == 2) { day = Labels.getLabel("common.dayname.tuesday.2"); } else if (date.getDay() == 3) { day = Labels.getLabel("common.dayname.wednesday.2"); } else if (date.getDay() == 4) { day = Labels.getLabel("common.dayname.thursday.2"); } else if (date.getDay() == 5) { day = Labels.getLabel("common.dayname.friday.2"); } else if (date.getDay() == 6) { day = Labels.getLabel("common.dayname.saturday.2"); } day = StringUtils.capitalize(day.toLowerCase()); String result = day + " " + sDate; return result; }
From source file:jp.codic.plugins.netbeans.utils.CodicUtils.java
/** * Convert from default case to pascal case. * * @param text// w w w .j av a 2 s . c om * @return pascal case text */ public static String toPascalCase(String text) { if (StringUtils.isEmpty(text)) { return text; } StringBuilder sb = new StringBuilder(); String[] words = toWords(text); for (String word : words) { sb.append(StringUtils.capitalize(word)); } return sb.toString(); }
From source file:com.ecyrd.management.SimpleMBean.java
/** * Create a new SimpleMBean/*ww w.j ava 2s . c om*/ * * @throws NotCompliantMBeanException {@inheritDoc} */ protected SimpleMBean() throws NotCompliantMBeanException { // // Create attributes // String[] attlist = getAttributeNames(); MBeanAttributeInfo[] attributes = null; if (attlist != null) { attributes = new MBeanAttributeInfo[attlist.length]; for (int i = 0; i < attlist.length; i++) { String name = attlist[i]; name = StringUtils.capitalize(name); Method getter = findGetterSetter(getClass(), "get" + name, null); if (getter == null) getter = findGetterSetter(getClass(), "is" + name, null); Method setter = null; if (getter != null) { setter = findGetterSetter(getClass(), "set" + name, getter.getReturnType()); } // // Check, if there's a description available // Method descriptor = findGetterSetter(getClass(), "get" + name + "Description", null); String description = ""; if (descriptor != null) { try { description = (String) descriptor.invoke(this, (Object[]) null); } catch (Exception e) { description = "Exception: " + e.getMessage(); } } MBeanAttributeInfo info; try { info = new MBeanAttributeInfo(attlist[i], description, getter, setter); } catch (IntrospectionException e) { throw new NotCompliantMBeanException(e.getMessage()); } attributes[i] = info; } } // // Create operations. // String[] oplist = getMethodNames(); MBeanOperationInfo[] operations = new MBeanOperationInfo[oplist.length]; Method[] methods = getClass().getMethods(); for (int i = 0; i < oplist.length; i++) { Method method = null; for (int m = 0; m < methods.length; m++) { if (methods[m].getName().equals(oplist[i])) { method = methods[m]; } } if (method == null) { throw new NotCompliantMBeanException( "Class declares method " + oplist[i] + ", yet does not implement it!"); } MBeanOperationInfo info = new MBeanOperationInfo(method.getName(), method); operations[i] = info; } // // Create the actual BeanInfo instance. // MBeanConstructorInfo[] constructors = null; MBeanNotificationInfo[] notifications = null; m_beanInfo = new MBeanInfo(getClass().getName(), getDescription(), attributes, constructors, operations, notifications); }
From source file:com.manydesigns.elements.fields.search.TextSearchField.java
public void toXhtml(@NotNull XhtmlBuffer xb) { xb.openElement("div"); xb.addAttribute("class", "control-group"); xb.writeLabel(StringUtils.capitalize(label), id, ATTR_NAME_HTML_CLASS); xb.openElement("div"); xb.addAttribute("class", "controls"); if (showMatchMode) { xb.writeLabel(MATCH_MODE_LABEL, matchModeId, "match_mode"); xb.openElement("select"); xb.addAttribute("id", matchModeId); xb.addAttribute("name", matchModeParam); xb.addAttribute("class", "match_mode"); for (TextMatchMode m : TextMatchMode.values()) { boolean checked = matchMode == m; String option = m.getStringValue(); xb.writeOption(option, checked, getText(m.getI18nKey())); }/*from w w w. ja va2s . c om*/ xb.closeElement("select"); xb.write(" "); } xb.writeInputText(id, inputName, value, "text", 18, maxLength); xb.closeElement("div"); xb.closeElement("div"); }
From source file:net.sf.firemox.ui.wizard.Wizard.java
/** * Create a new instance of this class./*from w w w .j ava 2s . c om*/ * * @param ability * ability to associate to this ability. If this ability has an * associated picture, it will be used instead of given picture. * Ability's name is also used to fill the title. This ability will * be used to restart this wizard in case of Background button is * used. * @param title * the title of this wizard. * @param description * the description appended to the title of this wizard. This content * will be displayed as Html. * @param iconName * the icon's name to display on the top right place. * @param width * the preferred width. * @param height * the preferred height. */ public Wizard(Ability ability, String title, String description, String iconName, int width, int height) { super(MagicUIComponents.magicForm, StringUtils.capitalize(title), true); getRootPane().setPreferredSize(new Dimension(width, 300)); getRootPane().setMinimumSize(new Dimension(width, height)); setSize(new Dimension(width, height)); // center gameParamPanel = new JPanel(null); gameParamPanel.setLayout(new BoxLayout(gameParamPanel, BoxLayout.Y_AXIS)); if (ability == null) getContentPane().add(new WizardTitle(new WizardImageIcon((Image) null, iconName), description), BorderLayout.NORTH); else getContentPane().add(new WizardTitle(new WizardImageIcon(ability.getCard(), iconName), description), BorderLayout.NORTH); getContentPane().add(gameParamPanel, BorderLayout.CENTER); getContentPane().add(new JPanel(), BorderLayout.EAST); // bottom final JPanel abstractButtonPanel = new JPanel(new BorderLayout()); this.buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); this.ability = ability; abstractButtonPanel.setBorder(null); abstractButtonPanel.add(new JSeparator(), BorderLayout.NORTH); abstractButtonPanel.add(buttonPanel, BorderLayout.CENTER); abstractButtonPanel.add(wizardInfo, BorderLayout.SOUTH); getContentPane().add(abstractButtonPanel, BorderLayout.SOUTH); setLocationRelativeTo(null); }