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:msi.gama.lang.gaml.ui.labeling.GamlLabelProvider.java

String text(final EObject ele) {
    String text;//from ww  w .ja va2  s  .c o m
    String key = EGaml.getKeyOf(ele);
    if (key == null) {
        key = "";
    }
    text = key;
    key = null;
    if (ele instanceof Statement) {
        if (text.equals(IKeyword.PARAMETER)) {
            return parameterText((Statement) ele);
        }
        if (GamlOutlineTreeProvider.isAttribute((Statement) ele)) {
            return attributeText((S_Definition) ele);
        }
        if (GamlOutlineTreeProvider.isAction((Statement) ele)) {
            return actionText((Statement) ele);
        }
        String name = EGaml.getNameOf((Statement) ele);
        if (name == null) {
            final Expression expr = ((Statement) ele).getExpr();
            if (expr != null) {
                name = EGaml.getKeyOf(expr);
            }
        }
        if (name == null) {
            QualifiedName qn = null;
            try {
                qn = nameProvider.getFullyQualifiedName(ele);
                name = qn == null ? null : qn.toString();
            } catch (final IllegalArgumentException e) {
                name = null;
            }

        }
        text += " " + (name == null ? "" : name);
    }
    // } else {
    // text = key + " " + qn.toString();
    // }
    return StringUtils.capitalize(text);
}

From source file:com.adobe.acs.commons.wcm.views.impl.WCMViewsServlet.java

@Override
protected final void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
        throws ServletException, IOException {

    response.setCharacterEncoding("UTF-8");
    response.setContentType("application/json");

    if (WCMMode.DISABLED.equals(WCMMode.fromRequest(request))) {
        response.setStatus(SlingHttpServletResponse.SC_NOT_FOUND);
        response.getWriter().write("");
        return;//from   w w w .ja  v  a2s. c  om
    }

    /* Valid WCMMode */

    final PageManager pageManager = request.getResourceResolver().adaptTo(PageManager.class);
    final Page page = pageManager.getContainingPage(request.getResource());

    final WCMViewsResourceVisitor visitor = new WCMViewsResourceVisitor();
    visitor.accept(page.getContentResource());

    final Set<String> viewSet = new HashSet<String>(visitor.getWCMViews());

    // Get the Views provided by the Servlet
    for (final Map.Entry<String, String[]> entry : this.defaultViews.entrySet()) {
        if (StringUtils.startsWith(page.getPath(), entry.getKey())) {
            viewSet.addAll(Arrays.asList(entry.getValue()));
        }
    }

    final List<String> views = new ArrayList<String>(viewSet);

    Collections.sort(views);

    log.debug("Collected WCM Views {} for Page [ {} ]", views, page.getPath());

    final JSONArray jsonArray = new JSONArray();

    for (final String view : views) {
        final JSONObject json = new JSONObject();

        try {
            json.put("title", StringUtils.capitalize(view) + " View");
            json.put("value", view);

            jsonArray.put(json);
        } catch (JSONException e) {
            log.error("Unable to build WCM Views JSON output.", e);
        }
    }

    response.getWriter().write(jsonArray.toString());
}

From source file:de.iteratec.iteraplan.businesslogic.exchange.xmi.importer.XmiHelper.java

/**
 * Searches the ReadMethod for the given EStructuralFeature
 * //from   w  w w .  j  a  v  a 2 s  .  c om
 * @param esf the given EStructuralFeature
 * @param entityClass the entity class to get the method from
 * @return the corresponding ReadMethod
 */
private static Method getReadMethod(EStructuralFeature esf, Class<?> entityClass) {
    try {
        String prefix = "get";
        if ((esf instanceof EAttribute) && esf.getEType().getName().startsWith("EBoolean")) {
            prefix = "is";
        }
        String methodName = prefix + StringUtils.capitalize(esf.getName());

        return entityClass.getMethod(methodName);
    } catch (SecurityException e) {
        LOGGER.error(e);
    } catch (NoSuchMethodException e) {
        LOGGER.error(e);
    }

    LOGGER.error("No getMethod for:" + esf.getName());
    return null;
}

From source file:fr.amapj.view.engine.basicform.BasicFormListPart.java

protected void addColumn(String propertyId) {
    colInfos.add(new ColumnInfo(propertyId, StringUtils.capitalize(propertyId)));
}

From source file:com.laxser.blitz.web.impl.module.ControllerRef.java

