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

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

Introduction

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

Prototype

public static String capitalize(final String str) 

Source Link

Document

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

Usage

From source file:de.adorsys.forge.gwt.GWTFacet.java

private String getClassPrefix() {
    String artifactId = getSaveProjectName();
    return StringUtils.capitalize(artifactId);
}

From source file:com.systematic.healthcare.fhir.generator.Generator.java

private String convertNameToValidJavaIdentifier(String enumName) {
    StringBuilder b = new StringBuilder();
    for (String part : enumName.split("[ ]")) {
        b.append(StringUtils.capitalize(part));
    }/* w w  w. j  a  va2 s  .co m*/
    return b.toString().replaceAll("[ \\.\\?]", "");
}

From source file:com.neatresults.mgnltweaks.neatu2b.ui.form.field.U2BField.java

/**
 * Create a single element.<br>/*from ww  w . ja va  2s  .co  m*/
 * This single element is composed of:<br>
 * - a configured field <br>
 * - a remove Button<br>
 */
private Component createEntryComponent(String propertyId, PropertysetItem newValue) {
    String cappedId = StringUtils.capitalize(propertyId);
    final HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setHeight(-1, Unit.PIXELS);
    TextField url = createTextField(cappedId + " Thumbnail", newValue, propertyId + "Url");
    layout.addComponent(url);

    TextField width = createTextField("Width", newValue, propertyId + "Width");
    layout.addComponent(width);
    TextField height = createTextField("Height", newValue, propertyId + "Height");
    layout.addComponent(height);
    layout.setExpandRatio(url, .7f);
    layout.setExpandRatio(width, .15f);
    layout.setExpandRatio(height, .15f);

    return layout;
}

From source file:com.wrmsr.wava.compile.memory.LoadStoreCompilerImpl.java

private JMethod createLengthUnsignedLoad(Class<?> p, Class<?> t, int len, Object mask) {
    return new JMethod(immutableEnumSet(JAccess.PROTECTED, JAccess.FINAL), JTypeSpecifier.of(p.getName()),
            JName.of("_load" + StringUtils
                    .capitalize(p.getName()) + len + "u"),
            ImmutableList.of(new JArg(JTypeSpecifier.of("int"),
                    JName.of("ptr"))),
            Optional.of(//from www .  j ava2 s.  com
                    new JBlock(
                            ImmutableList
                                    .of(new JReturn(
                                            Optional.of(
                                                    new JBinary(JBinaryOp.BitwiseAnd,
                                                            JMethodInvocation.of(
                                                                    JQualifiedName.of("this", "_memory",
                                                                            "get" + (t == byte.class ? ""
                                                                                    : StringUtils.capitalize(
                                                                                            t.getName()))),
                                                                    ImmutableList.of(new JIdent(
                                                                            JQualifiedName.of("ptr")))),
                                                            new JLiteral(mask))))))));
}

From source file:com.erudika.para.utils.ValidationUtils.java

/**
 * Returns the JSON object containing all validation constraints for all the core Para classes and classes defined
 * by the given app./*  ww w .j  a  v a 2s.c  o  m*/
 *
 * @param app an app
 * @return JSON string
 */
public static String getAllValidationConstraints(App app) {
    String json = "{}";
    try {
        ObjectNode parentNode = Utils.getJsonMapper().createObjectNode();
        for (String type : RestUtils.getAllTypes(app).values()) {
            Map<?, ?> constraintsNode = getValidationConstraints(app, type);
            if (constraintsNode.size() > 0) {
                parentNode.putPOJO(StringUtils.capitalize(type), constraintsNode);
            }
        }
        json = Utils.getJsonWriter().writeValueAsString(parentNode);
    } catch (IOException ex) {
        logger.error(null, ex);
    }
    return json;
}

From source file:com.marand.thinkmed.medications.dto.report.TherapyDayReportUtils.java

