MCPcopy
hub / github.com/apache/commons-lang / add

Method add

src/main/java/org/apache/commons/lang3/CharSet.java:189–216  ·  view source on GitHub ↗

Add a set definition string to the CharSet. @param str set definition string

(final String str)

Source from the content-addressed store, hash-verified

187 * @param str set definition string
188 */
189 protected void add(final String str) {
190 if (str == null) {
191 return;
192 }
193
194 final int len = str.length();
195 int pos = 0;
196 while (pos < len) {
197 final int remainder = len - pos;
198 if (remainder >= 4 && str.charAt(pos) == '^' && str.charAt(pos + 2) == '-') {
199 // negated range
200 set.add(CharRange.isNotIn(str.charAt(pos + 1), str.charAt(pos + 3)));
201 pos += 4;
202 } else if (remainder >= 3 && str.charAt(pos + 1) == '-') {
203 // range
204 set.add(CharRange.isIn(str.charAt(pos), str.charAt(pos + 2)));
205 pos += 3;
206 } else if (remainder >= 2 && str.charAt(pos) == '^') {
207 // negated char
208 set.add(CharRange.isNot(str.charAt(pos + 1)));
209 pos += 2;
210 } else {
211 // char
212 set.add(CharRange.is(str.charAt(pos)));
213 pos += 1;
214 }
215 }
216 }
217
218 //-----------------------------------------------------------------------
219 /**

Callers 15

CharSetMethod · 0.95
findThreadsMethod · 0.45
findThreadGroupsMethod · 0.45
localeLookupListMethod · 0.45
languagesByCountryMethod · 0.45
countriesByLanguageMethod · 0.45
getAllSuperclassesMethod · 0.45
getAllInterfacesMethod · 0.45
nextMethod · 0.45
walkInterfacesMethod · 0.45

Calls 6

isNotInMethod · 0.95
isInMethod · 0.95
isNotMethod · 0.95
isMethod · 0.95
lengthMethod · 0.45
charAtMethod · 0.45

Tested by

no test coverage detected