MCPcopy Create free account
hub / github.com/apache/tomcat / compareIgnoreCase

Method compareIgnoreCase

java/org/apache/catalina/mapper/Mapper.java:1385–1422  ·  view source on GitHub ↗

Compare given char chunk with String ignoring case. Return -1, 0 or +1 if inferior, equal, or superior to the String.

(CharChunk name, int start, int end, String compareTo)

Source from the content-addressed store, hash-verified

1383 * String.
1384 */
1385 private static int compareIgnoreCase(CharChunk name, int start, int end, String compareTo) {
1386 int result = 0;
1387 char[] c = name.getBuffer();
1388 int compareLen = compareTo.length();
1389 int len = compareLen;
1390 if ((end - start) < len) {
1391 len = end - start;
1392 }
1393 for (int i = 0; (i < len) && (result == 0); i++) {
1394 char cName = c[i + start];
1395 char cCompare = compareTo.charAt(i);
1396 int nameLower;
1397 int compareLower;
1398 if (cName > 0xFF) {
1399 nameLower = Character.toLowerCase(cName);
1400 } else {
1401 nameLower = Ascii.toLower(cName);
1402 }
1403 if (cCompare > 0xFF) {
1404 compareLower = Character.toLowerCase(cCompare);
1405 } else {
1406 compareLower = Ascii.toLower(compareTo.charAt(i));
1407 }
1408 if (nameLower > compareLower) {
1409 result = 1;
1410 } else if (nameLower < compareLower) {
1411 result = -1;
1412 }
1413 }
1414 if (result == 0) {
1415 if (compareLen > (end - start)) {
1416 result = -1;
1417 } else if (compareLen < (end - start)) {
1418 result = 1;
1419 }
1420 }
1421 return result;
1422 }
1423
1424
1425 /**

Callers 1

findIgnoreCaseMethod · 0.95

Calls 4

toLowerMethod · 0.95
lengthMethod · 0.80
charAtMethod · 0.80
getBufferMethod · 0.65

Tested by

no test coverage detected