Java Code Examples for org.apache.commons.lang.WordUtils#capitalize()

The following examples show how to use org.apache.commons.lang.WordUtils#capitalize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractDataPreparer.java    From das with Apache License 2.0 6 votes vote down vote up
protected String getPojoClassName(String prefix, String suffix, String tableName) {
    String className = tableName;
    if (null != prefix && !prefix.isEmpty() && className.indexOf(prefix) == 0) {
        className = className.replaceFirst(prefix, "");
    }
    if (null != suffix && !suffix.isEmpty()) {
        className = className + WordUtils.capitalize(suffix);
    }

    StringBuilder result = new StringBuilder();
    for (String str : StringUtils.split(className, "_")) {
        result.append(WordUtils.capitalize(str));
    }

    return WordUtils.capitalize(result.toString());
}
 
Example 2
Source File: AbstractCSharpDataPreparer.java    From dal with Apache License 2.0 6 votes vote down vote up
protected String getPojoClassName(String prefix, String suffix, String table) {
    String className = table;
    if (null != prefix && !prefix.isEmpty() && className.indexOf(prefix) == 0) {
        className = className.replaceFirst(prefix, "");
    }
    if (null != suffix && !suffix.isEmpty()) {
        className = className + WordUtils.capitalize(suffix);
    }

    StringBuilder result = new StringBuilder();
    for (String str : StringUtils.split(className, "_")) {
        result.append(WordUtils.capitalize(str));
    }

    return WordUtils.capitalize(result.toString());
}
 
Example 3
Source File: AbstractJavaDataPreparer.java    From dal with Apache License 2.0 6 votes vote down vote up
protected String getPojoClassName(String prefix, String suffix, String tableName) {
    String className = tableName;
    if (null != prefix && !prefix.isEmpty() && className.indexOf(prefix) == 0) {
        className = className.replaceFirst(prefix, "");
    }
    if (null != suffix && !suffix.isEmpty()) {
        className = className + WordUtils.capitalize(suffix);
    }

    StringBuilder result = new StringBuilder();
    for (String str : StringUtils.split(className, "_")) {
        result.append(WordUtils.capitalize(str));
    }

    return WordUtils.capitalize(result.toString());
}
 
Example 4
Source File: JavaParameterHost.java    From das with Apache License 2.0 5 votes vote down vote up
public String getCapitalizedName() {
    String tempName = name.replace("@", "");
    // if (tempName.contains("_")) {
    // tempName = WordUtils.capitalizeFully(tempName.replace('_', ' ')).replace(" ", "");
    // }
    return WordUtils.capitalize(tempName);
}
 
Example 5
Source File: XMLMappingGenerator.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
private String printPredicateObjectMap(String predicate, String reference,
		String type, String typeprefix, String predicatedprefix,
		String function, String classname, boolean isgeometrypredicate) {
	predicate = predicate.replace(".", "");
	StringBuilder sb = new StringBuilder();
	sb.append("rr:predicateObjectMap [\n");
	sb.append("\trr:predicateMap [ rr:constant "
			+ ((predicatedprefix == null) ? "onto" : (predicatedprefix))
			+ ":");
	if (!isgeometrypredicate) {
		predicate = "has"
				+ WordUtils.capitalize(predicate, new char[] { '-' });
	}
	sb.append(predicate + " ];\n");
	sb.append("\trr:objectMap [\n");
	if (type != null) {
		sb.append("\t\trr:datatype " + " " + type + ";\n");
	}
	if (function != null) {
		sb.append("\t\trrx:function rrxf:" + function + ";\n");
		sb.append("\t\trrx:argumentMap ( [ ");
		sb.append("rml:reference \"" + reference + "\"; ] );\n");
	} else { // we have simple reference
		if (ontology != null && !isgeometrypredicate) {
			ontology.createDatatypeProperty(
					classname,
					"has"
							+ WordUtils.capitalize(predicate,
									new char[] { '-' }), type);
		}
		sb.append("\t\trml:reference \"" + reference + "\";\n");
	}
	sb.append("\t];\n");
	sb.append("];\n");
	return sb.toString();
}
 
Example 6
Source File: FormatExamples.java    From Aspose.OCR-for-Java with MIT License 5 votes vote down vote up
public static String formatTitle(String inputStr) {
    String title = inputStr.replaceAll("(_|.java|\\.)", " ");
    title = title.replaceAll("([A-Z])", " $1");
    title = WordUtils.capitalize(title);


    return title;
}
 
