|
@@ -4,6 +4,7 @@
|
4
|
4
|
*
|
5
|
5
|
* @author Wilhem Alcivar
|
6
|
6
|
*/
|
|
7
|
+import java.util.*;
|
7
|
8
|
public class StringParser
|
8
|
9
|
{
|
9
|
10
|
/**
|
|
@@ -15,7 +16,8 @@ public class StringParser
|
15
|
16
|
*/
|
16
|
17
|
public static String upperCaseString(String s)
|
17
|
18
|
{
|
18
|
|
- return null;
|
|
19
|
+ String change = s.toUpperCase();
|
|
20
|
+ return change;
|
19
|
21
|
}
|
20
|
22
|
|
21
|
23
|
/**
|
|
@@ -26,7 +28,8 @@ public class StringParser
|
26
|
28
|
* @return String
|
27
|
29
|
*/
|
28
|
30
|
public static String lowerCaseString(String s) {
|
29
|
|
- return null;
|
|
31
|
+
|
|
32
|
+ return s.toLowerCase();
|
30
|
33
|
}
|
31
|
34
|
|
32
|
35
|
/**
|
|
@@ -37,7 +40,10 @@ public class StringParser
|
37
|
40
|
* @return String
|
38
|
41
|
*/
|
39
|
42
|
public static Character getFirstCharacter(String s) {
|
40
|
|
- return null;
|
|
43
|
+
|
|
44
|
+ char first = s.charAt(0);
|
|
45
|
+ return first;
|
|
46
|
+
|
41
|
47
|
}
|
42
|
48
|
|
43
|
49
|
/**
|
|
@@ -49,7 +55,8 @@ public class StringParser
|
49
|
55
|
* @return String
|
50
|
56
|
*/
|
51
|
57
|
public static Character getNthCharacter(String s, Integer n) {
|
52
|
|
- return null;
|
|
58
|
+ char num = s.charAt(n);
|
|
59
|
+ return num;
|
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 change = s.substring(0,1).toUpperCase();
|
|
71
|
+ String nameCap = change + s.substring(1);
|
|
72
|
+ return nameCap;
|
64
|
73
|
}
|
65
|
74
|
|
66
|
75
|
/**
|
|
@@ -72,7 +81,12 @@ public class StringParser
|
72
|
81
|
* @return String
|
73
|
82
|
*/
|
74
|
83
|
public static String camelCaseString(String s) {
|
75
|
|
- return null;
|
|
84
|
+ s = s.toLowerCase();
|
|
85
|
+ int index = s.indexOf(" ") + 1;
|
|
86
|
+
|
|
87
|
+ s = s.substring(0,1).toUpperCase() + s.substring(1,index -1)+ s.substring(index, index +1).toUpperCase() + s.substring(index +1);
|
|
88
|
+
|
|
89
|
+ return s;
|
76
|
90
|
}
|
77
|
91
|
|
78
|
92
|
/**
|
|
@@ -84,7 +98,12 @@ public class StringParser
|
84
|
98
|
* @return String
|
85
|
99
|
*/
|
86
|
100
|
public static String snakeCaseString(String s) {
|
87
|
|
- return null;
|
|
101
|
+
|
|
102
|
+ String val = s.toLowerCase();
|
|
103
|
+
|
|
104
|
+ val = val.replaceAll(" ","_");
|
|
105
|
+
|
|
106
|
+ return val;
|
88
|
107
|
}
|
89
|
108
|
|
90
|
109
|
/**
|
|
@@ -95,7 +114,9 @@ public class StringParser
|
95
|
114
|
* @return String
|
96
|
115
|
*/
|
97
|
116
|
public static Integer getLength(String s) {
|
98
|
|
- return null;
|
|
117
|
+
|
|
118
|
+ int quantity = s.length();
|
|
119
|
+ return quantity;
|
99
|
120
|
}
|
100
|
121
|
|
101
|
122
|
/**
|
|
@@ -109,7 +130,11 @@ public class StringParser
|
109
|
130
|
* @return String
|
110
|
131
|
*/
|
111
|
132
|
public static Boolean isEqual(String s1, String s2) {
|
112
|
|
- return null;
|
|
133
|
+ if(s1.equals(s2))
|
|
134
|
+ {
|
|
135
|
+ return true;
|
|
136
|
+ }
|
|
137
|
+ return false;
|
113
|
138
|
}
|
114
|
139
|
|
115
|
140
|
/**
|
|
@@ -123,6 +148,10 @@ public class StringParser
|
123
|
148
|
* @return String
|
124
|
149
|
*/
|
125
|
150
|
public static Boolean isEqualIgnoreCase(String s1, String s2) {
|
126
|
|
- return null;
|
|
151
|
+ if(s1.equalsIgnoreCase(s2))
|
|
152
|
+ {
|
|
153
|
+ return true;
|
|
154
|
+ }
|
|
155
|
+ return false;
|
127
|
156
|
}
|
128
|
157
|
}
|