author | chris <chris@marvin> |
Tue, 20 Jan 2009 10:21:03 +0100 | |
changeset 0 | f907866f0e4b |
permissions | -rw-r--r-- |
chris@0 | 1 |
/* |
chris@0 | 2 |
* StarOffice News Server |
chris@0 | 3 |
* see AUTHORS for the list of contributors |
chris@0 | 4 |
* |
chris@0 | 5 |
* This program is free software: you can redistribute it and/or modify |
chris@0 | 6 |
* it under the terms of the GNU General Public License as published by |
chris@0 | 7 |
* the Free Software Foundation, either version 3 of the License, or |
chris@0 | 8 |
* (at your option) any later version. |
chris@0 | 9 |
* |
chris@0 | 10 |
* This program is distributed in the hope that it will be useful, |
chris@0 | 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
chris@0 | 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
chris@0 | 13 |
* GNU General Public License for more details. |
chris@0 | 14 |
* |
chris@0 | 15 |
* You should have received a copy of the GNU General Public License |
chris@0 | 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
chris@0 | 17 |
*/ |
chris@0 | 18 |
|
chris@0 | 19 |
package com.so.news.command; |
chris@0 | 20 |
|
chris@0 | 21 |
import java.io.IOException; |
chris@0 | 22 |
import java.util.List; |
chris@0 | 23 |
import com.so.news.NNTPConnection; |
chris@0 | 24 |
import com.so.news.storage.Article; |
chris@0 | 25 |
import com.so.news.storage.Group; |
chris@0 | 26 |
|
chris@0 | 27 |
/** |
chris@0 | 28 |
* Base class for all command handling classes. |
chris@0 | 29 |
* @author Christian Lins |
chris@0 | 30 |
* @author Dennis Schwerdel |
chris@0 | 31 |
*/ |
chris@0 | 32 |
public abstract class Command |
chris@0 | 33 |
{ |
chris@0 | 34 |
protected NNTPConnection connection; |
chris@0 | 35 |
|
chris@0 | 36 |
public Command(NNTPConnection connection) |
chris@0 | 37 |
{ |
chris@0 | 38 |
this.connection = connection; |
chris@0 | 39 |
} |
chris@0 | 40 |
|
chris@0 | 41 |
protected static String NEWLINE = NNTPConnection.NEWLINE; |
chris@0 | 42 |
|
chris@0 | 43 |
protected List<String> readText() |
chris@0 | 44 |
throws IOException |
chris@0 | 45 |
{ |
chris@0 | 46 |
return connection.readText(); |
chris@0 | 47 |
} |
chris@0 | 48 |
|
chris@0 | 49 |
protected String readTextLine() throws IOException |
chris@0 | 50 |
{ |
chris@0 | 51 |
return connection.readTextLine(); |
chris@0 | 52 |
} |
chris@0 | 53 |
|
chris@0 | 54 |
protected void printStatus(int status, String text) throws IOException |
chris@0 | 55 |
{ |
chris@0 | 56 |
connection.printStatus(status, text); |
chris@0 | 57 |
} |
chris@0 | 58 |
|
chris@0 | 59 |
protected void printTextLine(CharSequence text) throws IOException |
chris@0 | 60 |
{ |
chris@0 | 61 |
connection.printTextLine(text); |
chris@0 | 62 |
} |
chris@0 | 63 |
|
chris@0 | 64 |
protected void printTextPart(CharSequence text) throws IOException |
chris@0 | 65 |
{ |
chris@0 | 66 |
connection.printTextPart(text); |
chris@0 | 67 |
} |
chris@0 | 68 |
|
chris@0 | 69 |
protected void printText(CharSequence text) throws IOException |
chris@0 | 70 |
{ |
chris@0 | 71 |
connection.printText(text); |
chris@0 | 72 |
} |
chris@0 | 73 |
|
chris@0 | 74 |
protected void println(CharSequence text) throws IOException |
chris@0 | 75 |
{ |
chris@0 | 76 |
connection.println(text); |
chris@0 | 77 |
} |
chris@0 | 78 |
|
chris@0 | 79 |
protected void flush() throws IOException |
chris@0 | 80 |
{ |
chris@0 | 81 |
connection.flush(); |
chris@0 | 82 |
} |
chris@0 | 83 |
|
chris@0 | 84 |
protected Article getCurrentArticle() |
chris@0 | 85 |
{ |
chris@0 | 86 |
return connection.getCurrentArticle(); |
chris@0 | 87 |
} |
chris@0 | 88 |
|
chris@0 | 89 |
protected Group getCurrentGroup() |
chris@0 | 90 |
{ |
chris@0 | 91 |
return connection.getCurrentGroup(); |
chris@0 | 92 |
} |
chris@0 | 93 |
|
chris@0 | 94 |
protected void setCurrentArticle(Article current) |
chris@0 | 95 |
{ |
chris@0 | 96 |
connection.setCurrentArticle(current); |
chris@0 | 97 |
} |
chris@0 | 98 |
|
chris@0 | 99 |
protected void setCurrentGroup(Group current) |
chris@0 | 100 |
{ |
chris@0 | 101 |
connection.setCurrentGroup(current); |
chris@0 | 102 |
} |
chris@0 | 103 |
|
chris@0 | 104 |
public abstract boolean process(String[] command) |
chris@0 | 105 |
throws Exception; |
chris@0 | 106 |
} |