Example 7
Source File: ShapefileMappingGenerator.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
private String printPredicateObjectMap(boolean isTemplate, String predicate, String reference, String type,
		String typeprefix, String predicatedprefix, String function, String classname, boolean isgeometrypredicate,
		boolean isSubtypeOfGeometryClass) {
	predicate = predicate.replace(".", "");
	StringBuilder sb = new StringBuilder();
	sb.append("rr:predicateObjectMap [\n");
	sb.append(
			"\trr:predicateMap [ rr:constant " + ((predicatedprefix == null) ? "onto" : (predicatedprefix)) + ":");
	if (!isgeometrypredicate) {
		predicate = "has" + WordUtils.capitalize(predicate, new char[] { '-' });
	}
	sb.append(predicate + " ];\n");
	sb.append("\trr:objectMap [\n");
	if (type != null) {
		sb.append("\t\trr:datatype " + " " + type + ";\n");
	}
	if (function != null) {
		sb.append("\t\trrx:function rrxf:" + function + ";\n");
		sb.append("\t\trrx:argumentMap ( [ ");
		sb.append("rml:reference \"" + reference + "\"; ] );\n");
	} else { // we have simple reference
		if (ontology != null && !isgeometrypredicate) {
			ontology.createDatatypeProperty(classname, "has" + WordUtils.capitalize(predicate, new char[] { '-' }),
					type);
		}
		sb.append("\t\t" + (isTemplate ? "rr:template" : "rml:reference") + " \"" + reference + "\";\n");
	}
	if (ontology != null) {
		if (isSubtypeOfGeometryClass) {
			ontology.createObjectProperty(classname, predicate, classname + "_Geometry", true);
			if (true) {
				ontology.addFeatureAsSuperClass(classname);
				ontology.createGeometryClass(classname + "_Geometry");
			}
		}
	}
	sb.append("\t];\n");
	sb.append("];\n");
	return sb.toString();
}
 
Example 8
Source File: XMLMappingGeneratorTrans.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
private String printPredicateObjectMap(boolean isTemplate,String predicate, String reference,
		String type, String typeprefix, String predicatedprefix,
		String function, String classname, boolean isgeometrypredicate) {
	predicate = predicate.replace(".", "");
	StringBuilder sb = new StringBuilder();
	sb.append("rr:predicateObjectMap [\n");
	sb.append("\trr:predicateMap [ rr:constant "
			+ ((predicatedprefix == null) ? "onto" : (predicatedprefix))
			+ ":");
	if (!isgeometrypredicate) {
		predicate = "has"
				+ WordUtils.capitalize(predicate, new char[] { '-' });
	}
	sb.append(predicate + " ];\n");
	sb.append("\trr:objectMap [\n");
	if (type != null) {
		sb.append("\t\trr:datatype " + " " + type + ";\n");
	}
	if (function != null) {
		sb.append("\t\trrx:function rrxf:" + function + ";\n");
		sb.append("\t\trrx:argumentMap ( [ ");
		sb.append("rml:reference \"" + reference + "\"; ] );\n");
	} else { // we have simple reference
		if (ontology != null && !isgeometrypredicate) {
			ontology.createDatatypeProperty(
					classname,
					"has"
							+ WordUtils.capitalize(predicate,
									new char[] { '-' }), type);
		}
		sb.append("\t\t"+(isTemplate?"rr:template":"rml:reference")+" \"" + reference + "\";\n");
	}
	sb.append("\t];\n");
	sb.append("];\n");
	return sb.toString();
}
 
Example 9
Source File: JavaParameterHost.java    From dal with Apache License 2.0 5 votes vote down vote up
public String getCapitalizedName() {
    String tempName = name.replace("@", "");
    // if (tempName.contains("_")) {
    // tempName = WordUtils.capitalizeFully(tempName.replace('_', ' ')).replace(" ", "");
    // }
    return WordUtils.capitalize(tempName);
}
 
Example 10
Source File: MojibakeServlet.java    From easybuggy with Apache License 2.0 5 votes vote down vote up
@Override
protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {

    req.setCharacterEncoding("Shift_JIS");
    res.setContentType("text/html; charset=UTF-8");
    try {
        String string = req.getParameter("string");
        Locale locale = req.getLocale();

        StringBuilder bodyHtml = new StringBuilder();

        bodyHtml.append("<form action=\"mojibake\" method=\"post\">");
        bodyHtml.append(getMsg("description.capitalize.string", locale));
        bodyHtml.append("<br><br>");
        bodyHtml.append(getMsg("label.string", locale) + ": ");
        bodyHtml.append("<input type=\"text\" name=\"string\" size=\"100\" maxlength=\"100\">");
        bodyHtml.append("<br><br>");
        bodyHtml.append("<input type=\"submit\" value=\"" + getMsg("label.submit", locale) + "\">");
        bodyHtml.append("<br><br>");

        if (string != null && !"".equals(string)) {
            // Capitalize the given string
            String capitalizeName = WordUtils.capitalize(string);
            bodyHtml.append(getMsg("label.capitalized.string", locale) + " : " + encodeForHTML(capitalizeName));
        } else {
            bodyHtml.append(getMsg("msg.enter.string", locale));
        }
        bodyHtml.append("<br><br>");
        bodyHtml.append(getInfoMsg("msg.note.mojibake", locale));
        bodyHtml.append("</form>");

        responseToClient(req, res, getMsg("title.mojibake.page", locale), bodyHtml.toString());

    } catch (Exception e) {
        log.error("Exception occurs: ", e);
    }
}
 
