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:fr.amapj.view.engine.basicform.BasicFormListPart.java

protected Field addFieldText(FormInfo formInfo, String propertyId) {
    return addFieldText(formInfo, propertyId, StringUtils.capitalize(propertyId));
}

From source file:adalid.core.programmers.AbstractJavaProgrammer.java

@Override
public String getJavaUpperClassName(String name) {
    return StringUtils.capitalize(StrUtils.getCamelCase(name, true));
}

From source file:com.frameworkset.orm.engine.model.JavaNameGenerator.java

/**
 * Converts a database schema name to java object name.  Removes
 * <code>STD_SEPARATOR_CHAR</code> and <code>SCHEMA_SEPARATOR_CHAR</code>,
 * capitilizes first letter of name and each letter after the 
 * <code>STD_SEPERATOR</code> and <code>SCHEMA_SEPARATOR_CHAR</code>,
 * converts the rest of the letters to lowercase.
 *
 * @param schemaName name to be converted.
 * @return converted name.//  w ww. java2  s  .  co m
 * @see com.frameworkset.orm.engine.model.NameGenerator
 * @see #underscoreMethod(String)
 */
protected String underscoreMethod(String schemaName, boolean IGNORE_FIRST_TOKEN) {
    StringBuffer name = new StringBuffer();

    // remove the STD_SEPARATOR_CHARs and capitalize 
    // the tokens
    StringTokenizer tok = new StringTokenizer(schemaName, String.valueOf(STD_SEPARATOR_CHAR));
    while (tok.hasMoreTokens()) {
        String namePart = ((String) tok.nextElement()).toLowerCase();
        name.append(StringUtils.capitalize(namePart));
    }

    // remove the SCHEMA_SEPARATOR_CHARs and capitalize 
    // the tokens
    schemaName = name.toString();
    name = new StringBuffer();
    tok = new StringTokenizer(schemaName, String.valueOf(SCHEMA_SEPARATOR_CHAR));
    while (tok.hasMoreTokens()) {
        String namePart = (String) tok.nextElement();
        name.append(StringUtils.capitalize(namePart));
    }
    return name.toString();
}

From source file:com.bluexml.xforms.generator.tools.ModelTools.java

/**
 * To jaxb./* w w w  .  j a v  a2 s  .c o  m*/
 * 
 * @param completeName
 *            the complete name
 * @return the string
 */
public static String toJAXB(String completeName) {
    String[] split = completeName.split("\\.");
    StringBuffer sb = new StringBuffer("");
    for (String string : split) {
        sb.append(StringUtils.capitalize(string));
    }
    return sb.toString();
}

From source file:com.manydesigns.elements.fields.PasswordField.java

public void labelToXhtml(XhtmlBuffer xb, String actualHtmlId, String actualLabel) {
    xb.openElement("label");
    xb.addAttribute("for", actualHtmlId);
    xb.addAttribute("class", FORM_LABEL_CLASS);
    xb.write(StringUtils.capitalize(actualLabel));
    xb.closeElement("label");
}

From source file:com.square.core.service.implementations.AgendaServiceImplementation.java

