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:com.sap.research.connectivity.gw.GWOperationsUtils.java

private String makeGWShowFieldCode(String tabLevels, String entityName, String remoteEntity,
        Map.Entry<String[], String> field) {
    String startCast = "", endCast = "", returnString = "";
    String remoteFieldName = field.getKey()[0];
    String localFieldName = field.getKey()[1];

    if (field.getValue().equals("DateTime")) {
        returnString = tabLevels + "DateTime " + localFieldName.toLowerCase()
                + "DT = DTformatter.parseDateTime(" + remoteEntity + ".getProperty(\"" + remoteFieldName
                + "\").getValue().toString());\n";
        returnString += tabLevels + "Date " + localFieldName.toLowerCase() + "ConvertedDate = "
                + localFieldName.toLowerCase() + "DT.toDate();\n";
        returnString += tabLevels + entityName + ".set" + StringUtils.capitalize(localFieldName) + "("
                + localFieldName.toLowerCase() + "ConvertedDate);\n";

    } else if (field.getValue().equals("DateTimeOffset")) {
        returnString = tabLevels + "DateTime " + localFieldName.toLowerCase()
                + "DT = DTOformatter.parseDateTime(" + remoteEntity + ".getProperty(\"" + remoteFieldName
                + "\").getValue().toString());\n";
        returnString += tabLevels + "Date " + localFieldName.toLowerCase() + "ConvertedDate = "
                + localFieldName.toLowerCase() + "DT.toDate();\n";
        returnString += tabLevels + entityName + ".set" + StringUtils.capitalize(localFieldName) + "("
                + localFieldName.toLowerCase() + "ConvertedDate);\n";

    } else {/*from w w w  .  ja  va2  s.c  om*/
        String javaType = GwUtils.odataToJavaType(field.getValue());
        startCast = GwUtils.generateCast(javaType);
        if (!startCast.isEmpty())
            endCast = ")";

        returnString = tabLevels + entityName + ".set" + StringUtils.capitalize(localFieldName) + "("
                + startCast + remoteEntity + ".getProperty(\"" + remoteFieldName + "\").getValue().toString()"
                + endCast + ");\n";
    }

    return returnString;
}

From source file:com.moviejukebox.model.Movie.java

public boolean addActor(String actorKey, String actorName, String character, String actorUrl, String doublage,
        String source) {/*w  ww.ja v  a2s  .c om*/
    boolean added = Boolean.FALSE;

    if (actorName != null) {
        String name = actorName;
        if (actorName.indexOf(':') > -1) {
            String[] names = actorName.split(":");
            if (StringTools.isValidString(names[1])) {
                name = names[1];
            } else if (StringTools.isValidString(names[0])) {
                name = names[0];
            }
        }

        name = name.trim();
        boolean found = Boolean.FALSE;
        for (Filmography p : people) {
            if (p.getName().equalsIgnoreCase(name) && p.getDepartment().equals(Filmography.DEPT_ACTORS)) {
                found = Boolean.TRUE;
                break;
            }
        }

        if (!found) {
            added = addPerson(actorKey, actorName, actorUrl, StringUtils.capitalize(Filmography.JOB_ACTOR),
                    character, doublage, source);
            if (added) {
                setOverrideSource(OverrideFlag.PEOPLE_ACTORS, source);
            }
        }
    }
    return added;
}

From source file:com.sap.research.connectivity.gw.GWOperationsUtils.java

private String makeLocalShowFieldCode(String tabLevels, String entityName, String remoteEntity,
        String fieldName) {//w ww .jav  a2  s. com

    String returnString = entityName + ".set" + StringUtils.capitalize(fieldName) + "(local" + remoteEntity
            + "== null ? null : local" + remoteEntity + ".get" + StringUtils.capitalize(fieldName) + "());\n"
            + tabLevels;

    return returnString;
}

From source file:act.installer.reachablesexplorer.FreemarkerRenderer.java

