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:edu.psu.citeseerx.myciteseer.domain.logic.CollectionValidator.java

public String getInputFieldValidationMessage(String formInputId, String formInputValue) {
    String validationMessage = "";

    try {/*from  w  w w. java 2  s . co m*/
        Object formBackingObject = new Collection();
        Errors errors = new BindException(formBackingObject, "command");

        formInputId = formInputId.split("\\.")[1];
        String capitalizedFormInputId = StringUtils.capitalize(formInputId);

        String accountMethodName = "set" + capitalizedFormInputId;
        Class setterArgs[] = new Class[] { String.class };
        Method accountMethod = formBackingObject.getClass().getMethod(accountMethodName, setterArgs);
        accountMethod.invoke(formBackingObject, new Object[] { formInputValue });

        String validationMethodName = "validate" + capitalizedFormInputId;
        Class validationArgs[] = new Class[] { String.class, Errors.class };
        Method validationMethod = getClass().getMethod(validationMethodName, validationArgs);
        validationMethod.invoke(this, new Object[] { formInputValue, errors });

        validationMessage = getValidationMessage(errors, formInputId);

    } catch (Exception e) {
        e.printStackTrace();
    }

    return validationMessage;

}

From source file:edu.ku.brc.specify.toycode.mexconabio.FMPCreateTable.java

public void startElement(String namespaceURI, String localName, String qName, Attributes attrs) {
    buffer.setLength(0);//from   ww w .  ja  v  a 2s . c o  m

    if (localName.equals("FIELD")) {
        FieldDef fldDef = new FieldDef();
        fields.add(fldDef);

        for (int i = 0; i < attrs.getLength(); i++) {
            String attr = attrs.getLocalName(i);
            String value = attrs.getValue(i);
            if (attr.equals("EMPTYOK")) {
                fldDef.setNullable(value.equals("YES"));

            } else if (attr.equals("NAME")) {
                value = StringUtils.capitalize(value.trim());
                value = StringUtils.deleteWhitespace(value);
                value = StringUtils.replace(value, "_", "");

                if ((value.charAt(0) >= '0' && value.charAt(0) <= '9') || value.equalsIgnoreCase("New")
                        || value.equalsIgnoreCase("Group")) {
                    value = "Fld" + value;
                }

                String fixedStr = convertFromTwoByteUTF8(value);
                fixedStr = StringUtils.replace(fixedStr, ".", "");
                fixedStr = StringUtils.replace(fixedStr, ":", "");
                fixedStr = StringUtils.replace(fixedStr, "/", "_");
                fldDef.setName(fixedStr);
                fldDef.setOrigName(value);

            } else if (attr.equals("TYPE")) {
                if (value.equals("TEXT")) {
                    fldDef.setType(DataType.eText);

                } else if (value.equals("NUMBER")) {
                    fldDef.setType(DataType.eNumber);

                } else if (value.equals("DATE")) {
                    fldDef.setType(DataType.eDate);

                } else if (value.equals("TIME")) {
                    fldDef.setType(DataType.eTime);
                } else {
                    System.err.println("Unknown Type[" + value + "]");
                }
            }
        }
    }
}

From source file:com.square.composant.prestations.square.server.service.PrestationServiceGwtImpl.java

@Override
public List<IdentifiantLibelleGwt> recupererBenefPrestations(Long uidAssure, String prenom) {
    final List<IdentifiantLibelleGwt> listePersonnes = new ArrayList<IdentifiantLibelleGwt>();
    // On ajoute la personne principale puis ses bnficiaires
    final PersonneSimpleDto personnePrincipale = personnePhysiqueService
            .rechercherPersonneSimpleParIdentifiant(uidAssure);
    listePersonnes/*from   w  w w . j av  a2s .c o m*/
            .add(new IdentifiantLibelleGwt(personnePrincipale.getId(), personnePrincipale.getNom().toUpperCase()
                    + " " + StringUtils.capitalize(personnePrincipale.getPrenom())));
    final List<BeneficiairePrestationDto> resultatsDto = prestationService
            .recupererBeneficiairesPrestations(uidAssure, prenom);
    for (BeneficiairePrestationDto beneficiaire : resultatsDto) {
        listePersonnes.add(new IdentifiantLibelleGwt(beneficiaire.getIdentifiant(),
                beneficiaire.getNom().toUpperCase() + " " + StringUtils.capitalize(beneficiaire.getPrenom())));
    }
    return listePersonnes;
}

From source file:com.manydesigns.elements.fields.search.BooleanSearchField.java

