chris@0: /* chris@0: * StarOffice News Server chris@0: * see AUTHORS for the list of contributors chris@0: * chris@0: * This program is free software: you can redistribute it and/or modify chris@0: * it under the terms of the GNU General Public License as published by chris@0: * the Free Software Foundation, either version 3 of the License, or chris@0: * (at your option) any later version. chris@0: * chris@0: * This program is distributed in the hope that it will be useful, chris@0: * but WITHOUT ANY WARRANTY; without even the implied warranty of chris@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the chris@0: * GNU General Public License for more details. chris@0: * chris@0: * You should have received a copy of the GNU General Public License chris@0: * along with this program. If not, see . chris@0: */ chris@0: chris@0: package com.so.news.command; chris@0: chris@0: import java.io.IOException; chris@0: import java.util.List; chris@0: import com.so.news.NNTPConnection; chris@0: import com.so.news.storage.Article; chris@0: import com.so.news.storage.Group; chris@0: chris@0: /** chris@0: * Base class for all command handling classes. chris@0: * @author Christian Lins chris@0: * @author Dennis Schwerdel chris@0: */ chris@0: public abstract class Command chris@0: { chris@0: protected NNTPConnection connection; chris@0: chris@0: public Command(NNTPConnection connection) chris@0: { chris@0: this.connection = connection; chris@0: } chris@0: chris@0: protected static String NEWLINE = NNTPConnection.NEWLINE; chris@0: chris@0: protected List readText() chris@0: throws IOException chris@0: { chris@0: return connection.readText(); chris@0: } chris@0: chris@0: protected String readTextLine() throws IOException chris@0: { chris@0: return connection.readTextLine(); chris@0: } chris@0: chris@0: protected void printStatus(int status, String text) throws IOException chris@0: { chris@0: connection.printStatus(status, text); chris@0: } chris@0: chris@0: protected void printTextLine(CharSequence text) throws IOException chris@0: { chris@0: connection.printTextLine(text); chris@0: } chris@0: chris@0: protected void printTextPart(CharSequence text) throws IOException chris@0: { chris@0: connection.printTextPart(text); chris@0: } chris@0: chris@0: protected void printText(CharSequence text) throws IOException chris@0: { chris@0: connection.printText(text); chris@0: } chris@0: chris@0: protected void println(CharSequence text) throws IOException chris@0: { chris@0: connection.println(text); chris@0: } chris@0: chris@0: protected void flush() throws IOException chris@0: { chris@0: connection.flush(); chris@0: } chris@0: chris@0: protected Article getCurrentArticle() chris@0: { chris@0: return connection.getCurrentArticle(); chris@0: } chris@0: chris@0: protected Group getCurrentGroup() chris@0: { chris@0: return connection.getCurrentGroup(); chris@0: } chris@0: chris@0: protected void setCurrentArticle(Article current) chris@0: { chris@0: connection.setCurrentArticle(current); chris@0: } chris@0: chris@0: protected void setCurrentGroup(Group current) chris@0: { chris@0: connection.setCurrentGroup(current); chris@0: } chris@0: chris@0: public abstract boolean process(String[] command) chris@0: throws Exception; chris@0: }