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:ch.entwine.weblounge.common.impl.util.config.OptionsHelper.java

/**
 * Initializes the options from an XML node that was generated using
 * {@link #toXml()}. This method expects a <code>&lt;properties&gt;</code>
 * node as the input to <code>config</code>.
 * //from  w  w  w.  j a  va  2s .c  o  m
 * @param config
 *          the options node
 * @param customizable
 *          the customizable object
 * @param xpathProcessor
 *          xpath processor to use
 * @throws IllegalStateException
 *           if the options cannot be parsed
 * @see #toXml()
 */
public static void fromXml(Node config, Customizable customizable, XPath xpathProcessor)
        throws IllegalStateException {

    if (config == null)
        return;

    // Read the options
    NodeList nodes = XPathHelper.selectList(config, "ns:option", xpathProcessor);
    for (int i = 0; i < nodes.getLength(); i++) {
        Node option = nodes.item(i);
        String name = XPathHelper.valueOf(option, "ns:name", xpathProcessor);
        NodeList valueNodes = XPathHelper.selectList(option, "ns:value", xpathProcessor);

        for (int j = 0; j < valueNodes.getLength(); j++) {

            String env = XPathHelper.valueOf(valueNodes.item(j), "@environment");
            Environment environment = Environment.Any;
            if (StringUtils.isNotBlank(env)) {
                try {
                    environment = Environment.valueOf(StringUtils.capitalize(env));
                } catch (Throwable t) {
                    throw new IllegalStateException("Environment '" + env + "' is unknown");
                }
            }

            String value = valueNodes.item(j).getFirstChild().getNodeValue();
            customizable.setOption(name, value, environment);
        }

    }
}

From source file:com.evolveum.midpoint.prism.marshaller.PrismBeanInspector.java

private <T> Method findPropertyGetterUncached(Class<T> classType, String propName) {
    if (propName.startsWith("_")) {
        propName = propName.substring(1);
    }//from w  w  w.  j  a  v a  2  s.co m
    for (Method method : classType.getDeclaredMethods()) {
        XmlElement xmlElement = method.getAnnotation(XmlElement.class);
        if (xmlElement != null && xmlElement.name().equals(propName)) {
            return method;
        }
        XmlAttribute xmlAttribute = method.getAnnotation(XmlAttribute.class);
        if (xmlAttribute != null && xmlAttribute.name().equals(propName)) {
            return method;
        }
    }
    String getterName = "get" + StringUtils.capitalize(propName);
    try {
        return classType.getDeclaredMethod(getterName);
    } catch (NoSuchMethodException e) {
        // nothing found
    }
    getterName = "is" + StringUtils.capitalize(propName);
    try {
        return classType.getDeclaredMethod(getterName);
    } catch (NoSuchMethodException e) {
        // nothing found
    }
    Class<? super T> superclass = classType.getSuperclass();
    if (superclass == null || superclass.equals(Object.class)) {
        return null;
    }
    return findPropertyGetter(superclass, propName);
}

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

/**
 * ?ServiceServiceIml/*from   w  ww.j av a  2 s  .co m*/
 *
 * @param tablesMap
 * @throws Exception
 */
public static void productService(Map<String, TableInfo> tablesMap) throws Exception {

    VelocityContext context = new VelocityContext();

    Template templateService = Velocity.getTemplate("java-service.vm");
    Template template2 = Velocity.getTemplate("java-service-impl.vm");

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

        TableInfo tableInfo = entry.getValue();

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

        String serviceName = tableName + "Service";

        context.put("serviceName", serviceName);
        context.put("beanName", tableName);
        context.put("beanNameTuoFeng", getStartSmallName(tableName));
        context.put("mapperTuoFeng", getStartSmallName(tableName) + "Mapper");
        context.put("beanVarName", StringUtils.uncapitalize(tableName));
        context.put("pkgMapper", pkgMapper);
        context.put("pkgBean", pkgBean);
        context.put("pkgService", pkgService);
        context.put("pkgServiceImpl", pkgServiceImpl);
        context.put("tableComment", tableInfo.getTableComment());

        String keyInBean = ""; // Bean????
        String keyInColoum = ""; // ??
        List<Object> fileds = new ArrayList<>();
        for (Column column : tableInfo.getColumns()) {
            if (column.isKey()) {
                keyInBean = fixName(column.getName());
                keyInColoum = column.getName();
            }

            Map<String, Object> field = new HashMap<>();
            String columnType = column.getType();
            if (columnType.contains("(")) {
                columnType = columnType.substring(0, columnType.indexOf("("));
            }
            String name = fixName(column.getName());
            field.put("isKey", column.isKey());
            field.put("sqlName", column.getName());
            field.put("name", name);
            field.put("nameStartBig", getStartBigName(name));
            field.put("comment", column.getComment());
            field.put("isNullable", column.isNullable());
            fileds.add(field);
        }

        context.put("tableName", tableInfo.getTableName());
        context.put("keyInBean", keyInBean);
        context.put("keyInColoum", keyInColoum);
        context.put("fields", fileds);

        StringWriter writerService = new StringWriter();
        templateService.merge(context, writerService);
        FileUtils.writeStringToFile(new File(generatedPath + "service/" + serviceName + ".java"),
                writerService.toString(), "UTF-8");

        StringWriter writer2 = new StringWriter();
        template2.merge(context, writer2);
        FileUtils.writeStringToFile(new File(generatedPath + "serviceImpl/" + serviceName + "Impl.java"),
                writer2.toString(), "UTF-8");
    }
}