public void toXhtml(@NotNull XhtmlBuffer xb) {
    xb.openElement("div");
    xb.addAttribute("class", "control-group ");
    xb.openElement("label");
    xb.addAttribute("class", ATTR_NAME_HTML_CLASS);
    xb.write(StringUtils.capitalize(label));
    xb.closeElement("label");
    xb.openElement("div");
    xb.addAttribute("class", "controls");

    for (BooleanSearchValue current : BooleanSearchValue.values()) {
        // don't print null if the attribute is required
        if (required && current == BooleanSearchValue.NULL) {
            continue;
        }// www.  j  ava  2  s .  com
        String idStr = id + "_" + current.name();
        String stringValue = current.getStringValue();
        boolean checked = (value == current);
        xb.openElement("label");
        xb.addAttribute("class", "checkbox");
        xb.addAttribute("for", idStr);
        String label = getText(current.getLabelI18N());
        xb.write(label);
        xb.writeInputRadio(idStr, inputName, stringValue, checked);
        xb.closeElement("label");
    }
    xb.closeElement("div");
    xb.closeElement("div");
}

From source file:com.googlecode.gmaps4jsf.jsfplugin.mojo.TagMojo.java

private String getPropertySetterMethod(Attribute attribute) {
    String method = "\t\tComponentUtils.set";

    //Handle special attributes like converter, validator, value, valueChangeListener, action, actionListener
    if (isIgnored(attribute, specialAttributes))
        method += StringUtils.capitalize(attribute.getName()) + "Property(getFacesContext(), uicomponent, _"
                + attribute.getName() + ");\n";
    else {//from w w w. j  a  v  a 2 s .  c o m
        method += FacesMojoUtils.getWrapperType(attribute.getShortTypeName())
                + "Property(getFacesContext(), uicomponent, \"" + attribute.getName() + "\", _"
                + attribute.getName() + " );\n";
    }

    return method;
}

From source file:fr.esrf.icat.manager.core.part.SameEntitiesMenuContribution.java

@AboutToShow
public void aboutToShow(final List<MMenuElement> items,
        final @Named(IServiceConstants.ACTIVE_PART) MPart activePart,
        final @Named(IServiceConstants.ACTIVE_SELECTION) @Optional List<WrappedEntityBean> selection) {

    if (null == selection || selection.isEmpty()) {
        return;// www  .  j  av a  2s  .c o m
    }

    MCommand command = null;
    for (MCommand c : application.getCommands()) {
        if (ICAT_MANAGER_CORE_COMMAND_OPENENTITY.equals(c.getElementId())) {
            command = c;
            break;
        }
    }

    if (null == command) {
        LOG.error("Command {} not found", ICAT_MANAGER_CORE_COMMAND_OPENENTITY);
        return;
    }

    DataPart part;
    if (activePart instanceof DataPart) {
        part = (DataPart) activePart;
    } else {
        part = (DataPart) activePart.getObject();
    }

    final WrappedEntityBean firstEntityBean = selection.get(0);
    final List<String> fields = new LinkedList<>(firstEntityBean.getMutableFields());
    fields.removeAll(firstEntityBean.getEntityFields());
    for (String fieldName : fields) {
        String entityFilter = makeFieldFilter(selection, fieldName);
        if (null == entityFilter) {
            continue;
        }
        MHandledMenuItem dynamicItem = MMenuFactory.INSTANCE.createHandledMenuItem();
        dynamicItem.setCommand(command);
        dynamicItem.setLabel(StringUtils.capitalize(fieldName));
        MParameter p = MCommandsFactory.INSTANCE.createParameter();
        p.setName("icat-manager.core.commandparameter.filter");
        p.setValue(entityFilter);
        dynamicItem.getParameters().add(p);
        MParameter pEntity = MCommandsFactory.INSTANCE.createParameter();
        pEntity.setName("icat-manager.core.commandparameter.entity");
        pEntity.setValue(firstEntityBean.getEntityName());
        dynamicItem.getParameters().add(pEntity);
        MParameter pServer = MCommandsFactory.INSTANCE.createParameter();
        pServer.setName("icat-manager.core.commandparameter.server");
        pServer.setValue(part.getEntity().getServer().getServerURL());
        dynamicItem.getParameters().add(pServer);
        dynamicItem.setEnabled(true);
        dynamicItem.setToBeRendered(true);
        dynamicItem.setVisible(true);
        items.add(dynamicItem);
    }

    if (items.size() > 0) {
        final MMenuSeparator separator = MMenuFactory.INSTANCE.createMenuSeparator();
        separator.setToBeRendered(true);
        separator.setVisible(true);
        items.add(separator);
    }
    for (String fieldName : firstEntityBean.getEntityFields()) {
        final String entityName = firstEntityBean.getReturnType(fieldName).getSimpleName();
        String entityFilter = makeFKEntityFilter(selection, fieldName);
        if (null == entityFilter) {
            continue;
        }
        final MHandledMenuItem dynamicItem = MMenuFactory.INSTANCE.createHandledMenuItem();
        dynamicItem.setCommand(command);
        dynamicItem.setLabel(entityName);
        MParameter p = MCommandsFactory.INSTANCE.createParameter();
        p.setName("icat-manager.core.commandparameter.filter");
        p.setValue(entityFilter);
        dynamicItem.getParameters().add(p);
        MParameter pEntity = MCommandsFactory.INSTANCE.createParameter();
        pEntity.setName("icat-manager.core.commandparameter.entity");
        pEntity.setValue(firstEntityBean.getEntityName());
        dynamicItem.getParameters().add(pEntity);
        MParameter pServer = MCommandsFactory.INSTANCE.createParameter();
        pServer.setName("icat-manager.core.commandparameter.server");
        pServer.setValue(part.getEntity().getServer().getServerURL());
        dynamicItem.getParameters().add(pServer);
        dynamicItem.setEnabled(true);
        dynamicItem.setToBeRendered(true);
        dynamicItem.setVisible(true);
        items.add(dynamicItem);
    }
}