Example 11
Source File: ExprStringCase.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
private static String toPascalCase(String str, boolean strict) {
	String[] words = str.split(" "); // Splits at spaces 
	String buf = "";
	for (int i = 0; i < words.length; i++)
		buf += strict ? WordUtils.capitalizeFully(words[i]) : WordUtils.capitalize(words[i]);
	return buf;
}
 
Example 12
Source File: ExprStringCase.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("null")
private static String toCamelCase(String str, boolean strict) {
	String[] words = str.split(" "); // Splits at spaces 
	String buf = words.length > 0 ? (strict ? words[0].toLowerCase() : WordUtils.uncapitalize(words[0])) : "";
	for (int i = 1; i < words.length; i++)
		buf += strict ? WordUtils.capitalizeFully(words[i]) : WordUtils.capitalize(words[i]);
	return buf;
}
 
Example 13
Source File: ExprStringCase.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("null")
@Override
@Nullable
protected String[] get(Event e) {
	String[] strs = expr.getArray(e);
	for (int i = 0; i < strs.length; i++) {
		if (strs[i] != null) {
			switch (type) {
				case 0: // Basic Case Change 
					strs[i] = (casemode == 1) ? strs[i].toUpperCase() : strs[i].toLowerCase();
					break;
				case 1: // Proper Case 
					strs[i] = (casemode == 3) ? WordUtils.capitalizeFully(strs[i]) : WordUtils.capitalize(strs[i]);
					break;
				case 2: // Camel Case 
					strs[i] = toCamelCase(strs[i], casemode == 3);
					break;
				case 3: // Pascal Case 
					strs[i] = toPascalCase(strs[i], casemode == 3);
					break;
				case 4: // Snake Case 
					strs[i] = toSnakeCase(strs[i], casemode);
					break;
				case 5: // Kebab Case 
					strs[i] = toKebabCase(strs[i], casemode);
					break;
			}
		}
	}
	return strs;
}
 
Example 14
Source File: JavaParameterHost.java    From das with Apache License 2.0 5 votes vote down vote up
public String getCamelCaseCapitalizedName() {
    String temp = name.replace("@", "");
    if (temp.contains("_")) {
        temp = WordUtils.capitalizeFully(temp.replace('_', ' ')).replace(" ", "");
    }
    return WordUtils.capitalize(temp);
}
 
Example 15
Source File: PropertyUtils.java    From jdal with Apache License 2.0 4 votes vote down vote up
public static String toHumanReadable(String propertyName) {
	String humanReadable = getPropertyName(propertyName).replaceAll("([A-Z])", " $1").trim();
	return WordUtils.capitalize(humanReadable);
}
 
Example 16
Source File: PythonApiActionGenerator.java    From zstack with Apache License 2.0 4 votes vote down vote up
private static String populateActionName(Class<?> clazz) {
    String name = clazz.getSimpleName().replace("API", "").replace("Msg", "");
    name = String.format("%sAction", name);
    return WordUtils.capitalize(name);
}
 
Example 17
Source File: ValueDataUtil.java    From hop with Apache License 2.0 4 votes vote down vote up
public static String initCap( IValueMeta metaA, Object dataA ) {
  if ( dataA == null ) {
    return null;
  }
  return WordUtils.capitalize( dataA.toString(), new char[] { ' ', '_', ',', ':', ';', '-' } );
}
 
Example 18
Source File: EnumValuesFinder.java    From rice with Educational Community License v2.0 4 votes vote down vote up
/**
 * Derives a label value from an enum
 */
protected String getEnumLabel(Enum enm) {
    return WordUtils.capitalize(enm.name().toLowerCase());
}
 
Example 19
Source File: CapitalizeBuilder.java    From sequenceiq-samples with Apache License 2.0 4 votes vote down vote up
private Object transformFieldValue(Object value) {
    return WordUtils.capitalize(value.toString());
}
 
Example 20
Source File: CreateI18NKeysForConnectionHandler.java    From rapidminer-studio with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * Turns a parameter key into a capitalized version to be used as a name,
 * e.g. {@code parameter_key} is turned into "Parameter key"
 *
 * @param i18nKey
 * 		the i18n key of the parameter
 * @return the capitalized name
 */
private static String capitalizeName(String i18nKey) {
	return WordUtils.capitalize(extractName(i18nKey).replace('_', ' '));
}