|
@@ -4,6 +4,8 @@
|
4
|
4
|
*
|
5
|
5
|
* @author Wilhem Alcivar
|
6
|
6
|
*/
|
|
7
|
+
|
|
8
|
+//ElliottStansbury
|
7
|
9
|
public class StringParser
|
8
|
10
|
{
|
9
|
11
|
/**
|
|
@@ -15,7 +17,8 @@ public class StringParser
|
15
|
17
|
*/
|
16
|
18
|
public static String upperCaseString(String s)
|
17
|
19
|
{
|
18
|
|
- return null;
|
|
20
|
+
|
|
21
|
+ return s.toUpperCase();
|
19
|
22
|
}
|
20
|
23
|
|
21
|
24
|
/**
|
|
@@ -26,7 +29,7 @@ public class StringParser
|
26
|
29
|
* @return String
|
27
|
30
|
*/
|
28
|
31
|
public static String lowerCaseString(String s) {
|
29
|
|
- return null;
|
|
32
|
+ return s.toLowerCase();
|
30
|
33
|
}
|
31
|
34
|
|
32
|
35
|
/**
|
|
@@ -37,7 +40,9 @@ public class StringParser
|
37
|
40
|
* @return String
|
38
|
41
|
*/
|
39
|
42
|
public static Character getFirstCharacter(String s) {
|
40
|
|
- return null;
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+ return s.charAt(0);
|
41
|
46
|
}
|
42
|
47
|
|
43
|
48
|
/**
|
|
@@ -49,7 +54,9 @@ public class StringParser
|
49
|
54
|
* @return String
|
50
|
55
|
*/
|
51
|
56
|
public static Character getNthCharacter(String s, Integer n) {
|
52
|
|
- return null;
|
|
57
|
+ char nLetter = s.charAt(n);
|
|
58
|
+
|
|
59
|
+ return nLetter;
|
53
|
60
|
}
|
54
|
61
|
|
55
|
62
|
/**
|
|
@@ -60,7 +67,9 @@ public class StringParser
|
60
|
67
|
* @return String
|
61
|
68
|
*/
|
62
|
69
|
public static String upperCaseFirstCharacter(String s) {
|
63
|
|
- return null;
|
|
70
|
+ String firstLetterUpper = s.substring(0,1).toUpperCase() + s.substring(1);
|
|
71
|
+
|
|
72
|
+ return firstLetterUpper;
|
64
|
73
|
}
|
65
|
74
|
|
66
|
75
|
/**
|
|
@@ -72,7 +81,23 @@ public class StringParser
|
72
|
81
|
* @return String
|
73
|
82
|
*/
|
74
|
83
|
public static String camelCaseString(String s) {
|
75
|
|
- return null;
|
|
84
|
+ String st = s.toLowerCase();
|
|
85
|
+ String[] arr = st.split(" ");
|
|
86
|
+ StringBuffer sb = new StringBuffer();
|
|
87
|
+
|
|
88
|
+ for (int i = 0; i < arr.length; i++) {
|
|
89
|
+ sb.append(Character.toUpperCase(arr[i].charAt(0)))
|
|
90
|
+ .append(arr[i].substring(1));
|
|
91
|
+ }
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+ String a = sb.toString();
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+ return a;
|
|
100
|
+
|
76
|
101
|
}
|
77
|
102
|
|
78
|
103
|
/**
|
|
@@ -84,7 +109,11 @@ public class StringParser
|
84
|
109
|
* @return String
|
85
|
110
|
*/
|
86
|
111
|
public static String snakeCaseString(String s) {
|
87
|
|
- return null;
|
|
112
|
+ String lower = s.toLowerCase();
|
|
113
|
+ String a = lower.replaceAll("\\s","_");
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+ return a;
|
88
|
117
|
}
|
89
|
118
|
|
90
|
119
|
/**
|
|
@@ -95,7 +124,7 @@ public class StringParser
|
95
|
124
|
* @return String
|
96
|
125
|
*/
|
97
|
126
|
public static Integer getLength(String s) {
|
98
|
|
- return null;
|
|
127
|
+ return s.length();
|
99
|
128
|
}
|
100
|
129
|
|
101
|
130
|
/**
|
|
@@ -109,7 +138,11 @@ public class StringParser
|
109
|
138
|
* @return String
|
110
|
139
|
*/
|
111
|
140
|
public static Boolean isEqual(String s1, String s2) {
|
112
|
|
- return null;
|
|
141
|
+ if(s1.equals(s2)){
|
|
142
|
+ return true;
|
|
143
|
+ }else{
|
|
144
|
+ }
|
|
145
|
+ return false;
|
113
|
146
|
}
|
114
|
147
|
|
115
|
148
|
/**
|
|
@@ -123,6 +156,16 @@ public class StringParser
|
123
|
156
|
* @return String
|
124
|
157
|
*/
|
125
|
158
|
public static Boolean isEqualIgnoreCase(String s1, String s2) {
|
126
|
|
- return null;
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+ if(s1.equalsIgnoreCase(s2)){
|
|
165
|
+ return true;
|
|
166
|
+ }else {
|
|
167
|
+ }
|
|
168
|
+ return false;
|
|
169
|
+
|
127
|
170
|
}
|
128
|
171
|
}
|