|
@@ -4,6 +4,7 @@
|
4
|
4
|
*
|
5
|
5
|
* @author Wilhem Alcivar
|
6
|
6
|
*/
|
|
7
|
+
|
7
|
8
|
public class StringParser
|
8
|
9
|
{
|
9
|
10
|
/**
|
|
@@ -15,7 +16,7 @@ public class StringParser
|
15
|
16
|
*/
|
16
|
17
|
public static String upperCaseString(String s)
|
17
|
18
|
{
|
18
|
|
- return null;
|
|
19
|
+ return s.toUpperCase();
|
19
|
20
|
}
|
20
|
21
|
|
21
|
22
|
/**
|
|
@@ -26,7 +27,7 @@ public class StringParser
|
26
|
27
|
* @return String
|
27
|
28
|
*/
|
28
|
29
|
public static String lowerCaseString(String s) {
|
29
|
|
- return null;
|
|
30
|
+ return s.toLowerCase();
|
30
|
31
|
}
|
31
|
32
|
|
32
|
33
|
/**
|
|
@@ -37,7 +38,7 @@ public class StringParser
|
37
|
38
|
* @return String
|
38
|
39
|
*/
|
39
|
40
|
public static Character getFirstCharacter(String s) {
|
40
|
|
- return null;
|
|
41
|
+ return s.charAt(0);
|
41
|
42
|
}
|
42
|
43
|
|
43
|
44
|
/**
|
|
@@ -49,7 +50,7 @@ public class StringParser
|
49
|
50
|
* @return String
|
50
|
51
|
*/
|
51
|
52
|
public static Character getNthCharacter(String s, Integer n) {
|
52
|
|
- return null;
|
|
53
|
+ return s.charAt(n);
|
53
|
54
|
}
|
54
|
55
|
|
55
|
56
|
/**
|
|
@@ -60,7 +61,8 @@ public class StringParser
|
60
|
61
|
* @return String
|
61
|
62
|
*/
|
62
|
63
|
public static String upperCaseFirstCharacter(String s) {
|
63
|
|
- return null;
|
|
64
|
+ String cap = s.substring(0, 1).toUpperCase() + s.substring(1);
|
|
65
|
+ return cap;
|
64
|
66
|
}
|
65
|
67
|
|
66
|
68
|
/**
|
|
@@ -72,7 +74,12 @@ public class StringParser
|
72
|
74
|
* @return String
|
73
|
75
|
*/
|
74
|
76
|
public static String camelCaseString(String s) {
|
75
|
|
- return null;
|
|
77
|
+ s = s.toLowerCase();
|
|
78
|
+ String camel = new String();
|
|
79
|
+ int x = s.indexOf(" ") + 1;
|
|
80
|
+ camel = s.substring(0,1).toUpperCase() + s.substring(1, x - 1) + s.substring(x, x +1).toUpperCase() + s.substring(x +1);
|
|
81
|
+
|
|
82
|
+ return camel;
|
76
|
83
|
}
|
77
|
84
|
|
78
|
85
|
/**
|
|
@@ -84,7 +91,17 @@ public class StringParser
|
84
|
91
|
* @return String
|
85
|
92
|
*/
|
86
|
93
|
public static String snakeCaseString(String s) {
|
87
|
|
- return null;
|
|
94
|
+
|
|
95
|
+ int x = s.length();
|
|
96
|
+ String s1 = "";
|
|
97
|
+
|
|
98
|
+ for (int i = 0; i < x; i++) {
|
|
99
|
+ if (s.charAt(i) == ' ')
|
|
100
|
+ s1 = s1 + '_';
|
|
101
|
+ else
|
|
102
|
+ s1 = s1 + Character.toLowerCase(s.charAt(i));
|
|
103
|
+ }
|
|
104
|
+ return s1;
|
88
|
105
|
}
|
89
|
106
|
|
90
|
107
|
/**
|
|
@@ -95,7 +112,7 @@ public class StringParser
|
95
|
112
|
* @return String
|
96
|
113
|
*/
|
97
|
114
|
public static Integer getLength(String s) {
|
98
|
|
- return null;
|
|
115
|
+ return s.length();
|
99
|
116
|
}
|
100
|
117
|
|
101
|
118
|
/**
|
|
@@ -109,7 +126,12 @@ public class StringParser
|
109
|
126
|
* @return String
|
110
|
127
|
*/
|
111
|
128
|
public static Boolean isEqual(String s1, String s2) {
|
112
|
|
- return null;
|
|
129
|
+
|
|
130
|
+ if (s1.equals(s2)){
|
|
131
|
+ return true;
|
|
132
|
+ } else {
|
|
133
|
+ return false;
|
|
134
|
+ }
|
113
|
135
|
}
|
114
|
136
|
|
115
|
137
|
/**
|
|
@@ -123,6 +145,11 @@ public class StringParser
|
123
|
145
|
* @return String
|
124
|
146
|
*/
|
125
|
147
|
public static Boolean isEqualIgnoreCase(String s1, String s2) {
|
126
|
|
- return null;
|
|
148
|
+
|
|
149
|
+ if (s1.equalsIgnoreCase(s2)){
|
|
150
|
+ return true;
|
|
151
|
+ } else{
|
|
152
|
+ return false;
|
127
|
153
|
}
|
128
|
154
|
}
|
|
155
|
+}
|