/*
* Copyright 2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mockftpserver.core.command;
import org.mockftpserver.core.session.Session;
import org.mockftpserver.core.util.AssertFailedException;
import org.mockftpserver.stub.command.AbstractStubCommandHandler;
/**
* CommandHandler that sends back the configured reply code and text. You can customize the
* returned reply code by setting the required replyCode
property. If only the
* replyCode
property is set, then the default reply text corresponding to that
* reply code is used in the response. You can optionally configure the reply text by setting
* the replyMessageKey
or replyText
property.
*
* Each invocation record stored by this CommandHandler contains no data elements. * * @version $Revision: 95 $ - $Date: 2007-10-30 22:05:41 -0400 (Tue, 30 Oct 2007) $ * * @author Chris Mair */ public final class StaticReplyCommandHandler extends AbstractStubCommandHandler implements CommandHandler { /** * Create a new uninitialized instance */ public StaticReplyCommandHandler() { } /** * Create a new instance with the specified replyCode * @param replyCode - the replyCode to use * @throws AssertFailedException - if the replyCode is null */ public StaticReplyCommandHandler(int replyCode) { setReplyCode(replyCode); } /** * Create a new instance with the specified replyCode and replyText * @param replyCode - the replyCode to use * @param replyText - the replyText * @throws AssertFailedException - if the replyCode is null */ public StaticReplyCommandHandler(int replyCode, String replyText) { setReplyCode(replyCode); setReplyText(replyText); } /** * @see org.mockftpserver.core.command.CommandHandler#handleCommand(Command, Session, InvocationRecord) */ public void handleCommand(Command command, Session session, InvocationRecord invocationRecord) { sendReply(session); } }