blob: 135039f1a8747fb074c3031e811d012bc21bbe2b [file] [log] [blame]
chrismair00dc7bd2014-05-11 21:21:28 +00001/*
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.core.command;
17
18import org.mockftpserver.core.session.Session;
19import org.mockftpserver.core.util.AssertFailedException;
20
21/**
22 * CommandHandler that sends back the configured reply code and text. You can customize the
23 * returned reply code by setting the required <code>replyCode</code> property. If only the
24 * <code>replyCode</code> property is set, then the default reply text corresponding to that
25 * reply code is used in the response. You can optionally configure the reply text by setting
26 * the <code>replyMessageKey</code> or <code>replyText</code> property.
27 * <p>
28 * Each invocation record stored by this CommandHandler contains no data elements.
29 *
30 * @version $Revision$ - $Date$
31 *
32 * @author Chris Mair
33 */
34public final class StaticReplyCommandHandler extends AbstractStaticReplyCommandHandler {
35
36 /**
37 * Create a new uninitialized instance
38 */
39 public StaticReplyCommandHandler() {
40 }
41
42 /**
43 * Create a new instance with the specified replyCode
44 * @param replyCode - the replyCode to use
45 * @throws AssertFailedException - if the replyCode is null
46 */
47 public StaticReplyCommandHandler(int replyCode) {
48 setReplyCode(replyCode);
49 }
50
51 /**
52 * Create a new instance with the specified replyCode and replyText
53 * @param replyCode - the replyCode to use
54 * @param replyText - the replyText
55 * @throws AssertFailedException - if the replyCode is null
56 */
57 public StaticReplyCommandHandler(int replyCode, String replyText) {
58 setReplyCode(replyCode);
59 setReplyText(replyText);
60 }
61
62 /**
63 * @see AbstractTrackingCommandHandler#handleCommand(Command, org.mockftpserver.core.session.Session, InvocationRecord)
64 */
65 public void handleCommand(Command command, Session session, InvocationRecord invocationRecord) {
66 sendReply(session);
67 }
68
69}