mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Builders for batches and bundles.
This commit is contained in:
@@ -7,6 +7,7 @@ import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.Rating;
|
||||
import net.sf.briar.api.protocol.AuthorId;
|
||||
import net.sf.briar.api.protocol.Bundle;
|
||||
import net.sf.briar.api.protocol.BundleBuilder;
|
||||
import net.sf.briar.api.protocol.GroupId;
|
||||
import net.sf.briar.api.protocol.Message;
|
||||
|
||||
@@ -48,7 +49,7 @@ public interface DatabaseComponent {
|
||||
* Generates a bundle of acknowledgements, subscriptions, and batches of
|
||||
* messages for the given contact.
|
||||
*/
|
||||
void generateBundle(ContactId c, Bundle b) throws DbException;
|
||||
Bundle generateBundle(ContactId c, BundleBuilder bundleBuilder) throws DbException;
|
||||
|
||||
/** Returns the IDs of all contacts. */
|
||||
Set<ContactId> getContacts() throws DbException;
|
||||
|
||||
@@ -5,12 +5,7 @@ public interface Batch {
|
||||
|
||||
public static final long CAPACITY = 1024L * 1024L;
|
||||
|
||||
/** Prepares the batch for transmission and generates its identifier. */
|
||||
public void seal();
|
||||
|
||||
/**
|
||||
* Returns the batch's unique identifier. Cannot be called before seal().
|
||||
*/
|
||||
/** Returns the batch's unique identifier. */
|
||||
BatchId getId();
|
||||
|
||||
/** Returns the size of the batch in bytes. */
|
||||
@@ -18,7 +13,4 @@ public interface Batch {
|
||||
|
||||
/** Returns the messages contained in the batch. */
|
||||
Iterable<Message> getMessages();
|
||||
|
||||
/** Adds a message to the batch. Cannot be called after seal(). */
|
||||
void addMessage(Message m);
|
||||
}
|
||||
10
api/net/sf/briar/api/protocol/BatchBuilder.java
Normal file
10
api/net/sf/briar/api/protocol/BatchBuilder.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package net.sf.briar.api.protocol;
|
||||
|
||||
public interface BatchBuilder {
|
||||
|
||||
/** Adds a message to the batch. */
|
||||
void addMessage(Message m);
|
||||
|
||||
/** Builds and returns the batch. */
|
||||
Batch build();
|
||||
}
|
||||
@@ -5,12 +5,7 @@ import java.util.Map;
|
||||
/** A bundle of acknowledgements, subscriptions, and batches of messages. */
|
||||
public interface Bundle {
|
||||
|
||||
/** Prepares the bundle for transmission and generates its identifier. */
|
||||
public void seal();
|
||||
|
||||
/**
|
||||
* Returns the bundle's unique identifier. Cannot be called before seal().
|
||||
*/
|
||||
/** Returns the bundle's unique identifier. */
|
||||
BundleId getId();
|
||||
|
||||
/** Returns the bundle's capacity in bytes. */
|
||||
@@ -22,26 +17,12 @@ public interface Bundle {
|
||||
/** Returns the acknowledgements contained in the bundle. */
|
||||
Iterable<BatchId> getAcks();
|
||||
|
||||
/** Adds an acknowledgement to the bundle. Cannot be called after seal(). */
|
||||
void addAck(BatchId b);
|
||||
|
||||
/** Returns the subscriptions contained in the bundle. */
|
||||
Iterable<GroupId> getSubscriptions();
|
||||
|
||||
/** Adds a subscription to the bundle. Cannot be called after seal(). */
|
||||
void addSubscription(GroupId g);
|
||||
|
||||
/** Returns the transport details contained in the bundle. */
|
||||
Map<String, String> getTransports();
|
||||
|
||||
/** Adds a transport detail to the bundle. Cannot be called after seal(). */
|
||||
void addTransport(String key, String value);
|
||||
|
||||
/** Returns the batches of messages contained in the bundle. */
|
||||
Iterable<Batch> getBatches();
|
||||
|
||||
/**
|
||||
* Adds a batch of messages to the bundle. Cannot be called after seal().
|
||||
*/
|
||||
void addBatch(Batch b);
|
||||
}
|
||||
|
||||
22
api/net/sf/briar/api/protocol/BundleBuilder.java
Normal file
22
api/net/sf/briar/api/protocol/BundleBuilder.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package net.sf.briar.api.protocol;
|
||||
|
||||
public interface BundleBuilder {
|
||||
|
||||
/** Returns the bundle's capacity in bytes. */
|
||||
long getCapacity();
|
||||
|
||||
/** Adds an acknowledgement to the bundle. */
|
||||
void addAck(BatchId b);
|
||||
|
||||
/** Adds a subscription to the bundle. */
|
||||
void addSubscription(GroupId g);
|
||||
|
||||
/** Adds a transport detail to the bundle. */
|
||||
void addTransport(String key, String value);
|
||||
|
||||
/** Adds a batch of messages to the bundle. */
|
||||
void addBatch(Batch b);
|
||||
|
||||
/** Builds and returns the bundle. */
|
||||
Bundle build();
|
||||
}
|
||||
Reference in New Issue
Block a user