s/transport details/transport properties/g

This commit is contained in:
akwizgran
2011-08-02 13:08:44 +01:00
parent 0e48f4ba55
commit 2740b2b002
7 changed files with 29 additions and 27 deletions

View File

@@ -55,8 +55,8 @@ public interface DatabaseComponent {
void removeListener(DatabaseListener d);
/**
* Adds a new contact to the database with the given transport details and
* returns an ID for the contact.
* Adds a new contact to the database with the given transport properties
* and returns an ID for the contact.
*/
ContactId addContact(Map<String, String> transports) throws DbException;
@@ -110,10 +110,10 @@ public interface DatabaseComponent {
/** Returns the set of groups to which the user subscribes. */
Collection<Group> getSubscriptions() throws DbException;
/** Returns the local transport details. */
/** Returns the local transport properties. */
Map<String, String> getTransports() throws DbException;
/** Returns the transport details for the given contact. */
/** Returns the transport properties for the given contact. */
Map<String, String> getTransports(ContactId c) throws DbException;
/** Returns the contacts to which the given group is visible. */
@@ -151,7 +151,9 @@ public interface DatabaseComponent {
/** Records the user's rating for the given author. */
void setRating(AuthorId a, Rating r) throws DbException;
/** Sets the local transport details, replacing any existing details. */
/**
* Sets the local transport properties, replacing any existing properties.
*/
void setTransports(Map<String, String> transports) throws DbException;
/**

View File

@@ -77,8 +77,8 @@ interface Database<T> {
void addBatchToAck(T txn, ContactId c, BatchId b) throws DbException;
/**
* Adds a new contact to the database with the given transport details and
* returns an ID for the contact.
* Adds a new contact to the database with the given transport properties
* and returns an ID for the contact.
* <p>
* Locking: contacts write, transports write.
*/
@@ -268,14 +268,14 @@ interface Database<T> {
Collection<Group> getSubscriptions(T txn, ContactId c) throws DbException;
/**
* Returns the local transport details.
* Returns the local transport properties.
* <p>
* Locking: transports read.
*/
Map<String, String> getTransports(T txn) throws DbException;
/**
* Returns the transport details for the given contact.
* Returns the transport properties for the given contact.
* <p>
* Locking: contacts read, transports read.
*/
@@ -397,8 +397,7 @@ interface Database<T> {
long timestamp) throws DbException;
/**
* Sets the local transport details, replacing any existing transport
* details.
* Sets the local transport properties, replacing any existing properties.
* <p>
* Locking: transports write.
*/
@@ -406,8 +405,9 @@ interface Database<T> {
throws DbException;
/**
* Sets the transport details for the given contact, replacing any existing
* transport details unless the existing details have a newer timestamp.
* Sets the transport properties for the given contact, replacing any
* existing properties unless the existing properties have a newer
* timestamp.
* <p>
* Locking: contacts write, transports write.
*/

View File

@@ -444,7 +444,7 @@ abstract class JdbcDatabase implements Database<Connection> {
int rowsAffected = ps.executeUpdate();
assert rowsAffected == 1;
ps.close();
// Store the contact's transport details
// Store the contact's transport properties
if(transports != null) {
sql = "INSERT INTO contactTransports (contactId, key, value)"
+ " VALUES (?, ?, ?)";

View File

@@ -818,7 +818,7 @@ class ReadWriteLockDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
public void receiveTransports(ContactId c, Transports t)
throws DbException {
// Update the contact's transport details
// Update the contact's transport properties
contactLock.writeLock().lock();
try {
if(!containsContact(c)) throw new NoSuchContactException();

View File

@@ -608,7 +608,7 @@ class SynchronizedDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
public void receiveTransports(ContactId c, Transports t)
throws DbException {
// Update the contact's transport details
// Update the contact's transport properties
synchronized(contactLock) {
if(!containsContact(c)) throw new NoSuchContactException();
synchronized(transportLock) {

View File

@@ -744,10 +744,10 @@ public abstract class DatabaseComponentTest extends TestCase {
allowing(database).commitTransaction(txn);
allowing(database).containsContact(txn, contactId);
will(returnValue(true));
// Get the local transport details
// Get the local transport properties
oneOf(database).getTransports(txn);
will(returnValue(transports));
// Add the transports to the writer
// Add the properties to the writer
oneOf(transportWriter).writeTransports(transports);
}});
DatabaseComponent db = createDatabaseComponent(database, cleaner);

View File

@@ -783,24 +783,24 @@ public class H2DatabaseTest extends TestCase {
Database<Connection> db = open(false);
Connection txn = db.startTransaction();
// Add a contact with some transport details
// Add a contact with some transport properties
Map<String, String> transports = Collections.singletonMap("foo", "bar");
assertEquals(contactId, db.addContact(txn, transports));
assertEquals(transports, db.getTransports(txn, contactId));
// Replace the transport details
// Replace the transport properties
transports = new TreeMap<String, String>();
transports.put("foo", "bar baz");
transports.put("bar", "baz quux");
db.setTransports(txn, contactId, transports, 1);
assertEquals(transports, db.getTransports(txn, contactId));
// Remove the transport details
// Remove the transport properties
db.setTransports(txn, contactId,
Collections.<String, String>emptyMap(), 2);
assertEquals(Collections.emptyMap(), db.getTransports(txn, contactId));
// Set the local transport details
// Set the local transport properties
db.setTransports(txn, transports);
assertEquals(transports, db.getTransports(txn));
// Remove the local transport details
// Remove the local transport properties
db.setTransports(txn, Collections.<String, String>emptyMap());
assertEquals(Collections.emptyMap(), db.getTransports(txn));
@@ -813,22 +813,22 @@ public class H2DatabaseTest extends TestCase {
Database<Connection> db = open(false);
Connection txn = db.startTransaction();
// Add a contact with some transport details
// Add a contact with some transport properties
Map<String, String> transports = Collections.singletonMap("foo", "bar");
assertEquals(contactId, db.addContact(txn, transports));
assertEquals(transports, db.getTransports(txn, contactId));
// Replace the transport details using a timestamp of 2
// Replace the transport properties using a timestamp of 2
Map<String, String> transports1 = new TreeMap<String, String>();
transports1.put("foo", "bar baz");
transports1.put("bar", "baz quux");
db.setTransports(txn, contactId, transports1, 2);
assertEquals(transports1, db.getTransports(txn, contactId));
// Try to replace the transport details using a timestamp of 1
// Try to replace the transport properties using a timestamp of 1
Map<String, String> transports2 = new TreeMap<String, String>();
transports2.put("bar", "baz");
transports2.put("quux", "fnord");
db.setTransports(txn, contactId, transports2, 1);
// The old transports should still be there
// The old properties should still be there
assertEquals(transports1, db.getTransports(txn, contactId));
db.commitTransaction(txn);