List of usage examples for org.apache.commons.lang StringUtils capitalize
public static String capitalize(String str)
Capitalizes a String changing the first letter to title case as per Character#toTitleCase(char) .
From source file:com.github.jdot.util.NameUtil.java
public final static String toGetter(State state) { if ("boolean".equals(state.getType())) { return "is" + StringUtils.capitalize(state.getName()); } else {//from w ww . ja v a 2s. c o m return "get" + StringUtils.capitalize(state.getName()); } }
From source file:com.carteblanche.kwd.parsers.TestCaseParser.java
public static KWDTestCase parse(File csv, String cvsSplitBy) { BufferedReader br = null;/*from ww w. j a va 2 s. co m*/ String line = ""; String csvFile = csv.getAbsolutePath(); try { File file = new File(csvFile); String testCaseName = file.getName(); testCaseName = testCaseName.replace(".csv", ""); testCaseName = StringUtils .capitalize(StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(testCaseName), ' ')); br = new BufferedReader(new FileReader(csvFile)); ArrayList<KWDTestMethod> testMethods = new ArrayList<KWDTestMethod>(); while ((line = br.readLine()) != null) { // use comma as separator String[] columns = line.split(cvsSplitBy); if (columns.length < 1) { System.out.println("Every row should have atleast 1 Column"); System.exit(122); } ArrayList<String> parameters = new ArrayList<String>(); for (int i = 1; i < columns.length; i++) { parameters.add(columns[i]); } KWDTestMethod testMethod = new KWDTestMethod(columns[0], parameters); testMethod.setClasssName("com.carteblanche.kwd.tests.Login"); testMethods.add(testMethod); } KWDTestCase testCase = new KWDTestCase(testCaseName, testMethods); return testCase; // return new KWDTestSuite(testSuiteName, testcases); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (br != null) { try { br.close(); } catch (IOException e) { e.printStackTrace(); } } } return null; }
From source file:com.openshift.restclient.utils.BeanUtils.java
/** * Convert a delimited string to camelcase (e.g. foo-bar -> fooBar) * @param name the string to convert * @param delimiter the delimiter to use * @return the delimited string camelcased *//* w w w. ja v a2s . co m*/ public static String toCamelCase(String name, String delimiter) { String[] parts = name.split("-"); List<String> capitalized = Stream.of(parts).map(p -> StringUtils.capitalize(p)) .collect(Collectors.toList()); return StringUtils.uncapitalize(StringUtils.join(capitalized, "")); }
From source file:cn.com.widemex.core.utils.reflection.ReflectionUtils.java
/** * Getter.// w ww . j a va2s. co m */ public static Object invokeGetterMethod(Object obj, String propertyName) { String getterMethodName = "get" + StringUtils.capitalize(propertyName); return invokeMethod(obj, getterMethodName, new Class[] {}, new Object[] {}); }
From source file:com.google.code.sagetvaddons.sjq.listener.CommandFactory.java
@SuppressWarnings("unchecked") static public final Command get(String name, String cmdPkg, ObjectInputStream in, ObjectOutputStream out, String logPkg) {// w w w . j ava2s.c om try { Class<Command> cls = (Class<Command>) Class .forName(cmdPkg + "." + StringUtils.capitalize(name.toLowerCase())); Constructor<Command> ctor = cls.getConstructor(ObjectInputStream.class, ObjectOutputStream.class); return ctor.newInstance(in, out); } catch (Exception e) { Logger log = Logger.getLogger(logPkg + "." + CommandFactory.class.getSimpleName()); log.error("Error", e); } return null; }
From source file:com.mobileman.kuravis.core.util.ValidationUtils.java
public static void rejectIfEmpty(Errors errors, String field, MessageSource messageSource) { String capitalizedField = StringUtils.capitalize(field); rejectIfEmpty(//from w w w . j a v a2s .c o m errors, field, "error.required", new String[] { messageSource.getMessage(field, null, capitalizedField, AbstractHealtPlatformController.LOCALE_DEFAULT) }, capitalizedField + " is required!"); }
From source file:com.personal.tools.Reflections.java
/** * Getter./*from w w w. j a va 2s. c o m*/ */ public static Object invokeGetter(Object obj, String propertyName) { String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(propertyName); return invokeMethod(obj, getterMethodName, new Class[] {}, new Object[] {}); }
From source file:com.galeoconsulting.leonardinius.api.LanguageUtils.java
public static String getLanguageName(ScriptEngineFactory factory) { String languageName = factory.getLanguageName(); if ("ECMAScript".equals(languageName) && factory.getNames().contains("JavaScript")) { languageName = "JavaScript"; }//from w w w.j a v a2 s . co m return StringUtils.capitalize(languageName); }
From source file:com.github.jdot.util.NameUtil.java
public final static String toSetter(State state) { return "set" + StringUtils.capitalize(state.getName()); }
From source file:jp.co.tis.gsp.tools.dba.dialect.DialectFactory.java
public static Dialect getDialect(String url, String driver) { String[] urlTokens = StringUtils.split(url, ':'); if (urlTokens.length < 3) { throw new IllegalArgumentException("url isn't jdbc url format."); }/*w w w . ja v a 2 s. c o m*/ Dialect dialect; try { Class<?> dialectClass; if (classMap.containsKey(urlTokens[1])) { dialectClass = classMap.get(urlTokens[1]); } else { String dialectClassName; dialectClassName = "jp.co.tis.gsp.tools.dba.dialect." + StringUtils.capitalize(urlTokens[1]) + "Dialect"; dialectClass = Class.forName(dialectClassName); } dialect = (Dialect) dialectClass.newInstance(); dialect.setUrl(url); dialect.setDriver(driver); } catch (Exception e) { throw new IllegalArgumentException("Unsupported Database product:" + urlTokens[1], e); } return dialect; }