public static String getTherapyApplicationColumnValue(List<AdministrationDto> therapyAdministrations,
        @Nonnull final TherapyDto order, @Nonnull final Date startDate, final int column,
        @Nonnull Locale locale) {
    final DateTime day = new DateTime(startDate).plusDays(column).withTimeAtStartOfDay();
    final StringBuilder administrationString = new StringBuilder();

    if (therapyAdministrations != null) {
        Collections.sort(therapyAdministrations,
                Comparator.comparing(AdministrationDto::getAdministrationTime));
        for (final AdministrationDto administration : therapyAdministrations) {
            final DateTime administrationTime = administration.getAdministrationTime();
            if (administrationTime != null && administrationTime.withTimeAtStartOfDay().isEqual(day)) {
                final StringBuilder dose = new StringBuilder();

                if (administration.getAdministrationResult() == AdministrationResultEnum.DEFER) {
                    dose.append(StringUtils.capitalize(getDictionaryEntry("administration.defer", locale)));

                    if (administration.getNotAdministeredReason() != null
                            && administration.getNotAdministeredReason().getName() != null) {
                        dose.append(" - ").append(administration.getNotAdministeredReason().getName());
                    }/*from   w w  w . ja va2 s.c o m*/
                } else if (administration.getAdministrationResult() == AdministrationResultEnum.NOT_GIVEN) {
                    dose.append(StringUtils.capitalize(getDictionaryEntry("administration.not.given", locale)));

                    if (administration.getNotAdministeredReason() != null
                            && administration.getNotAdministeredReason().getName() != null) {
                        dose.append(" - ").append(administration.getNotAdministeredReason().getName());
                    }
                } else {
                    if (administration instanceof StartAdministrationDto) {
                        final TherapyDoseDto administeredDose = ((StartAdministrationDto) administration)
                                .getAdministeredDose();
                        if (administeredDose != null && administeredDose.getNumerator() != null
                                && administeredDose.getNumeratorUnit() != null) {
                            try {
                                dose.append(NumberFormatters.doubleFormatter2(locale)
                                        .valueToString(administeredDose.getNumerator()) + " "
                                        + administeredDose.getNumeratorUnit());
                            } catch (final ParseException e) {
                                e.printStackTrace();
                            }
                        }
                    } else if (administration instanceof AdjustInfusionAdministrationDto) {
                        final TherapyDoseDto administeredDose = ((AdjustInfusionAdministrationDto) administration)
                                .getAdministeredDose();
                        if (administeredDose.getNumerator() != null
                                && administeredDose.getNumeratorUnit() != null) {
                            try {
                                dose.append(NumberFormatters.doubleFormatter2(locale)
                                        .valueToString(administeredDose.getNumerator()) + " "
                                        + administeredDose.getNumeratorUnit());
                            } catch (ParseException e) {
                                e.printStackTrace();
                            }
                        }
                    } else if (administration instanceof InfusionSetChangeDto) {
                        //noinspection SwitchStatement
                        switch (((InfusionSetChangeDto) administration).getInfusionSetChangeEnum()) {
                        case INFUSION_SYRINGE_CHANGE:
                            dose.append(getDictionaryEntry("infusion.syringe.change", locale));
                            break;

                        case INFUSION_SYSTEM_CHANGE:
                            dose.append(getDictionaryEntry("infusion.system.change", locale));
                            break;
                        }
                    } else if (administration instanceof StopAdministrationDto) {
                        dose.append(getDictionaryEntry("infusion.stopped", locale));
                    }
                }

                if (administration.getComment() != null) {
                    dose.append(" - ").append(administration.getComment());
                }

                administrationString.append(String.format("<b>%02d:%02d<br></b>%s<br><br>",
                        administrationTime.getHourOfDay(), administrationTime.getMinuteOfHour(), dose));
            }
        }
    }

    return administrationString.toString();
}

From source file:com.hesine.manager.generate.Generate.java

