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

Method parseCmd

java/org/apache/catalina/ssi/SSIProcessor.java:331–354  ·  view source on GitHub ↗

Parse a StringBuilder and take out the command token. Called from requestHandler @param cmd a value of type 'StringBuilder' @return a value of type 'String', or null if there is none

(StringBuilder cmd)

Source from the content-addressed store, hash-verified

329 * @return a value of type 'String', or null if there is none
330 */
331 private String parseCmd(StringBuilder cmd) {
332 int firstLetter = -1;
333 int lastLetter = -1;
334 for (int i = 0; i < cmd.length(); i++) {
335 char c = cmd.charAt(i);
336 if (Character.isLetter(c)) {
337 if (firstLetter == -1) {
338 firstLetter = i;
339 }
340 lastLetter = i;
341 } else if (isSpace(c)) {
342 if (lastLetter > -1) {
343 break;
344 }
345 } else {
346 break;
347 }
348 }
349 if (firstLetter == -1) {
350 return "";
351 } else {
352 return cmd.substring(firstLetter, lastLetter + 1);
353 }
354 }
355
356
357 /**

Callers 1

processMethod · 0.95

Calls 3

isSpaceMethod · 0.95
lengthMethod · 0.80
charAtMethod · 0.80

Tested by

no test coverage detected