mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 21:59:54 +01:00
Converted MessageHeader from an interface to a value class.
This commit is contained in:
@@ -4,32 +4,74 @@ import net.sf.briar.api.messaging.AuthorId;
|
|||||||
import net.sf.briar.api.messaging.GroupId;
|
import net.sf.briar.api.messaging.GroupId;
|
||||||
import net.sf.briar.api.messaging.MessageId;
|
import net.sf.briar.api.messaging.MessageId;
|
||||||
|
|
||||||
public interface MessageHeader {
|
public class MessageHeader {
|
||||||
|
|
||||||
|
private final MessageId id, parent;
|
||||||
|
private final GroupId group;
|
||||||
|
private final AuthorId author;
|
||||||
|
private final String subject;
|
||||||
|
private final long timestamp;
|
||||||
|
private final boolean read, starred;
|
||||||
|
|
||||||
|
public MessageHeader(MessageId id, MessageId parent, GroupId group,
|
||||||
|
AuthorId author, String subject, long timestamp, boolean read,
|
||||||
|
boolean starred) {
|
||||||
|
this.id = id;
|
||||||
|
this.parent = parent;
|
||||||
|
this.group = group;
|
||||||
|
this.author = author;
|
||||||
|
this.subject = subject;
|
||||||
|
this.timestamp = timestamp;
|
||||||
|
this.read = read;
|
||||||
|
this.starred = starred;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns the message's unique identifier. */
|
/** Returns the message's unique identifier. */
|
||||||
MessageId getId();
|
public MessageId getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the message's parent, or null if this is the first message in a
|
* Returns the message's parent, or null if this is the first message in a
|
||||||
* thread.
|
* thread.
|
||||||
*/
|
*/
|
||||||
MessageId getParent();
|
public MessageId getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns the group to which the message belongs. */
|
/**
|
||||||
GroupId getGroup();
|
* Returns the ID of the group to which the message belongs, or null if
|
||||||
|
* this is a private message.
|
||||||
|
*/
|
||||||
|
public GroupId getGroup() {
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns the message's author. */
|
/**
|
||||||
AuthorId getAuthor();
|
* Returns the ID of the message's author, or null if this is an
|
||||||
|
* anonymous message.
|
||||||
|
*/
|
||||||
|
public AuthorId getAuthor() {
|
||||||
|
return author;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns the message's subject line. */
|
/** Returns the message's subject line. */
|
||||||
String getSubject();
|
public String getSubject() {
|
||||||
|
return subject;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns the timestamp created by the message's author. */
|
/** Returns the timestamp created by the message's author. */
|
||||||
long getTimestamp();
|
public long getTimestamp() {
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns true if the message has been read. */
|
/** Returns true if the message has been read. */
|
||||||
boolean getRead();
|
public boolean getRead() {
|
||||||
|
return read;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns true if the message has been starred. */
|
/** Returns true if the message has been starred. */
|
||||||
boolean getStarred();
|
public boolean getStarred() {
|
||||||
|
return starred;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1189,7 +1189,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
if(rs.next()) throw new DbStateException();
|
if(rs.next()) throw new DbStateException();
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
return new MessageHeaderImpl(m, parent, group, author, subject,
|
return new MessageHeader(m, parent, group, author, subject,
|
||||||
timestamp, read, starred);
|
timestamp, read, starred);
|
||||||
} catch(SQLException e) {
|
} catch(SQLException e) {
|
||||||
tryToClose(rs);
|
tryToClose(rs);
|
||||||
@@ -1220,8 +1220,8 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
long timestamp = rs.getLong(5);
|
long timestamp = rs.getLong(5);
|
||||||
boolean read = rs.getBoolean(6);
|
boolean read = rs.getBoolean(6);
|
||||||
boolean starred = rs.getBoolean(7);
|
boolean starred = rs.getBoolean(7);
|
||||||
headers.add(new MessageHeaderImpl(id, parent, g, author,
|
headers.add(new MessageHeader(id, parent, g, author, subject,
|
||||||
subject, timestamp, read, starred));
|
timestamp, read, starred));
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
|
|||||||
@@ -1,61 +0,0 @@
|
|||||||
package net.sf.briar.db;
|
|
||||||
|
|
||||||
import net.sf.briar.api.db.MessageHeader;
|
|
||||||
import net.sf.briar.api.messaging.AuthorId;
|
|
||||||
import net.sf.briar.api.messaging.GroupId;
|
|
||||||
import net.sf.briar.api.messaging.MessageId;
|
|
||||||
|
|
||||||
class MessageHeaderImpl implements MessageHeader {
|
|
||||||
|
|
||||||
private final MessageId id, parent;
|
|
||||||
private final GroupId group;
|
|
||||||
private final AuthorId author;
|
|
||||||
private final String subject;
|
|
||||||
private final long timestamp;
|
|
||||||
private final boolean read, starred;
|
|
||||||
|
|
||||||
MessageHeaderImpl(MessageId id, MessageId parent, GroupId group,
|
|
||||||
AuthorId author, String subject, long timestamp, boolean read,
|
|
||||||
boolean starred) {
|
|
||||||
this.id = id;
|
|
||||||
this.parent = parent;
|
|
||||||
this.group = group;
|
|
||||||
this.author = author;
|
|
||||||
this.subject = subject;
|
|
||||||
this.timestamp = timestamp;
|
|
||||||
this.read = read;
|
|
||||||
this.starred = starred;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MessageId getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MessageId getParent() {
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GroupId getGroup() {
|
|
||||||
return group;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AuthorId getAuthor() {
|
|
||||||
return author;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSubject() {
|
|
||||||
return subject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTimestamp() {
|
|
||||||
return timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getRead() {
|
|
||||||
return read;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getStarred() {
|
|
||||||
return starred;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user