1 /*
2 * Copyright (c) 2004-2007 Creative Sphere Limited.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 *
10 * Creative Sphere - initial API and implementation
11 *
12 */
13 package org.abstracthorizon.mercury.imap.cmd;
14
15 import java.io.IOException;
16
17 import org.abstracthorizon.mercury.imap.IMAPSession;
18 import org.abstracthorizon.mercury.imap.response.BADResponse;
19
20 /**
21 * Artificial command representing unknown command
22 *
23 * @author Daniel Sendula
24 */
25 public class Bad extends IMAPCommand {
26
27 /** Error message */
28 protected String error;
29
30 /**
31 * Constructor
32 */
33 public Bad() {
34 super("");
35 }
36
37 /**
38 * Sets error message
39 * @param error error message
40 */
41 public void setErrorString(String error) {
42 this.error = error;
43 }
44
45 /**
46 * Executes the command
47 * @param session
48 * @throws IOException
49 */
50 public void execute(IMAPSession session) throws IOException {
51 if (error == null) {
52 new BADResponse(session, "Command").submit();
53 } else {
54 new BADResponse(session, error).submit();
55 }
56 }
57 }