@Override
public List<RendezVousDto> rechercherRendezVousParCriteres(RendezVousCriteresRechercheDto criteres) {
    if (criteres == null) {
        throw new BusinessException(messageSourceUtil.get(AgendaKeyUtil.MESSAGE_ERREUR_AGENDA_CRITERES_NULL));
    }//  w  w w .j  av a2s  .c  o  m
    if (criteres.getIdRessource() == null) {
        throw new BusinessException(messageSourceUtil.get(AgendaKeyUtil.MESSAGE_ERREUR_AGENDA_RESSOURCE_NULL));
    }
    if (criteres.getDateMinDateDebut() == null) {
        throw new BusinessException(messageSourceUtil.get(AgendaKeyUtil.MESSAGE_ERREUR_AGENDA_DATE_MIN_NULL));
    }
    if (criteres.getDateMaxDateDebut() == null) {
        throw new BusinessException(messageSourceUtil.get(AgendaKeyUtil.MESSAGE_ERREUR_AGENDA_DATE_MAX_NULL));
    }
    if (criteres.getDateMinDateDebut().after(criteres.getDateMaxDateDebut())) {
        throw new BusinessException(
                messageSourceUtil.get(AgendaKeyUtil.MESSAGE_ERREUR_AGENDA_DATE_MIN_SUP_DATE_MAX));
    }

    final Ressource ressource = ressourceDao.rechercherRessourceParId(criteres.getIdRessource());
    if (ressource == null) {
        throw new BusinessException(
                messageSourceUtil.get(AgendaKeyUtil.MESSAGE_ERREUR_AGENDA_RESSOURCE_INEXISTANTE));
    }
    final CritereRechercheAction criteresActions = mapperDozerBean.map(criteres, CritereRechercheAction.class);
    criteresActions.setVisibleAgenda(true);
    final List<Action> actions = actionDao.rechercherActionParCriteresEtRessource(criteresActions, ressource);

    final List<RendezVousDto> listeResult = new ArrayList<RendezVousDto>();

    for (Action action : actions) {
        final RendezVousDto rendezVous = mapperDozerBean.map(action, RendezVousDto.class);
        if (action.getActionAffectation().getPersonne() != null) {
            final PersonneBaseDto personne = personneService
                    .rechercherPersonneParId(action.getActionAffectation().getPersonne().getId());
            if (personne instanceof PersonneDto) {
                final PersonneDto personnePhysique = (PersonneDto) personne;
                rendezVous.setNomPersonne(personnePhysique.getNom().toUpperCase());
                rendezVous.setPrenomPersonne(StringUtils.capitalize(personnePhysique.getPrenom()));
                rendezVous.setTitre(personnePhysique.getNom().toUpperCase() + ESPACE
                        + StringUtils.capitalize(personnePhysique.getPrenom()));
                rendezVous.setNaturePersonne(personnePhysique.getNaturePersonne());
            } else if (personne instanceof PersonneMoraleDto) {
                final PersonneMoraleDto personneMorale = (PersonneMoraleDto) personne;
                rendezVous.setRaisonSociale(personneMorale.getRaisonSociale().toUpperCase());
                rendezVous.setTitre(personneMorale.getNumEntreprise() + ESPACE
                        + personneMorale.getRaisonSociale().toUpperCase());
                rendezVous.setNaturePersonne(personneMorale.getNature());
            }
        }
        listeResult.add(rendezVous);
    }

    try {
        // on recupere les rendez vous tiers
        final RendezVousTiersCriteresDto criteresTiers = new RendezVousTiersCriteresDto();
        criteresTiers.setIdUtilisateurConnecte(Long.parseLong(ressource.getIdentifiantExterieur()));
        criteresTiers.setDateMin(criteres.getDateMinDateDebut());
        criteresTiers.setDateMax(criteres.getDateMaxDateDebut());
        final List<RendezVousTiersDto> listeRendezVousTiers = agendaTiersSquarePlugin
                .getListeRendezVous(criteresTiers);
        for (RendezVousTiersDto rendezVousTiersDto : listeRendezVousTiers) {
            if (rendezVousTiersDto.getDate() != null) {
                listeResult.add((RendezVousDto) mapperDozerBean.map(rendezVousTiersDto, RendezVousDto.class));
            }
        }
    } catch (BusinessException e) {
        logger.error(messageSourceUtil.get(AgendaKeyUtil.MESSAGE_ERREUR_AGENDA_RECUPERATION_AGENDA_TIERS), e);
    }

    Collections.sort(listeResult, new Comparator<RendezVousDto>() {
        @Override
        public int compare(RendezVousDto r0, RendezVousDto r1) {
            return r0.getDate().compareTo(r1.getDate());
        }
    });
    return listeResult;
}

From source file:com.simplexwork.mysql.tools.utils.DocumentUtils.java

/**
 * ?java bean/*  w  w w  .  j  a  va 2 s. c  o m*/
 * 
 * @param tablesMap
 * @throws Exception
 */
public static void productJavaBean(Map<String, TableInfo> tablesMap) throws Exception {

    VelocityContext context = new VelocityContext();
    Template template = Velocity.getTemplate("javabean.vm");

    for (Entry<String, TableInfo> entry : tablesMap.entrySet()) {

        TableInfo tableInfo = entry.getValue();

        String javaBeanName = getJavaBeanName(StringUtils.capitalize(tableInfo.getTableName()));

        List<Object> fileds = new ArrayList<>();

        for (Column column : tableInfo.getColumns()) {
            Map<String, String> field = new HashMap<>();
            String columnType = column.getType();
            if (columnType.contains("(")) {
                columnType = columnType.substring(0, columnType.indexOf("("));
            }
            field.put("comment", column.getComment());
            field.put("type", MysqlUtils.getPojoType(columnType, column.getName()));
            field.put("name", fixName(column.getName()));
            fileds.add(field);
        }

        context.put("tableComment", tableInfo.getTableComment());
        context.put("className", javaBeanName);
        context.put("fields", fileds);
        context.put("pkgBean", pkgBean);

        StringWriter writer = new StringWriter();
        template.merge(context, writer);

        FileUtils.writeStringToFile(new File(generatedPath + "bean/" + javaBeanName + ".java"),
                writer.toString(), "UTF-8");

    }

}

