1b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair/*
2b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * Copyright 2007 the original author or authors.
3b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair *
4b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * Licensed under the Apache License, Version 2.0 (the "License");
5b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * you may not use this file except in compliance with the License.
6b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * You may obtain a copy of the License at
7b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair *
8b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair *      http://www.apache.org/licenses/LICENSE-2.0
9b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair *
10b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * Unless required by applicable law or agreed to in writing, software
11b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * distributed under the License is distributed on an "AS IS" BASIS,
12b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * See the License for the specific language governing permissions and
14b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * limitations under the License.
15b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair */
16b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismairpackage org.mockftpserver.core.command;
17b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair
18b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismairimport org.mockftpserver.core.session.Session;
19b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismairimport org.mockftpserver.core.util.AssertFailedException;
20b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair
21b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair/**
22b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * CommandHandler that sends back the configured reply code and text. You can customize the
23b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * returned reply code by setting the required <code>replyCode</code> property. If only the
24b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * <code>replyCode</code> property is set, then the default reply text corresponding to that
25b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * reply code is used in the response. You can optionally configure the reply text by setting
26b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * the <code>replyMessageKey</code> or <code>replyText</code> property.
27b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * <p>
28b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * Each invocation record stored by this CommandHandler contains no data elements.
29b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair *
30b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * @version $Revision$ - $Date$
31b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair *
32b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * @author Chris Mair
33b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair */
34b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismairpublic final class StaticReplyCommandHandler extends AbstractStaticReplyCommandHandler {
35b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair
36b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair    /**
37b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair     * Create a new uninitialized instance
38b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair     */
39b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair    public StaticReplyCommandHandler() {
40b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair    }
41b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair
42b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair    /**
43b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair     * Create a new instance with the specified replyCode
44b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair     * @param replyCode - the replyCode to use
45b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair     * @throws AssertFailedException - if the replyCode is null
46b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair     */
47b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair    public StaticReplyCommandHandler(int replyCode) {
48b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair        setReplyCode(replyCode);
49b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair    }
50b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair
51b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair    /**
52b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair     * Create a new instance with the specified replyCode and replyText
53b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair     * @param replyCode - the replyCode to use
54b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair     * @param replyText - the replyText
55b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair     * @throws AssertFailedException - if the replyCode is null
56b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair     */
57b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair    public StaticReplyCommandHandler(int replyCode, String replyText) {
58b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair        setReplyCode(replyCode);
59b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair        setReplyText(replyText);
60b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair    }
61b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair
62b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair    /**
63b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair     * @see AbstractTrackingCommandHandler#handleCommand(Command, org.mockftpserver.core.session.Session, InvocationRecord)
64b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair     */
65b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair    public void handleCommand(Command command, Session session, InvocationRecord invocationRecord) {
66b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair        sendReply(session);
67b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair    }
68b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair
69b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair}
70