From source file:com.austin.base.commons.util.ReflectUtil.java

/**
 * @param type//  w w  w  .j a  va 2 s  .  com
 * @param fieldName
 * @return
 */
public static String getGetterName(Class type, String fieldName) {
    Assert.notNull(type, "Type required");
    Assert.hasText(fieldName, "FieldName required");

    if (type.getName().equals("boolean")) {
        return "is" + StringUtils.capitalize(fieldName);
    } else {
        return "get" + StringUtils.capitalize(fieldName);
    }
}

From source file:gov.nih.nci.ncicb.tcga.dcc.datareports.service.DatareportsServiceImpl.java

@Override
public void processDisplayTag(final String id, final List<X> list, final ModelMap model,
        final HttpServletRequest request) {
    final String page = request
            .getParameter(new ParamEncoder(id).encodeParameterName(TableTagParameters.PARAMETER_PAGE));
    final int pageSize = 50;
    int pageNumber;
    try {//from   w w w  .  j a v  a  2  s .c o m
        pageNumber = Integer.parseInt(page);
    } catch (Exception e) {
        pageNumber = 0;
    }
    model.addAttribute(id + "List", getPaginatedList(list, (pageNumber - 1) * pageSize, pageSize));
    model.addAttribute(id + StringUtils.capitalize(TOTAL_COUNT), getTotalCount(list));
    model.addAttribute(id + StringUtils.capitalize(PAGE_SIZE), pageSize);
}

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

public void valueToXhtmlRadio(XhtmlBuffer xb) {
    Object[] values = getValues();
    Map<Object, SelectionModel.Option> options = selectionModel.getOptions(selectionModelIndex);

    xb.writeLabel(StringUtils.capitalize(label), id, ATTR_NAME_HTML_CLASS);

    xb.openElement("div");
    xb.addAttribute("class", "controls");

    int counter = 0;

    if (!required) {
        String radioId = id + "_" + counter;
        boolean checked = (values == null && !notSet);
        writeRadioWithLabel(xb, radioId, getText("elements.search.select.none"), "", checked);
        counter++;/*from www. j ava2  s .c  om*/
        radioId = id + "_" + counter;
        writeRadioWithLabel(xb, radioId, getText("elements.search.select.notset.radio"), VALUE_NOT_SET, notSet);
        counter++;
    }

    for (Map.Entry<Object, SelectionModel.Option> option : options.entrySet()) {
        if (!option.getValue().active) {
            continue;
        }
        Object optionValue = option.getKey();
        String optionStringValue = OgnlUtils.convertValueToString(optionValue);
        String optionLabel = option.getValue().label;
        String radioId = id + "_" + counter;
        boolean checked = ArrayUtils.contains(values, optionValue);
        writeRadioWithLabel(xb, radioId, optionLabel, optionStringValue, checked);
        counter++;
    }
    xb.closeElement("div");

    // TODO: gestire radio in cascata
}

From source file:io.swagger.inflector.utils.ReflectionUtils.java

public String getControllerName(Operation operation) {
    String name = (String) operation.getVendorExtensions().get("x-swagger-router-controller");
    if (name != null) {
        if (name.indexOf(".") == -1 && config.getControllerPackage() != null) {
            return config.getControllerPackage() + "." + name;
        } else {// w w  w  .  j a v  a2  s .co  m
            return name;
        }
    }
    if (operation.getTags() != null && operation.getTags().size() > 0) {
        String className = StringUtils.capitalize(sanitizeToJava(operation.getTags().get(0)));
        if (config.getControllerPackage() != null) {
            return config.getControllerPackage() + "." + className;
        }
        return className;
    }
    return null;
}

From source file:com.google.gdt.eclipse.designer.gxt.databinding.wizards.autobindings.GxtDatabindingProvider.java

