MCPcopy Create free account
hub / github.com/apache/commons-lang / add

Method add

src/main/java/org/apache/commons/lang3/CharSet.java:193–219  ·  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

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

Callers 12

localeLookupListMethod · 0.45
getAllInterfacesMethod · 0.45
getAllSuperclassesMethod · 0.45
nextMethod · 0.45
walkInterfacesMethod · 0.45
generateBitVectorsMethod · 0.45
processBitVectorsMethod · 0.45
splitByCharacterTypeMethod · 0.45
splitWorkerMethod · 0.45
substringsBetweenMethod · 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