private String renderSetOfProteinDesignMetadata(Set<ProteinInformation> proteinInformationSet) {
    List<String> listOfProteinMetaData = proteinInformationSet.stream().filter(Objects::nonNull)
            .map(this::renderProteinMetadata).collect(Collectors.toList());
    String concatenatedListOfProteinMetaData = StringUtils.join(listOfProteinMetaData, ", ");
    return StringUtils.capitalize(concatenatedListOfProteinMetaData);
}

From source file:com.sap.research.connectivity.gw.GWOperationsUtils.java

public void addKeyInGWJavaFile(Map<String[], String> keys, JavaSourceFileEditor entityClassFile,
        Map.Entry<String[], String> key) {
    //Map ODataFieldTypes to JavaTypes 
    String oDataType = key.getValue();
    String javaType = GwUtils.odataToJavaType(oDataType);

    String localFieldName = key.getKey()[1];
    JavaSourceFieldBuilder fieldBuilder = new JavaSourceFieldBuilder().fieldPrefix("private")
            .fieldType(javaType).fieldName(localFieldName).fieldValue("");

    if (localFieldName.equals("Id"))
        fieldBuilder = fieldBuilder.fieldAnnotations("@Id\n\t@Column(name = \"id\")");
    // \t@GeneratedValue(strategy = GenerationType.AUTO)\n

    if (key.getValue().equals("DateTime"))
        fieldBuilder = fieldBuilder//from   ww  w.ja va 2 s.c o m
                .fieldAnnotations("@Temporal(TemporalType.TIMESTAMP)\n\t@DateTimeFormat(style=\"M-\")");

    JavaSourceField fieldDeclaration = fieldBuilder.build();

    entityClassFile.addGlobalField(fieldDeclaration);

    if (!localFieldName.equals("Id")) {
        JavaSourceMethod getMethod = new JavaSourceMethodBuilder()
                .methodName("get" + StringUtils.capitalize(localFieldName)).methodPrefix("public")
                .returnType(javaType).methodBody("\t\t" + "return" + " " + "this." + localFieldName + ";\n")
                .build();
        entityClassFile.addMethod(getMethod);

        ArrayList<String> parameters = new ArrayList<String>();
        parameters.add(javaType + " " + localFieldName);

        JavaSourceMethod setMethod = new JavaSourceMethodBuilder()
                .methodName("set" + StringUtils.capitalize(localFieldName)).methodPrefix("public")
                .returnType("void").parameters(parameters)
                .methodBody("\t\t" + "this." + localFieldName + " = " + localFieldName + ";\n").build();

        entityClassFile.addMethod(setMethod);
    }
}

From source file:at.bitfire.davdroid.resource.LocalAddressBook.java

protected static String xNameToLabel(String xname) {
    // "X-MY_PROPERTY"
    // 1. ensure lower case -> "x-my_property"
    // 2. remove x- from beginning -> "my_property"
    // 3. replace "_" by " " -> "my property"
    // 4. capitalize -> "My Property"
    String lowerCase = StringUtils.lowerCase(xname, Locale.US),
            withoutPrefix = StringUtils.removeStart(lowerCase, "x-"),
            withSpaces = StringUtils.replace(withoutPrefix, "_", " ");
    return StringUtils.capitalize(withSpaces);
}

From source file:com.sap.research.connectivity.gw.GWOperationsUtils.java

