|
@@ -15,7 +15,8 @@ public class StringParser
|
15
|
15
|
*/
|
16
|
16
|
public static String upperCaseString(String s)
|
17
|
17
|
{
|
18
|
|
- return null;
|
|
18
|
+ String result = s.toUpperCase();
|
|
19
|
+ return result;
|
19
|
20
|
}
|
20
|
21
|
|
21
|
22
|
/**
|
|
@@ -26,7 +27,8 @@ public class StringParser
|
26
|
27
|
* @return String
|
27
|
28
|
*/
|
28
|
29
|
public static String lowerCaseString(String s) {
|
29
|
|
- return null;
|
|
30
|
+ String result = s.toLowerCase();
|
|
31
|
+ return result;
|
30
|
32
|
}
|
31
|
33
|
|
32
|
34
|
/**
|
|
@@ -37,7 +39,8 @@ public class StringParser
|
37
|
39
|
* @return String
|
38
|
40
|
*/
|
39
|
41
|
public static Character getFirstCharacter(String s) {
|
40
|
|
- return null;
|
|
42
|
+ char result = s.charAt(0);
|
|
43
|
+ return result;
|
41
|
44
|
}
|
42
|
45
|
|
43
|
46
|
/**
|
|
@@ -49,7 +52,8 @@ public class StringParser
|
49
|
52
|
* @return String
|
50
|
53
|
*/
|
51
|
54
|
public static Character getNthCharacter(String s, Integer n) {
|
52
|
|
- return null;
|
|
55
|
+ char result = s.charAt(n);
|
|
56
|
+ return result;
|
53
|
57
|
}
|
54
|
58
|
|
55
|
59
|
/**
|
|
@@ -60,7 +64,8 @@ public class StringParser
|
60
|
64
|
* @return String
|
61
|
65
|
*/
|
62
|
66
|
public static String upperCaseFirstCharacter(String s) {
|
63
|
|
- return null;
|
|
67
|
+ String result = s.substring(0,1).toUpperCase() + s.substring(1);
|
|
68
|
+ return result;
|
64
|
69
|
}
|
65
|
70
|
|
66
|
71
|
/**
|
|
@@ -72,7 +77,21 @@ public class StringParser
|
72
|
77
|
* @return String
|
73
|
78
|
*/
|
74
|
79
|
public static String camelCaseString(String s) {
|
75
|
|
- return null;
|
|
80
|
+ String lC = s.toLowerCase();
|
|
81
|
+ StringBuilder sb = new StringBuilder(lC.substring(0,1).toUpperCase());
|
|
82
|
+
|
|
83
|
+ for(int i = 1; i<lC.length(); i++){
|
|
84
|
+
|
|
85
|
+ if(lC.charAt(i)==' '){
|
|
86
|
+ i++;
|
|
87
|
+ sb.append(lC.substring(i,i+1).toUpperCase());
|
|
88
|
+ } else {
|
|
89
|
+ sb.append(lC.charAt(i));
|
|
90
|
+ }
|
|
91
|
+ }
|
|
92
|
+
|
|
93
|
+ String result = sb.toString();
|
|
94
|
+ return result;
|
76
|
95
|
}
|
77
|
96
|
|
78
|
97
|
/**
|
|
@@ -84,7 +103,9 @@ public class StringParser
|
84
|
103
|
* @return String
|
85
|
104
|
*/
|
86
|
105
|
public static String snakeCaseString(String s) {
|
87
|
|
- return null;
|
|
106
|
+ String lowerCase = s.toLowerCase();
|
|
107
|
+ String result = lowerCase.replace(' ','_');
|
|
108
|
+ return result;
|
88
|
109
|
}
|
89
|
110
|
|
90
|
111
|
/**
|
|
@@ -95,7 +116,7 @@ public class StringParser
|
95
|
116
|
* @return String
|
96
|
117
|
*/
|
97
|
118
|
public static Integer getLength(String s) {
|
98
|
|
- return null;
|
|
119
|
+ return s.length();
|
99
|
120
|
}
|
100
|
121
|
|
101
|
122
|
/**
|
|
@@ -109,7 +130,8 @@ public class StringParser
|
109
|
130
|
* @return String
|
110
|
131
|
*/
|
111
|
132
|
public static Boolean isEqual(String s1, String s2) {
|
112
|
|
- return null;
|
|
133
|
+ boolean result = s1.equals(s2) ? true : false;
|
|
134
|
+ return result;
|
113
|
135
|
}
|
114
|
136
|
|
115
|
137
|
/**
|
|
@@ -123,6 +145,7 @@ public class StringParser
|
123
|
145
|
* @return String
|
124
|
146
|
*/
|
125
|
147
|
public static Boolean isEqualIgnoreCase(String s1, String s2) {
|
126
|
|
- return null;
|
|
148
|
+ boolean result = s1.equalsIgnoreCase(s2) ? true : false;
|
|
149
|
+ return result;
|
127
|
150
|
}
|
128
|
151
|
}
|