public static void execute(File curProjectPath, String packageName, String moduleName,
        Map<String, String> table, List<Map<String, String>> fileds) {
    // ==========  ?? ====================

    // ??????/* w w w . j av a2 s.  c  o  m*/
    // ?{packageName}/{moduleName}/{dao,entity,service,web}/{subModuleName}/{className}

    // packageName ????applicationContext.xmlsrping-mvc.xml?base-package?packagesToScan?4?
    //        String packageName = "com.hesine.manager";

    //      String moduleName = "function";         // ???sys
    //        String moduleName = "";         // ???sys
    //        String tableName = "tb_product";         // ???sys
    //        String subModuleName = "";            // ?????
    //        String className = "product";         // ??product
    //        String classAuthor = "Jason";      // ThinkGem
    //        String functionName = "?";         // ??
    String tableName = table.get("tableName"); // ???sys
    String subModuleName = ""; // ?????
    String className = table.get("className"); // ??product
    String classAuthor = "Jason"; // ThinkGem
    String functionName = table.get("comment"); // ??

    // ???
    Boolean isEnable = true;

    // ==========  ?? ====================

    if (!isEnable) {
        logger.error("????isEnable = true");
        return;
    }

    //        StringUtils.isBlank(moduleName) ||
    if (StringUtils.isBlank(packageName) || StringUtils.isBlank(className)
            || StringUtils.isBlank(functionName)) {
        logger.error("??????????????");
        return;
    }

    // ?
    String separator = File.separator;

    // ?
    File projectPath = curProjectPath;
    //        while(!new File(projectPath.getPath()+separator+"src"+separator+"main").exists()){
    //            projectPath = projectPath.getParentFile();
    //        }
    logger.info("Project Path: {}", projectPath);

    // ?
    String tmpProjectPath = "/Users/zhanghongbing/Workspaces/Projects/hesine-projects/github-framework/hesine-demo/hesine-portal";
    String tplPath = StringUtils.replace(tmpProjectPath + "/src/main/java/com/hesine/manager/generate/template",
            "/", separator);
    //        String tplPath = StringUtils.replace(projectPath+"/src/main/java/com/hesine/manager/generate/template", "/", separator);
    logger.info("Template Path: {}", tplPath);

    // Java
    String javaPath = StringUtils.replaceEach(
            projectPath + "/src/main/java/" + StringUtils.lowerCase(packageName), new String[] { "/", "." },
            new String[] { separator, separator });
    logger.info("Java Path: {}", javaPath);

    // Xml
    String xmlPath = StringUtils.replace(projectPath + "/src/main/resources/mybatis", "/", separator);
    logger.info("Xml Path: {}", xmlPath);

    // 
    String viewPath = StringUtils.replace(projectPath + "/src/main/webapp/WEB-INF/views", "/", separator);
    logger.info("View Path: {}", viewPath);

    // ???
    Map<String, Object> model = Maps.newHashMap();
    model.put("packageName", StringUtils.lowerCase(packageName));
    model.put("moduleName", StringUtils.lowerCase(moduleName));
    model.put("subModuleName",
            StringUtils.isNotBlank(subModuleName) ? "." + StringUtils.lowerCase(subModuleName) : "");
    model.put("className", StringUtils.uncapitalize(className));
    model.put("ClassName", StringUtils.capitalize(className));
    model.put("classAuthor", StringUtils.isNotBlank(classAuthor) ? classAuthor : "Generate Tools");
    model.put("classVersion", DateUtils.getDate());
    model.put("functionName", functionName);
    //      model.put("tableName", model.get("moduleName")+(StringUtils.isNotBlank(subModuleName)
    //            ?"_"+StringUtils.lowerCase(subModuleName):"")+"_"+model.get("className"));
    model.put("tableName", tableName);

    model.put("urlPrefix",
            model.get("moduleName")
                    + (StringUtils.isNotBlank(subModuleName) ? "/" + StringUtils.lowerCase(subModuleName) : "")
                    + "/" + model.get("className"));
    model.put("viewPrefix", //StringUtils.substringAfterLast(model.get("packageName"),".")+"/"+
            model.get("urlPrefix"));
    model.put("permissionPrefix",
            model.get("moduleName")
                    + (StringUtils.isNotBlank(subModuleName) ? ":" + StringUtils.lowerCase(subModuleName) : "")
                    + ":" + model.get("className"));
    model.put("fileds", fileds);

    // ? Entity
    FileGenUtils.generateEntity(tplPath, javaPath, model);

    // ? sqlMap
    FileGenUtils.generateSqlMap(tplPath, xmlPath, model);

    // ? Model
    FileGenUtils.generateModel(tplPath, javaPath, model);

    // ? Dao
    FileGenUtils.generateDao(tplPath, javaPath, model);

    // ? Service
    FileGenUtils.generateService(tplPath, javaPath, model);

    // ? ServiceImpl
    FileGenUtils.generateServiceImpl(tplPath, javaPath, model);

    // ? Controller
    FileGenUtils.generateController(tplPath, javaPath, model);
    //
    //        // ? add.ftl
    //        FileGenUtils.generateAddFtl(tplPath, viewPath, model);
    //
    //        // ? edit.ftl
    //        FileGenUtils.generateEditFtl(tplPath, viewPath, model);

    //        // ? list.ftl
    //        FileGenUtils.generateListFtl(tplPath, viewPath, model);

    logger.info("Generate Success.");
}

From source file:com.google.testing.pogen.generator.test.java.TestCodeGenerator.java

