Initial import.
2 * StarOffice News Server
3 * see AUTHORS for the list of contributors
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 package com.so.news.command;
21 import java.io.IOException;
22 import java.util.List;
23 import com.so.news.NNTPConnection;
24 import com.so.news.storage.Article;
25 import com.so.news.storage.Group;
28 * Base class for all command handling classes.
29 * @author Christian Lins
30 * @author Dennis Schwerdel
32 public abstract class Command
34 protected NNTPConnection connection;
36 public Command(NNTPConnection connection)
38 this.connection = connection;
41 protected static String NEWLINE = NNTPConnection.NEWLINE;
43 protected List<String> readText()
46 return connection.readText();
49 protected String readTextLine() throws IOException
51 return connection.readTextLine();
54 protected void printStatus(int status, String text) throws IOException
56 connection.printStatus(status, text);
59 protected void printTextLine(CharSequence text) throws IOException
61 connection.printTextLine(text);
64 protected void printTextPart(CharSequence text) throws IOException
66 connection.printTextPart(text);
69 protected void printText(CharSequence text) throws IOException
71 connection.printText(text);
74 protected void println(CharSequence text) throws IOException
76 connection.println(text);
79 protected void flush() throws IOException
84 protected Article getCurrentArticle()
86 return connection.getCurrentArticle();
89 protected Group getCurrentGroup()
91 return connection.getCurrentGroup();
94 protected void setCurrentArticle(Article current)
96 connection.setCurrentArticle(current);
99 protected void setCurrentGroup(Group current)
101 connection.setCurrentGroup(current);
104 public abstract boolean process(String[] command)