replaced all StringBuffers with StringBuilder to improve performance
[Bob.git] / src / com / interrupt / bob / util / StringUtil.java
blobe4035c53358f31d35f407a486e774ee402dff527
1 package com.interrupt.bob.util;
3 public class StringUtil {
5 public static String upperFirstLetter(String word) {
7 String className = word.trim();
9 String firstLetter = className.substring(0,1);
10 String restOf = className.substring(1);
12 StringBuilder sb = new StringBuilder(firstLetter.toUpperCase());
13 sb.append(restOf);
15 return sb.toString();
18 public static String namespaceToPackage(String word) {
20 String pkg = word.trim();
21 pkg = pkg.replace('/','.');
23 if(pkg.length() <= 0) {
24 return pkg;
27 int plength = pkg.length() - 1;
28 char lastchar = pkg.charAt(plength);
29 if(lastchar == '.') {
30 pkg = pkg.substring(0, plength);
33 return pkg;
37 public static String packageToNamespace(String word) {
39 String nspace = word.trim();
40 nspace = nspace.replace('.','/');
42 if(nspace.length() <= 0) {
43 return nspace;
46 int plength = nspace.length() - 1;
47 char lastchar = nspace.charAt(plength);
48 if(lastchar == '/') {
49 nspace = nspace.substring(0, plength);
52 return nspace;