/**
 * Appends a getter method for the text of html tag which contains the variable specified by the
 * name into the given string builder.//from  w ww  . j a v a2  s .c o  m
 * 
 * @param methodBuilder {@link StringBuilder} the generated method will be appended to
 * @param uniqueVariableName the unique variable name with a sequential number
 * @param tagInfo the information of the html tag containing the template variable
 * @param varInfo the information of the template variable
 * @param isRepeated the boolean whether the specified html tag appears in a repeated part
 */
private void appendTextGetter(StringBuilder methodBuilder, String uniqueVariableName, HtmlTagInfo tagInfo,
        VariableInfo varInfo, boolean isRepeated) {
    // TODO(kazuu): Help to select proper one from getFoo, getFoo2, getFoo3 ...
    appendLine(methodBuilder);
    String methodNamePrefix = !isRepeated ? "String getTextOf" : "List<String> getTextsOf";
    String foundedProcess = !isRepeated ? "return matcher.group(3);" : "result.add(matcher.group(3));";
    String finalProcess = !isRepeated ? "return null;" : "return result;";
    appendLine(methodBuilder, 1,
            String.format("public %s%s() {", methodNamePrefix, StringUtils.capitalize(uniqueVariableName)));
    if (isRepeated) {
        appendLine(methodBuilder, 2, "List<String> result = new ArrayList<String>();");
    }
    appendLine(methodBuilder, 2, "Matcher matcher = commentPattern.matcher(driver.getPageSource());");
    appendLine(methodBuilder, 2, "while (matcher.find()) {");
    appendLine(methodBuilder, 3,
            String.format("if (matcher.group(1).equals(\"%s\") && matcher.group(2).equals(\"%s\")) {",
                    tagInfo.getAttributeValue(), varInfo.getName()));
    appendLine(methodBuilder, 4, foundedProcess);
    appendLine(methodBuilder, 3, "}");
    appendLine(methodBuilder, 2, "}");
    appendLine(methodBuilder, 2, finalProcess);
    appendLine(methodBuilder, 1, "}");
}

From source file:com.aol.one.patch.DefaultPatcher.java

private void invokeAddMethod(Object object, String fieldName, JsonNode valueNode)
        throws IllegalAccessException, InvocationTargetException, PatchException {

    if (object instanceof Patchable) {
        Patchable patchable = (Patchable) object;
        patchable.addValue(fieldName, valueNode);
        return;/*from ww w  .  j  a  v  a 2s. c  o  m*/
    }

    if (StringUtils.isNumeric(fieldName) && object instanceof java.util.List) {
        List tmpList = (List) object;
        // WARN: inserting JsonNode into list
        tmpList.add(Integer.parseInt(fieldName), valueNode);
        return;
    }

    if (object instanceof java.util.Map) {
        Map tmpMap = (Map) object;
        // WARN: adding (String, Json) entry to Map, type of Map not known.
        tmpMap.put(fieldName, valueNode);
        return;
    }

    // first try to find set+CapitalizedField or add+CapitalizedField
    List<String> methodNames = new ArrayList<>();
    methodNames.add("set" + StringUtils.capitalize(fieldName));
    methodNames.add("add" + StringUtils.capitalize(fieldName));

    List<MethodData> methodDataList = generateMethodData(methodNames, valueNode);

    // final try, standard method
    List<Class<?>> argTypes = new ArrayList<>();
    argTypes.add(String.class);
    argTypes.add(JsonNode.class);

    List<Object> params = new ArrayList<>();
    params.add(fieldName);
    params.add(valueNode);

    MethodData standardMethodData = new MethodData(STANDARD_ADD_METHOD, argTypes, params);
    methodDataList.add(standardMethodData);

    invokeMethodFromMethodDataList(object, methodDataList);
}

From source file:com.qtplaf.library.util.Calendar.java

/**
 * Returns an array of localized names of months.
 *
 * @return An array of names./*from  ww  w. j a v a2s  . co m*/
 * @param locale The desired locale.
 * @param capitalized A boolean to capitalize the name.
 */
public static String[] getShortMonths(Locale locale, boolean capitalized) {

    DateFormatSymbols sysd = new DateFormatSymbols(locale);
    String[] dsc = sysd.getShortMonths();
    if (capitalized) {
        for (int i = 0; i < dsc.length; i++) {
            dsc[i] = StringUtils.capitalize(dsc[i]);
        }
    }
    return dsc;
}