private void init() {
    List<MethodRef> actions = new LinkedList<MethodRef>();
    Class<?> clz = controllerClass;
    ///*from w w  w . j av  a 2 s.c o m*/
    List<Method> pastMethods = new LinkedList<Method>();
    while (true) {
        Method[] declaredMethods = clz.getDeclaredMethods();
        for (Method method : declaredMethods) {
            if (quicklyPass(pastMethods, method, controllerClass)) {
                continue;
            }

            Map<ReqMethod, String[]> shotcutMappings = collectsShotcutMappings(method);
            if (shotcutMappings.size() == 0) {
                if (ignoresCommonMethod(method)) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("ignores common methods of controller " + controllerClass.getName() + "#"
                                + method.getName());
                    }
                } else {
                    // TODO: ?0.91.0?201007??
                    if ("get".equals(method.getName()) || "index".equals(method.getName())) {
                        // ??get/index@Get?@Get??
                        throw new IllegalArgumentException(
                                "please add @Get to " + controllerClass.getName() + "#" + method.getName());
                    }
                    if ("post".equals(method.getName()) || "delete".equals(method.getName())
                            || "put".equals(method.getName())) {
                        // ??post/delete/put@Get/@Delete/@Put?@Get??
                        throw new IllegalArgumentException(
                                "please add @" + StringUtils.capitalize(method.getName()) + " to "
                                        + controllerClass.getName() + "#" + method.getName());
                    }
                    shotcutMappings = new HashMap<ReqMethod, String[]>();
                    shotcutMappings.put(ReqMethod.GET, new String[] { "/" + method.getName() });
                    shotcutMappings.put(ReqMethod.POST, new String[] { "/" + method.getName() });
                }
            }
            if (shotcutMappings.size() > 0) {
                MethodRef methodRef = new MethodRef();
                for (Map.Entry<ReqMethod, String[]> entry : shotcutMappings.entrySet()) {
                    methodRef.addMapping(entry.getKey(), entry.getValue());
                }
                methodRef.setMethod(method);
                actions.add(methodRef);
            }
        }
        for (int i = 0; i < declaredMethods.length; i++) {
            pastMethods.add(declaredMethods[i]);
        }
        clz = clz.getSuperclass();
        if (clz == null || clz.getAnnotation(AsSuperController.class) == null) {
            break;
        }
    }
    this.actions = actions;
}

From source file:info.magnolia.freemarker.FreemarkerUtil.java

/**
 * Same as {@link #createTemplateName(Class, String)} but adds the classifier between
 * the template name and the extension./*  w w w  .jav  a 2 s  .  c  o m*/
 */
public static String createTemplateName(Class<?> klass, String classifier, String ext) {
    classifier = (classifier != null) ? StringUtils.capitalize(classifier) : "";
    return "/" + StringUtils.replace(klass.getName(), ".", "/") + classifier + "." + ext;
}

From source file:ar.edu.taco.simplejml.methodinfo.MethodInformationBuilder.java

private String getCapitalizedClassName(String className) {
    StringBuffer capitalizedClassName = new StringBuffer();
    String[] classNameParts = className.split("/");

    for (String aString : classNameParts) {
        capitalizedClassName.append(StringUtils.capitalize(aString));
    }//from   w w w.j  a  va2  s  .c  om
    return capitalizedClassName.toString();
}

From source file:airlift.util.AirliftUtil.java

/**
 * Upper the first character.//from w  ww . jav  a 2s  .  co m
 *
 * @param _string the _string
 * @return the string
 */
public static String upperTheFirstCharacter(String _string) {
    return StringUtils.capitalize(_string);
}

From source file:gov.va.med.pharmacy.peps.presentation.common.displaytag.BaseExportView.java

/**
 * Write table header.// www .j  a v  a2s. c o  m
 * @return String rendered header
 */
protected String doHeaders() {

    final String ROW_START = getRowStart();
    final String ROW_END = getRowEnd();
    final String CELL_START = getCellStart();
    final String CELL_END = getCellEnd();
    final boolean ALWAYS_APPEND_CELL_END = getAlwaysAppendCellEnd();

    StringBuffer buffer = new StringBuffer(PPSConstants.I1000);

    Iterator iterator = this.model.getHeaderCellList().iterator();

    // start row
    if (ROW_START != null) {
        buffer.append(ROW_START);
    }

    while (iterator.hasNext()) {
        HeaderCell headerCell = (HeaderCell) iterator.next();

        String columnHeader = headerCell.getTitle();

        if (columnHeader == null) {
            columnHeader = StringUtils.capitalize(headerCell.getBeanPropertyName());
        }

        columnHeader = escapeColumnValue(columnHeader);

        if (CELL_START != null) {
            buffer.append(CELL_START);
        }

        if (columnHeader != null) {
            buffer.append(columnHeader);
        }

        if (CELL_END != null && (ALWAYS_APPEND_CELL_END || iterator.hasNext())) {
            buffer.append(CELL_END);
        }
    }

    // end row
    if (ROW_END != null) {
        buffer.append(ROW_END);
    }

    return buffer.toString();

}

From source file:de.forsthaus.webui.calendar.model.CalendarDateFormatter.java

/**
 * This is for showing the Daynames in the month view, means mold="month" .<br>
 * EN: on top of every column the 2 digits day name is shown.<br>
 * DE: oberhalb jeder Spalte wird der Tagesnamen (2-stellig) angezeigt.<br>
 *///from   ww w .j  a va2 s  . co  m
@Override
public String getCaptionByDayOfWeek(Date date, Locale locale, TimeZone timezone) {

    String day = null;

    if (date.getDay() == 0) {
        day = Labels.getLabel("common.dayname.sunday.3");
    } else if (date.getDay() == 1) {
        day = Labels.getLabel("common.dayname.monday.3");
    } else if (date.getDay() == 2) {
        day = Labels.getLabel("common.dayname.tuesday.3");
    } else if (date.getDay() == 3) {
        day = Labels.getLabel("common.dayname.wednesday.3");
    } else if (date.getDay() == 4) {
        day = Labels.getLabel("common.dayname.thursday.3");
    } else if (date.getDay() == 5) {
        day = Labels.getLabel("common.dayname.friday.3");
    } else if (date.getDay() == 6) {
        day = Labels.getLabel("common.dayname.saturday.3");
    }

    day = StringUtils.capitalize(day.toLowerCase());

    return day;
}