private static String convertTypes(String className) {
    if (ArrayUtils.contains(new String[] { "boolean", "byte", "short", "long", "float", "double" },
            className)) {//from w ww .  j a  va2  s .c o m
        return StringUtils.capitalize(className);
    } else if ("char".equals(className)) {
        return "Character";
    } else if ("int".equals(className)) {
        return "Integer";
    } else if ("java.lang.String".equals(className)) {
        return "String";
    }
    return className;
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.internationalRelatOffice.internship.InternshipCandidacyDA.java

public ActionForward exportToCandidatesToXls(ActionMapping mapping, ActionForm actionForm,
        HttpServletRequest request, HttpServletResponse response) throws FenixActionException {
    CandidateSearchBean search = getRenderedObject("search");
    if (search.getCutEnd().isBefore(search.getCutStart())) {
        addErrorMessage(request, "start",
                "error.internationalrelations.internship.candidacy.search.startafterend");
        return prepareCandidates(mapping, actionForm, request, response);
    }/*  www . j a v a2  s.  c  o m*/
    if (search.getCutEnd().plusDays(1).toDateMidnight().isAfterNow()) {
        addErrorMessage(request, "end",
                "error.internationalrelations.internship.candidacy.export.todaywontwork");
        return prepareCandidates(mapping, actionForm, request, response);
    }
    Spreadsheet sheet = new Spreadsheet(search.getName());
    if (search.getUniversity() == null) {
        sheet.setHeaders(HEADERS);
    } else {
        sheet.setHeaders(HEADERS_NO_UNIV);
    }
    for (InternshipCandidacyBean bean : filterCandidates(search)) {
        Row row = sheet.addRow();
        row.setCell(bean.getCandidacy().getCandidacyCode());
        if (search.getUniversity() == null) {
            row.setCell(bean.getUniversity().getFullPresentationName());
        }
        row.setCell(bean.getStudentNumber());
        row.setCell(bean.getStudentYear().ordinal() + 1);
        row.setCell(bean.getDegree());
        row.setCell(bean.getBranch());
        row.setCell(bean.getName());
        row.setCell(bean.getGender().toLocalizedString());
        row.setCell(bean.getBirthday().toString("dd-MM-yyyy"));
        row.setCell(bean.getParishOfBirth());
        row.setCell(StringUtils.capitalize(
                bean.getCountryOfBirth().getCountryNationality().getPreferedContent().toLowerCase()));
        row.setCell(bean.getDocumentIdNumber());
        row.setCell(
                bean.getEmissionLocationOfDocumentId() != null ? bean.getEmissionLocationOfDocumentId() : null);
        row.setCell(bean.getEmissionDateOfDocumentId() != null
                ? bean.getEmissionDateOfDocumentId().toString("dd-MM-yyyy")
                : null);
        row.setCell(bean.getExpirationDateOfDocumentId() != null
                ? bean.getExpirationDateOfDocumentId().toString("dd-MM-yyyy")
                : null);
        row.setCell(bean.getPassportIdNumber() != null ? bean.getPassportIdNumber() : "");
        row.setCell(bean.getEmissionLocationOfPassport() != null ? bean.getEmissionLocationOfPassport() : "");
        row.setCell(bean.getEmissionDateOfPassport() != null
                ? bean.getEmissionDateOfPassport().toString("dd-MM-yyyy")
                : "");
        row.setCell(bean.getExpirationDateOfPassport() != null
                ? bean.getExpirationDateOfPassport().toString("dd-MM-yyyy")
                : "");
        row.setCell(bean.getStreet());
        row.setCell(bean.getAreaCode());
        row.setCell(bean.getArea());
        row.setCell(bean.getTelephone());
        row.setCell(bean.getMobilePhone());
        row.setCell(bean.getEmail());
        row.setCell(StringUtils.capitalize(
                bean.getFirstDestination() != null ? bean.getFirstDestination().getName().toLowerCase() : ""));
        row.setCell(StringUtils.capitalize(
                bean.getSecondDestination() != null ? bean.getSecondDestination().getName().toLowerCase()
                        : ""));
        row.setCell(StringUtils.capitalize(
                bean.getThirdDestination() != null ? bean.getThirdDestination().getName().toLowerCase() : ""));
        row.setCell(BundleUtil.getString(Bundle.ENUMERATION, bean.getEnglish().getQualifiedKey()));
        row.setCell(BundleUtil.getString(Bundle.ENUMERATION, bean.getFrench().getQualifiedKey()));
        row.setCell(BundleUtil.getString(Bundle.ENUMERATION, bean.getSpanish().getQualifiedKey()));
        row.setCell(BundleUtil.getString(Bundle.ENUMERATION, bean.getGerman().getQualifiedKey()));
        row.setCell(bean.getPreviousCandidacy() ? "Sim" : "No");
    }

    response.setContentType("application/vnd.ms-excel");
    response.setHeader("Content-disposition", "attachment; filename=" + search.getName() + ".xls");

    try {
        OutputStream outputStream = response.getOutputStream();
        sheet.exportToXLSSheet(outputStream);
        outputStream.close();
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
    return null;
}

From source file:com.activecq.api.helpers.WCMHelper.java

/**
 * Get the edit icon HTML img tag (&gt;img ...&lt;) for the specified
 * EditType/*from   ww  w .j  av a 2 s.  c  o  m*/
 *
 * @param editType
 * @return
 */
public static String getEditIconImgTag(WCMEditType.Type editType) {
    final String title = StringUtils.capitalize(editType.getName());

    return "<img src=\"/libs/cq/ui/resources/0.gif\"" + " " + "class=\"" + editType.getCssClass() + "\"" + " "
            + "alt=\"" + title + "\" " + "title=\"" + title + "\" />";
}