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

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

Introduction

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

Prototype

public static String capitalize(String str) 

Source Link

Document

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

Usage

From source file:com.googlecode.gmaps4jsf.jsfplugin.digester.Attribute.java

public String getCapitalizedType() {
    return StringUtils.capitalize(getShortTypeName());
}

From source file:eu.annocultor.converters.europeana.EuropeanaLabelExtractor.java

boolean extractDfgCoverage(List<String> extracted, String label) {
    if (precheckisDfgCoverage(label)) {
        if (StringUtils.capitalize(label).equals(label)) {
            String countryAbbreviated = StringUtils.substringBefore(label, " ");
            extracted.add(countryAbbreviated);
            String countrySpelled = StringUtils.substringAfter(label, " ");
            if (!StringUtils.isEmpty(countrySpelled)) {
                extracted.add(countrySpelled);
                return true;
            }/*from   w w  w. ja  v a  2 s  . c  o  m*/
        }
    }
    return false;
}

From source file:com.swtxml.events.registry.WidgetEventListenerMethod.java

public String getName() {
    if (StyledText.class == listenerAddMethod.getDeclaringClass()
            && ExtendedModifyListener.class == getListenerInterfaceClass()) {
        return "extendedModifyText";
    }//from w w  w  .  j  a va 2 s .  c om
    if (Browser.class == listenerAddMethod.getDeclaringClass()) {
        return StringUtils
                .uncapitalize(StringUtils.replace(getListenerInterfaceClass().getSimpleName(), "Listener", ""))
                + StringUtils.capitalize(listenerMethod.getName());
    }
    return listenerMethod.getName();
}

From source file:com.ocs.dynamo.utils.ClassUtils.java

/**
 * Clears a field//www.  j  a va2 s . com
 * 
 * @param obj
 *            the object on which to clear the field
 * @param fieldName
 *            the name of the field
 * @param argType
 */
public static void clearFieldValue(Object obj, String fieldName, Class<?> argType) {
    try {
        int p = fieldName.indexOf(".");
        if (p >= 0) {
            String firstProperty = fieldName.substring(0, p);
            Object first = MethodUtils.invokeMethod(obj, GET + StringUtils.capitalize(firstProperty),
                    new Object[] {});
            if (first != null) {
                clearFieldValue(first, fieldName.substring(p + 1), argType);
            }
        } else {
            Method m = obj.getClass().getMethod(SET + StringUtils.capitalize(fieldName),
                    new Class[] { argType });
            m.invoke(obj, new Object[] { null });
        }
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
        throw new OCSRuntimeException(e.getMessage(), e);
    }
}

From source file:com.adobe.cq.wcm.core.components.models.form.impl.v1.ButtonImpl.java

@Override
public String getTitle() {
    if (StringUtils.isBlank(this.title)) {
        this.title = i18n.getVar(StringUtils.capitalize(this.typeString));
    }/*from w w  w. j  a v  a2s  .c  om*/
    return this.title;
}

From source file:net.mindengine.oculus.frontend.db.jdbc.BeanMapper.java

@Override
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
    // TODO Auto-generated method stub
    ResultSetMetaData metaData = rs.getMetaData();
    int columns = metaData.getColumnCount();
    try {/*from www.  j a  va  2  s. c om*/
        Class<?> clazz = Class.forName(className);

        Object obj = clazz.newInstance();
        for (int i = 1; i <= columns; i++) {
            String column = metaData.getColumnName(i);
            FieldMapper fm = fields.get(column);
            if (fm != null) {
                Method method = fm.getMethod();

                String typeName = fm.getType().getSimpleName();

                typeName = StringUtils.capitalize(typeName);
                if (typeName.endsWith("[]")) {
                    typeName = typeName.substring(0, typeName.length() - 2) + "s";
                }
                if (typeName.equals("Date")) {
                    typeName = "Timestamp";
                }
                if (typeName.equals("Integer")) {
                    typeName = "Int";
                }

                Method rsMethod = ResultSet.class.getMethod("get" + typeName, String.class);
                Object value = rsMethod.invoke(rs, column);

                if (value instanceof Timestamp) {
                    Timestamp timestamp = (Timestamp) value;
                    value = new Date(timestamp.getTime());
                }
                method.invoke(obj, value);
            }
        }
        return obj;
    } catch (Exception e) {
        throw new SQLException(e);
    }
}

From source file:msi.gama.gui.views.ExperimentParametersView.java

protected void displayCommands() {
    final Collection<UserCommandStatement> userCommands = experiment.getUserCommands();

    String expInfo = "Model " + experiment.getModel().getDescription().getTitle() + " / "
            + StringUtils.capitalize(experiment.getDescription().getTitle());
    toolbar.status((Image) null, expInfo, IGamaColors.NEUTRAL, SWT.LEFT);
    toolbar.sep(2, SWT.LEFT);/*from  w w  w  .  j  a v a  2s. co m*/
    for (final IStatement command : userCommands) {
        ToolItem f = toolbar.button(IGamaColors.BLUE, command.getName(), new SelectionAdapter() {

            @Override
            public void widgetSelected(final SelectionEvent e) {
                GAMA.getSimulation().getScheduler().executeOneAction(new GamaHelper() {

                    @Override
                    public Object run(final IScope scope) {
                        final Object result = command.executeOn(scope);
                        experiment.getSimulationOutputs().forceUpdateOutputs();
                        return result;
                    }

                });
            }

        }, SWT.LEFT);
        toolbar.sep(2, SWT.LEFT);
    }
    toolbar.refresh(true);

}

From source file:com.evolveum.midpoint.util.ReflectionUtil.java

private static String getterName(String propertyName) {
    return "get" + StringUtils.capitalize(propertyName);
}

From source file:com.doculibre.constellio.wicket.components.locale.LocalePropertyModel.java

@Override
public Object getObject() {
    Locale getterLocale = locale;
    if (getterLocale == null) {
        getterLocale = Session.get().getLocale();
    }//from ww w. j a  v  a2s .  c o m
    String label;
    Object entity = labelledEntityModel.getObject();
    if (propertyName == null && entity instanceof ConstellioLabelledEntity) {
        ConstellioLabelledEntity labelledEntity = (ConstellioLabelledEntity) labelledEntityModel.getObject();
        label = labelledEntity.getLabel(labelKey, getterLocale);
    } else {
        String methodName = "get" + StringUtils.capitalize(propertyName);
        Method getter;
        try {
            getter = entity.getClass().getMethod(methodName, String.class, Locale.class);
            label = (String) getter.invoke(entity, labelKey, getterLocale);
        } catch (SecurityException e) {
            throw new WicketRuntimeException(e);
        } catch (NoSuchMethodException e) {
            throw new WicketRuntimeException(e);
        } catch (IllegalArgumentException e) {
            throw new WicketRuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new WicketRuntimeException(e);
        } catch (InvocationTargetException e) {
            throw new WicketRuntimeException(e);
        }
    }
    return label;
}

From source file:com.swtxml.swt.types.LayoutType.java

@SuppressWarnings("unchecked")
private Class<? extends Layout> getLayoutClass(String layoutName, Strictness strictness) {
    String className = SWT_LAYOUT_PACKAGE + "." + StringUtils.capitalize(layoutName) + "Layout";
    try {/*  w  w w.  j a va 2s  . c  o  m*/
        return (Class<? extends Layout>) Class.forName(className);
    } catch (Exception e) {
        if (strictness == Strictness.STRICT) {
            throw new ReflectorException(e);
        }
        return null;
    }
}