153295844df24dff0a1f59e1104795e640b54c2efchrismair/*
253295844df24dff0a1f59e1104795e640b54c2efchrismair * Copyright 2007 the original author or authors.
353295844df24dff0a1f59e1104795e640b54c2efchrismair *
453295844df24dff0a1f59e1104795e640b54c2efchrismair * Licensed under the Apache License, Version 2.0 (the "License");
553295844df24dff0a1f59e1104795e640b54c2efchrismair * you may not use this file except in compliance with the License.
653295844df24dff0a1f59e1104795e640b54c2efchrismair * You may obtain a copy of the License at
753295844df24dff0a1f59e1104795e640b54c2efchrismair *
853295844df24dff0a1f59e1104795e640b54c2efchrismair *      http://www.apache.org/licenses/LICENSE-2.0
953295844df24dff0a1f59e1104795e640b54c2efchrismair *
1053295844df24dff0a1f59e1104795e640b54c2efchrismair * Unless required by applicable law or agreed to in writing, software
1153295844df24dff0a1f59e1104795e640b54c2efchrismair * distributed under the License is distributed on an "AS IS" BASIS,
1253295844df24dff0a1f59e1104795e640b54c2efchrismair * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1353295844df24dff0a1f59e1104795e640b54c2efchrismair * See the License for the specific language governing permissions and
1453295844df24dff0a1f59e1104795e640b54c2efchrismair * limitations under the License.
1553295844df24dff0a1f59e1104795e640b54c2efchrismair */
1653295844df24dff0a1f59e1104795e640b54c2efchrismairpackage org.mockftpserver.core.command;
1753295844df24dff0a1f59e1104795e640b54c2efchrismair
1853295844df24dff0a1f59e1104795e640b54c2efchrismairimport org.mockftpserver.core.session.Session;
1953295844df24dff0a1f59e1104795e640b54c2efchrismairimport org.mockftpserver.core.util.AssertFailedException;
2053295844df24dff0a1f59e1104795e640b54c2efchrismairimport org.mockftpserver.stub.command.AbstractStubCommandHandler;
2153295844df24dff0a1f59e1104795e640b54c2efchrismair
2253295844df24dff0a1f59e1104795e640b54c2efchrismair/**
2353295844df24dff0a1f59e1104795e640b54c2efchrismair * CommandHandler that sends back the configured reply code and text. You can customize the
2453295844df24dff0a1f59e1104795e640b54c2efchrismair * returned reply code by setting the required <code>replyCode</code> property. If only the
2553295844df24dff0a1f59e1104795e640b54c2efchrismair * <code>replyCode</code> property is set, then the default reply text corresponding to that
2653295844df24dff0a1f59e1104795e640b54c2efchrismair * reply code is used in the response. You can optionally configure the reply text by setting
2753295844df24dff0a1f59e1104795e640b54c2efchrismair * the <code>replyMessageKey</code> or <code>replyText</code> property.
2853295844df24dff0a1f59e1104795e640b54c2efchrismair * <p>
2953295844df24dff0a1f59e1104795e640b54c2efchrismair * Each invocation record stored by this CommandHandler contains no data elements.
3053295844df24dff0a1f59e1104795e640b54c2efchrismair *
3153295844df24dff0a1f59e1104795e640b54c2efchrismair * @version $Revision$ - $Date$
3253295844df24dff0a1f59e1104795e640b54c2efchrismair *
3353295844df24dff0a1f59e1104795e640b54c2efchrismair * @author Chris Mair
3453295844df24dff0a1f59e1104795e640b54c2efchrismair */
3553295844df24dff0a1f59e1104795e640b54c2efchrismairpublic final class StaticReplyCommandHandler extends AbstractStubCommandHandler implements CommandHandler {
3653295844df24dff0a1f59e1104795e640b54c2efchrismair
3753295844df24dff0a1f59e1104795e640b54c2efchrismair    /**
3853295844df24dff0a1f59e1104795e640b54c2efchrismair     * Create a new uninitialized instance
3953295844df24dff0a1f59e1104795e640b54c2efchrismair     */
4053295844df24dff0a1f59e1104795e640b54c2efchrismair    public StaticReplyCommandHandler() {
4153295844df24dff0a1f59e1104795e640b54c2efchrismair    }
4253295844df24dff0a1f59e1104795e640b54c2efchrismair
4353295844df24dff0a1f59e1104795e640b54c2efchrismair    /**
4453295844df24dff0a1f59e1104795e640b54c2efchrismair     * Create a new instance with the specified replyCode
4553295844df24dff0a1f59e1104795e640b54c2efchrismair     * @param replyCode - the replyCode to use
4653295844df24dff0a1f59e1104795e640b54c2efchrismair     * @throws AssertFailedException - if the replyCode is null
4753295844df24dff0a1f59e1104795e640b54c2efchrismair     */
4853295844df24dff0a1f59e1104795e640b54c2efchrismair    public StaticReplyCommandHandler(int replyCode) {
4953295844df24dff0a1f59e1104795e640b54c2efchrismair        setReplyCode(replyCode);
5053295844df24dff0a1f59e1104795e640b54c2efchrismair    }
5153295844df24dff0a1f59e1104795e640b54c2efchrismair
5253295844df24dff0a1f59e1104795e640b54c2efchrismair    /**
5353295844df24dff0a1f59e1104795e640b54c2efchrismair     * Create a new instance with the specified replyCode and replyText
5453295844df24dff0a1f59e1104795e640b54c2efchrismair     * @param replyCode - the replyCode to use
5553295844df24dff0a1f59e1104795e640b54c2efchrismair     * @param replyText - the replyText
5653295844df24dff0a1f59e1104795e640b54c2efchrismair     * @throws AssertFailedException - if the replyCode is null
5753295844df24dff0a1f59e1104795e640b54c2efchrismair     */
5853295844df24dff0a1f59e1104795e640b54c2efchrismair    public StaticReplyCommandHandler(int replyCode, String replyText) {
5953295844df24dff0a1f59e1104795e640b54c2efchrismair        setReplyCode(replyCode);
6053295844df24dff0a1f59e1104795e640b54c2efchrismair        setReplyText(replyText);
6153295844df24dff0a1f59e1104795e640b54c2efchrismair    }
6253295844df24dff0a1f59e1104795e640b54c2efchrismair
6353295844df24dff0a1f59e1104795e640b54c2efchrismair    /**
6453295844df24dff0a1f59e1104795e640b54c2efchrismair     * @see org.mockftpserver.core.command.CommandHandler#handleCommand(Command, Session, InvocationRecord)
6553295844df24dff0a1f59e1104795e640b54c2efchrismair     */
6653295844df24dff0a1f59e1104795e640b54c2efchrismair    public void handleCommand(Command command, Session session, InvocationRecord invocationRecord) {
6753295844df24dff0a1f59e1104795e640b54c2efchrismair        sendReply(session);
6853295844df24dff0a1f59e1104795e640b54c2efchrismair    }
6953295844df24dff0a1f59e1104795e640b54c2efchrismair
7053295844df24dff0a1f59e1104795e640b54c2efchrismair}
71