From source file:de.xirp.plugin.ViewerBase.java

/**
 * Synchronize the control with the named property of the data.<br/>
 * This is shorthand for<br>//from   w w  w. j  a  va  2s  .  com
 * <code>sync(control, {@value #SET_PREFIX}+propertyName, {@value #GET_PREFIX}+propertyName);</code>
 * or<br>
 * <code>sync(control, {@value #SET_PREFIX}+propertyName, {@value #IS_PREFIX}+propertyName);</code>
 * 
 * @param control
 *            the control to sync with data
 * @param propertyName
 *            the property name of a field of the data
 */
protected void sync(Control control, String propertyName) {
    String uPropertyName = StringUtils.capitalize(propertyName);
    String setterName = SET_PREFIX + uPropertyName;
    String getterName = GET_PREFIX + uPropertyName;
    boolean exists = methodExists(getterName);
    if (!exists) {
        if (methodExists(IS_PREFIX + uPropertyName)) {
            getterName = IS_PREFIX + uPropertyName;
        }
    }

    if (data != null) {
        data.addPropertyChangeListener(propertyName, this);
    }

    setter.put(setterName, control);

    // Add the setter to the control
    control.setData(SETTER_KEY, setterName);

    // determine appropriate listener type for the control
    int listenerType = SWT.Selection;
    if (control instanceof Text) {
        listenerType = SWT.Modify;
    }

    // add the listener
    control.addListener(listenerType, new Listener() {

        public void handleEvent(Event event) {
            // only handle the event if theres no boolean
            // indicating that this event was already handled
            Object obj = event.data;
            if (obj == null || !(obj instanceof Boolean)) {
                select(event);
            }
        }
    });

    Object value = get(getterName);

    this.propertyChange(new PropertyChangeEvent(data, propertyName, null, value));
}

From source file:com.intellij.refactoring.rename.SilentRenameJavaVariableProcessor.java

private boolean askToRenameAccesors(PsiMethod getter, PsiMethod setter, String newName, final Project project) {
    if (getter != null && getter.hasModifierProperty("public"))
        return true;
    if (setter != null && setter.hasModifierProperty("public"))
        return true;

    PsiMethod[] superGetters = null;/*ww  w  . ja  v  a2 s . c o m*/
    if (getter != null) {
        String newGetterName = "get" + StringUtils.capitalize(newName);
        PsiClass clazz = getter.getContainingClass();
        PsiMethod[] collisions = clazz.findMethodsByName(newGetterName, true);
        for (PsiMethod method : collisions) {
            if (!ShuffleAction.isCollidingSignature(getter, method, true) && !getter.equals(method)) {
                return true;
            }
        }

        superGetters = ShuffleAction.findDeepestSuperMethods(getter);
    }

    PsiMethod[] superSetters = null;
    if (setter != null) {
        String newSetterName = "set" + StringUtils.capitalize(newName);
        PsiClass clazz = setter.getContainingClass();
        PsiMethod[] collisions = clazz.findMethodsByName(newSetterName, true);
        for (PsiMethod method : collisions) {
            if (!ShuffleAction.isCollidingSignature(setter, method, true) && !setter.equals(method)) {
                return true;
            }
        }
        superSetters = ShuffleAction.findDeepestSuperMethods(setter);
    }

    return !(renameGettersAndSetters && (superGetters == null || superGetters.length == 0)
            && (superSetters == null || superSetters.length == 0));
}

From source file:ml.shifu.shifu.util.ClassUtils.java

public static Method getDeclaredGetterWithNull(String name, Class<?> clazz) {
    try {/*from   ww w  .  jav  a2s .  c o  m*/
        return getDeclaredMethod("get" + StringUtils.capitalize(name), clazz);
    } catch (Exception e) {
        return null;
    }
}