From source file:it.eng.spagobi.meta.initializer.name.BusinessModelNamesInitializer.java

public void setTableName(BusinessTable businessTable) {
    Assert.assertNotNull("Input parameter [businessTable] cannot be null", businessTable);
    Assert.assertNotNull("Input parameter [businessTable] is not associated to any physical table",
            businessTable.getPhysicalTable());
    String physicalTableName = businessTable.getPhysicalTable().getName();
    String baseName = StringUtils.capitalize(physicalTableName.replace("_", " "));
    setTableName(businessTable, baseName);
}

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

@Override
public void setObject(Serializable object) {
    Locale setterLocale = locale;
    if (setterLocale == null) {
        setterLocale = Session.get().getLocale();
    }/*from  w w w .  ja  v  a2s. c o  m*/
    Object entity = labelledEntityModel.getObject();
    if (propertyName == null && entity instanceof ConstellioLabelledEntity) {
        ConstellioLabelledEntity labelledEntity = (ConstellioLabelledEntity) labelledEntityModel.getObject();
        labelledEntity.setLabel(labelKey, (String) object, setterLocale);
    } else {
        String methodName = "set" + StringUtils.capitalize(propertyName);
        Method setter;
        try {
            setter = entity.getClass().getMethod(methodName, String.class, String.class, Locale.class);
            setter.invoke(entity, labelKey, (String) object, setterLocale);
        } 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);
        }
    }
}

From source file:com.flexive.war.javascript.tree.StructureTreeEditor.java

/**
 * Reuse a property assignment//from www  . j  a  v a  2 s.c om
 *
 * @param orgAssignmentId id of the assignment to reuse
 * @param newName         new name (can be empty, will be used for label if set)
 * @param xPath           XPath
 * @param type            FxType
 * @return FxPropertyAssignmentEdit
 * @throws FxNotFoundException         on errors
 * @throws FxInvalidParameterException on errors
 */
private FxPropertyAssignmentEdit createReusedPropertyAssignment(long orgAssignmentId, String newName,
        String xPath, FxType type) throws FxNotFoundException, FxInvalidParameterException {
    FxPropertyAssignment assignment = (FxPropertyAssignment) CacheAdmin.getEnvironment()
            .getAssignment(orgAssignmentId);
    FxPropertyAssignmentEdit prop;
    if (!StringUtils.isEmpty(newName)) {
        prop = FxPropertyAssignmentEdit.createNew(assignment, type,
                newName == null ? assignment.getAlias() : newName, xPath);
        prop.getLabel().setDefaultTranslation(StringUtils.capitalize(newName));
    } else
        prop = FxPropertyAssignmentEdit.createNew(assignment, type, assignment.getAlias(), xPath);
    return prop;
}

From source file:com.seajas.search.profiler.controller.ModifierController.java

/**
 * Available script languages./*  w  w  w. j  av  a 2s  .  c o m*/
 * 
 * @return Map<String, String>
 */
@ModelAttribute("scriptLanguages")
public Map<String, String> populateScriptLanguages() {
    Map<String, String> scriptLanguages = new LinkedHashMap<String, String>();

    for (ScriptEngineFactory factory : new ScriptEngineManager().getEngineFactories())
        if (factory.getLanguageName().equalsIgnoreCase("ECMAScript"))
            scriptLanguages.put(factory.getLanguageName(), "JavaScript");
        else if (factory.getLanguageName().equalsIgnoreCase("Groovy")
                || factory.getLanguageName().equalsIgnoreCase("Scala")
                || factory.getLanguageName().equalsIgnoreCase("Ruby"))
            scriptLanguages.put(factory.getLanguageName(), StringUtils.capitalize(factory.getLanguageName()));

    scriptLanguages.put("xslt", "XSLT");

    return scriptLanguages;
}