1 17 package org.alfresco.filesys.ftp; 18 19 26 public class FTPRequest 27 { 28 29 31 private int m_cmd; 32 33 35 private String m_arg; 36 37 40 public FTPRequest() 41 { 42 m_cmd = FTPCommand.InvalidCmd; 43 } 44 45 51 public FTPRequest(int cmd, String arg) 52 { 53 m_cmd = cmd; 54 m_arg = arg; 55 } 56 57 62 public FTPRequest(String cmdLine) 63 { 64 65 67 parseCommandLine(cmdLine); 68 } 69 70 75 public final int isCommand() 76 { 77 return m_cmd; 78 } 79 80 85 public final boolean hasArgument() 86 { 87 return m_arg != null ? true : false; 88 } 89 90 95 public final String getArgument() 96 { 97 return m_arg; 98 } 99 100 106 public final int setCommandLine(String cmdLine) 107 { 108 109 111 m_cmd = FTPCommand.InvalidCmd; 112 m_arg = null; 113 114 116 parseCommandLine(cmdLine); 117 return isCommand(); 118 } 119 120 125 protected final void parseCommandLine(String cmdLine) 126 { 127 128 130 int pos = cmdLine.indexOf(' '); 131 String cmd = null; 132 133 if (pos != -1) 134 { 135 cmd = cmdLine.substring(0, pos); 136 m_arg = cmdLine.substring(pos + 1); 137 } 138 else 139 cmd = cmdLine; 140 141 143 m_cmd = FTPCommand.getCommandId(cmd); 144 } 145 146 151 protected final void updateArgument(String arg) 152 { 153 m_arg = arg; 154 } 155 156 161 public String toString() 162 { 163 StringBuilder str = new StringBuilder (); 164 165 str.append("["); 166 str.append(FTPCommand.getCommandName(m_cmd)); 167 str.append(":"); 168 str.append(m_arg); 169 str.append("]"); 170 171 return str.toString(); 172 } 173 } 174 | Popular Tags |