1/* 2 * Copyright 2007 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16package org.mockftpserver.stub.command; 17 18import org.mockftpserver.core.command.Command; 19import org.mockftpserver.core.command.CommandHandler; 20import org.mockftpserver.core.command.InvocationRecord; 21import org.mockftpserver.core.command.ReplyCodes; 22import org.mockftpserver.core.session.Session; 23import org.mockftpserver.core.util.Assert; 24 25/** 26 * CommandHandler for the SYST (System) command. Send back a reply code of 215. By default, 27 * return "WINDOWS" as the system name. You can customize the returned name by 28 * setting the <code>systemName</code> property. 29 * <p> 30 * See the available system names listed in the Assigned Numbers document (RFC 943). 31 * <p> 32 * Each invocation record stored by this CommandHandler contains no data elements. 33 34 * @see http://www.ietf.org/rfc/rfc943 35 * 36 * @version $Revision$ - $Date$ 37 * 38 * @author Chris Mair 39 */ 40public final class SystCommandHandler extends AbstractStubCommandHandler implements CommandHandler { 41 42 private String systemName = "WINDOWS"; 43 44 /** 45 * Constructor. Initialize the replyCode. 46 */ 47 public SystCommandHandler() { 48 setReplyCode(ReplyCodes.SYST_OK); 49 } 50 51 /** 52 * @see org.mockftpserver.core.command.CommandHandler#handleCommand(Command, Session, InvocationRecord) 53 */ 54 public void handleCommand(Command command, Session session, InvocationRecord invocationRecord) { 55 sendReply(session, quotes(systemName)); 56 } 57 58 /** 59 * Set the systemName String to be returned by this command 60 * @param systemName - the systemName 61 */ 62 public void setSystemName(String systemName) { 63 Assert.notNull(systemName, "systemName"); 64 this.systemName = systemName; 65 } 66 67} 68