1 18 package net.sf.drftpd.master; 19 20 28 public class FtpRequest { 29 30 private String line = null; 31 private String command = null; 32 private String argument = null; 33 34 39 public FtpRequest(String commandLine) { 40 line = commandLine.trim(); 41 parse(); 42 } 43 44 47 private void parse() { 48 int spInd = line.indexOf(' '); 49 50 if (spInd != -1) { 51 command = line.substring(0, spInd).toUpperCase(); 52 argument = line.substring(spInd + 1); 53 if (command.equals("SITE")) { 54 spInd = line.indexOf(' ', spInd+1); 55 if(spInd != -1) { 56 command = line.substring(0, spInd).toUpperCase(); 57 argument = line.substring(spInd + 1); 58 } else { 59 command = line.toUpperCase(); 60 argument = null; 61 } 62 } 63 } else { 64 command = line.toUpperCase(); 65 argument = null; 66 } 67 68 } 72 73 76 public String getCommand() { 77 return command; 78 } 79 80 83 public String getArgument() { 84 if(argument == null) throw new IllegalStateException (); 85 return argument; 86 } 87 88 91 public String getCommandLine() { 92 return line; 93 } 94 95 98 public boolean hasArgument() { 99 return argument != null; 100 } 101 102 } 103 | Popular Tags |