Source code: org/mrbook/mrpostman/another/summary/CmdSummary.java
1 /*
2 * -*- mode: java; c-basic-indent: 4; indent-tabs-mode: nil -*-
3 * :indentSize=4:noTabs=true:tabSize=4:indentOnTab=true:indentOnEnter=true:mode=java:
4 * ex: set tabstop=4 expandtab:
5 *
6 * MrPostman - webmail <-> email gateway
7 * Copyright (C) 2002-2003 MrPostman Development Group
8 * Projectpage: http://mrbook.org/mrpostman/
9 *
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 * In particular, this implies that users are responsible for
21 * using MrPostman after reading the terms and conditions given
22 * by their web-mail provider.
23 *
24 * You should have received a copy of the GNU General Public License
25 * Named LICENSE in the base directory of this distribution,
26 * if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 */
29
30 package org.mrbook.mrpostman.another.summary;
31
32
33 /**
34 * Command Summary class. This will store the summary information for a particular POP command execution.
35 * @author Chris Humphreys
36 */
37 public class CmdSummary {
38 public static final String CVSID = "$Id: CmdSummary.java,v 1.5 2003/02/09 23:38:13 lbruand Exp $";
39 public static final int TOP = 1;
40 public static final int DELE = 2;
41 public static final int RETR = 3;
42 private int type;
43 private boolean issued = false;
44 private boolean success = false;
45 private String errors = null;
46
47 public CmdSummary(int type) {
48 this.type = type;
49 issued = false;
50 }
51
52 public void success() {
53 this.issued = true;
54 this.success = true;
55 }
56
57 public void failure(String errMsg) {
58 this.issued = true;
59 this.success = false;
60 errors += errMsg;
61 }
62
63 public boolean isIssued() {
64 return issued;
65 }
66
67 public boolean isSuccess() {
68 return success;
69 }
70
71 public String getErrors() {
72 return errors;
73 }
74
75 public String toString() {
76 String s;
77
78 switch (type) {
79 case CmdSummary.TOP:
80 s = "TOP";
81 break;
82 case CmdSummary.DELE:
83 s = "DELE";
84 break;
85 case CmdSummary.RETR:
86 s = "RETR";
87 break;
88 default:
89 s = "UNKNOWN-CMD";
90 }
91
92 if (!issued) {
93 s += " not issued";
94 } else {
95 if (success) {
96 s += " success";
97 } else {
98 s += " failure: ";
99 s += errors;
100 }
101 }
102 return s;
103 }
104 }