private void addFieldInGWJavaFile(JavaSourceFileEditor entityClassFile, String fieldName, String fieldValue,
        String javaType, String annotations) throws Exception {
    JavaSourceFieldBuilder fieldBuilder = new JavaSourceFieldBuilder().fieldPrefix("private")
            .fieldType(javaType).fieldName(fieldName).fieldValue(fieldValue);

    if (javaType.toLowerCase().contains("date") || javaType.toLowerCase().contains("calendar"))
        annotations += "\n\t" + "@Temporal(TemporalType.TIMESTAMP)\n\t@DateTimeFormat(style=\"M-\")";

    fieldBuilder = fieldBuilder.fieldAnnotations(annotations);
    JavaSourceField fieldDeclaration = fieldBuilder.build();

    if (entityClassFile.fieldExists(fieldDeclaration.getFieldName()))
        throw new Exception("Field \"" + fieldDeclaration.getFieldName()
                + "\" already exists in java class file " + entityClassFile.CLASS_NAME);

    entityClassFile.addGlobalField(fieldDeclaration);

    JavaSourceMethod getMethod = new JavaSourceMethodBuilder()
            .methodName("get" + StringUtils.capitalize(fieldName)).methodPrefix("public").returnType(javaType)
            .methodBody("\t\t" + "return" + " " + "this." + fieldName + ";\n").build();
    entityClassFile.addMethod(getMethod);

    ArrayList<String> parameters = new ArrayList<String>();
    parameters.add(javaType + " " + fieldName);

    JavaSourceMethod setMethod = new JavaSourceMethodBuilder()
            .methodName("set" + StringUtils.capitalize(fieldName)).methodPrefix("public").returnType("void")
            .parameters(parameters).methodBody("\t\t" + "this." + fieldName + " = " + fieldName + ";\n")
            .build();/*from ww  w.  j  a  v  a 2  s.  co  m*/

    entityClassFile.addMethod(setMethod);
}

From source file:com.sap.research.connectivity.gw.GWOperationsUtils.java

private String makeGWPersistFieldCode(String tabLevels, Map.Entry<String[], String> fieldObj) {
    String reversedCast = "", dateTimeOffsetCastStart = "", dateTimeOffsetCastEnd = "";
    String remoteFieldName = fieldObj.getKey()[0];
    String localFieldName = fieldObj.getKey()[1];
    if (fieldObj.getValue().equals("DateTimeOffset")) {
        reversedCast = "datetimeOffset";
        dateTimeOffsetCastStart = "new DateTime(";
        dateTimeOffsetCastEnd = ")";
    } else {//from   w ww  .  j  a v  a 2  s . com
        reversedCast = GwUtils.generateReversedCast(GwUtils.odataToJavaType(fieldObj.getValue()));
    }

    return tabLevels + ".properties(OProperties." + reversedCast + "(\"" + remoteFieldName + "\", "
            + dateTimeOffsetCastStart + "get" + StringUtils.capitalize(localFieldName) + "()"
            + dateTimeOffsetCastEnd + "))\n";
}

From source file:co.touchlab.squeaky.processor.AnnotationProcessor.java

private void makeCopyRow(List<DatabaseTableHolder> databaseTableHolders, TypeElement fieldElement,
        FieldTypeGen config, CodeBlock.Builder builder, int count) {
    {/*from  w  ww. j a va 2s .com*/
        AccessDataHolder accessDataHolder = new AccessDataHolder(databaseTableHolders, fieldElement, config,
                count).invoke();
        String accessData = accessDataHolder.getAccessData();
        boolean checkNull = accessDataHolder.isCheckNull();

        if (accessData != null) {
            StringBuilder sb = new StringBuilder();

            if (config.foreign) {
                ConfigureClassDefinitions configureClassDefinitions = new ConfigureClassDefinitions(
                        databaseTableHolders,
                        (TypeElement) ((DeclaredType) config.fieldElement.asType()).asElement()).invoke();
                ClassName className = ClassName.get(fieldElement);

                CodeBlock.Builder foreignBuilder = CodeBlock.builder();
                foreignBuilder.add("if(!results.isNull(" + count + ")){");
                foreignBuilder.addStatement("$T __$N = $T.instance.createObject(null)",
                        configureClassDefinitions.className, config.fieldName,
                        configureClassDefinitions.configName);
                foreignBuilder.addStatement("$T.instance.assignId(__$N, $N)",
                        configureClassDefinitions.configName, config.fieldName, accessData);

                foreignBuilder.beginControlFlow(
                        "if(foreignRefreshMap != null && $T.findRefresh(foreignRefreshMap, $S) != null)",
                        DaoHelper.class, config.fieldName);
                foreignBuilder.addStatement(
                        "modelDao.getOpenHelper().getDao($T.class).refresh(__$N, $T.findRefresh(foreignRefreshMap, $S).refreshFields)",
                        configureClassDefinitions.className, config.fieldName, DaoHelper.class,
                        config.fieldName);
                foreignBuilder.endControlFlow();

                if (config.useGetSet) {
                    sb.append("data.set").append(StringUtils.capitalize(config.fieldName)).append("(")
                            .append("__" + config.fieldName).append(")");
                } else {
                    sb.append("data.").append(config.fieldName).append(" = ").append("__" + config.fieldName);
                }

                foreignBuilder.addStatement(sb.toString());
                foreignBuilder.add("}");
                builder.add(foreignBuilder.build());

            } else {
                if (checkNull)
                    sb.append("if(!results.isNull(" + count + "))");

                if (config.useGetSet) {
                    sb.append("data.set").append(StringUtils.capitalize(config.fieldName)).append("(")
                            .append(accessData).append(")");
                } else {
                    sb.append("data.").append(config.fieldName).append(" = ").append(accessData);
                }

                builder.addStatement(sb.toString());
            }
        }
    }
}

