jmud-0.11/
jmud-0.11/bin/
jmud-0.11/doc/
jmud-0.11/rec/
jmud-0.11/rec/mun/
jmud-0.11/rec/mun/grecia/
jmud-0.11/rec/mun/gunnar/
jmud-0.11/rec/qua/
jmud-0.11/src/bool/
jmud-0.11/src/clone/
jmud-0.11/src/integer/
jmud-0.11/src/misc/
jmud-0.11/src/string/
jmud-0.11/src/util/bit/
jmud-0.11/src/util/color/
jmud-0.11/src/util/file/
jmud-0.11/src/util/jgp/adaptor/
jmud-0.11/src/util/jgp/algorithm/
jmud-0.11/src/util/jgp/container/
jmud-0.11/src/util/jgp/functor/
jmud-0.11/src/util/jgp/interfaces/
jmud-0.11/src/util/jgp/predicate/
jmud-0.11/src/util/log/
jmud-0.11/src/util/state/
jmud-0.11/trash/
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;

import util.file.InvalidFileFormatException;
import string.StrUtil;

class BoardEntry {

    static final String fieldSep = " :: ";

    private int     authorId;
    private int     authorRank;
    private boolean authorIsPlayer;
    private String  header;
    private String  body;

    BoardEntry(int id, int rank, boolean player, String authorName, String date, String title, String bd) {
	authorId       = id;
	authorRank     = rank;
	authorIsPlayer = player;
	header         = StrUtil.rightPad(authorName, Client.MAX_NAME_LENGTH) + fieldSep + date + fieldSep + title;
	body           = bd;
    }

    BoardEntry(BufferedReader reader) throws InvalidFileFormatException {
	try {
	    if (!reader.ready())
		throw new InvalidFileFormatException();

	    authorId         = Integer.parseInt(reader.readLine());
	    authorRank       = Integer.parseInt(reader.readLine());
	    authorIsPlayer   = Boolean.getBoolean(reader.readLine());
	    header           = reader.readLine();

	    body             = StrUtil.readDescription(reader);
	}
	catch(IOException e) {
	    throw new InvalidFileFormatException();
	}
    }

    void save(BufferedWriter writer) throws IOException {
	writer.write(String.valueOf(authorId));       writer.newLine();
	writer.write(String.valueOf(authorRank));     writer.newLine();
	writer.write(String.valueOf(authorIsPlayer)); writer.newLine();
	writer.write(header);                         writer.newLine();

	StrUtil.writeDescription(writer, body);
    }

    int getAuthorId() {
	return authorId;
    }

    int getAuthorRank() {
	return authorRank;
    }

    boolean authorIsPlayer() {
	return authorIsPlayer;
    }

    String getHeader() {
	return  header;
    }

    String getBody() {
	return body;
    }
}