nosi.core.webapp.helpers.StringHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of igrp-core Show documentation
Show all versions of igrp-core Show documentation
IGRP Framework is a powerful and highly customizable platform developed by the Operational Nucleus for the Information Society (NOSi) to create web applications, it provides out of box, several modules to make easy to create stand-alone, production-grade web applications: authentication and access-control, business processes automation, reporting, page builder with automatic code generation and incorporation of the Once-Only-Principle, written in Java. IGRP Framework WAR - Contains some keys resources that give UI to IGRP Framework and others supports files.
package nosi.core.webapp.helpers;
import java.nio.charset.StandardCharsets;
/**
* @author: Emanuel Pereira
* 25 Oct 2017
*/
public class StringHelper {
private StringHelper(){}
/*Camel Case to first letter of string
*
* listpage => Listpage
*/
public static String camelCaseFirst(String string){
return string.substring(0, 1).toUpperCase() + string.substring(1);
}
public static String camelCase(String string,String regex,String replacement) {
return camelCase(string.replace(regex, replacement));
}
/*Removel all space of string
* List page => Listpage
*/
public static String removeSpace(String string){
return string.replaceAll("\\s+", "");
}
/*Camel Case to string
* List page => List Page
*/
public static String camelCase(String string){
String[] strParts = string.split("\\s+");
StringBuilder result = new StringBuilder();
for(String s:strParts)
result.append(StringHelper.camelCaseFirst(s));
return result.toString();
}
/*Validade the className for Java Class
*
*/
public static boolean validateClassName(String className){
return className.matches("([a-zA-Z_$][a-zA-Z\\d_$]*\\.)*[a-zA-Z_$][a-zA-Z\\d_$]*");
}
public static String removeSpecialCharaterAndSpace(String string) {
string = string.replaceAll("[^a-zA-Z0-9]", "_");
return removeSpace(string);
}
public static String decode(String headerText) {
return new String(headerText.getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8);
}
}