From source file:com.sap.research.connectivity.gw.GWOperationsUtils.java

private String makeGWShowRelationshipCode(String className, String virtualLocalEntityInstance,
        String remoteEntity, String remoteId, String nav, String javaType, String associationType, String tabs,
        boolean isFirstManyToMany) {
    String smallClassName = StringUtils.uncapitalize(className);
    String capitalNav = StringUtils.capitalize(nav);
    String returnString = "";
    if ("ManyToOne OneToOne".contains(associationType)) {
        returnString += "OEntity remote" + javaType + " = " + GwUtils.GW_CONNECTION_FIELD_NAME
                + ".rooODataConsumer.getEntity(\"" + className + "\", " + remoteId + ").nav(\"" + nav
                + "\").execute();\n";
        returnString += tabs + javaType + " virtual" + javaType + " = " + javaType + ".find" + javaType
                + "(remote" + javaType + ".getEntityKey().toKeyString());\n";
        returnString += tabs + virtualLocalEntityInstance + ".set" + javaType + "(virtual" + javaType + ");\n"
                + tabs;/* w w w .  ja  v  a2s . c om*/
    } else {
        String extraReturn = "";
        if (isFirstManyToMany) {
            returnString += "List<OLink> " + smallClassName + "Links = " + remoteEntity + ".getLinks();\n"
                    + tabs + "\tfor(OLink " + smallClassName + "Link : " + smallClassName + "Links) {\n" + tabs
                    + "\t\tif (" + smallClassName + "Link.isCollection()) {\n";
            extraReturn = "\n";
        }

        returnString += extraReturn + tabs + "\t\t\tif (" + smallClassName + "Link.getTitle().equals(\"" + nav
                + "\")) {\n" + tabs + "\t\t\t\tSet<" + javaType + "> virtual" + javaType + "List = new HashSet<"
                + javaType + ">();\n" + tabs + "\t\t\t\tList<OEntity> remote" + javaType + "List = "
                + GwUtils.GW_CONNECTION_FIELD_NAME + ".rooODataConsumer.getEntities("
                + "OLinks.relatedEntities(" + smallClassName + "Link.getRelation(), " + smallClassName
                + "Link.getTitle(), " + smallClassName + "Link.getHref()))\n" + tabs
                + "\t\t\t\t.execute().toList();\n" + tabs + "\t\t\t\tfor (OEntity remote" + javaType
                + " : remote" + javaType + "List) {\n" + tabs + "\t\t\t\t\t" + javaType + " virtual" + javaType
                + " = " + javaType + ".find" + javaType + "(remote" + javaType
                + ".getEntityKey().toKeyString());\n" + tabs + "\t\t\t\t\tvirtual" + javaType
                + "List.add(virtual" + javaType + ");\n" + tabs + "\t\t\t\t}\n" + tabs + "\t\t\t\t"
                + virtualLocalEntityInstance + ".set" + capitalNav + "(virtual" + javaType + "List);\n" + tabs
                + "\t\t\t}\n";

        if (isFirstManyToMany)
            returnString += tabs + "\t\t}\n" + tabs + "}\n" + tabs;
    }

    return returnString;
}