mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 14:19:53 +01:00
Rename BDF methods.
This commit is contained in:
@@ -46,7 +46,7 @@ public class BdfDictionary extends Hashtable<String, Object> {
|
|||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getInteger(String key) throws FormatException {
|
public Long getLong(String key) throws FormatException {
|
||||||
Object o = get(key);
|
Object o = get(key);
|
||||||
if (o instanceof Long) return (Long) o;
|
if (o instanceof Long) return (Long) o;
|
||||||
if (o instanceof Integer) return ((Integer) o).longValue();
|
if (o instanceof Integer) return ((Integer) o).longValue();
|
||||||
@@ -55,7 +55,7 @@ public class BdfDictionary extends Hashtable<String, Object> {
|
|||||||
throw new FormatException();
|
throw new FormatException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getInteger(String key, Long defaultValue) {
|
public Long getLong(String key, Long defaultValue) {
|
||||||
Object o = get(key);
|
Object o = get(key);
|
||||||
if (o instanceof Long) return (Long) o;
|
if (o instanceof Long) return (Long) o;
|
||||||
if (o instanceof Integer) return ((Integer) o).longValue();
|
if (o instanceof Integer) return ((Integer) o).longValue();
|
||||||
@@ -64,14 +64,14 @@ public class BdfDictionary extends Hashtable<String, Object> {
|
|||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double getFloat(String key) throws FormatException {
|
public Double getDouble(String key) throws FormatException {
|
||||||
Object o = get(key);
|
Object o = get(key);
|
||||||
if (o instanceof Double) return (Double) o;
|
if (o instanceof Double) return (Double) o;
|
||||||
if (o instanceof Float) return ((Float) o).doubleValue();
|
if (o instanceof Float) return ((Float) o).doubleValue();
|
||||||
throw new FormatException();
|
throw new FormatException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double getFloat(String key, Double defaultValue) {
|
public Double getDouble(String key, Double defaultValue) {
|
||||||
Object o = get(key);
|
Object o = get(key);
|
||||||
if (o instanceof Double) return (Double) o;
|
if (o instanceof Double) return (Double) o;
|
||||||
if (o instanceof Float) return ((Float) o).doubleValue();
|
if (o instanceof Float) return ((Float) o).doubleValue();
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class BdfList extends Vector<Object> {
|
|||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getInteger(int index) throws FormatException {
|
public Long getLong(int index) throws FormatException {
|
||||||
Object o = get(index);
|
Object o = get(index);
|
||||||
if (o instanceof Long) return (Long) o;
|
if (o instanceof Long) return (Long) o;
|
||||||
if (o instanceof Integer) return ((Integer) o).longValue();
|
if (o instanceof Integer) return ((Integer) o).longValue();
|
||||||
@@ -48,7 +48,7 @@ public class BdfList extends Vector<Object> {
|
|||||||
throw new FormatException();
|
throw new FormatException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getInteger(int index, Long defaultValue) {
|
public Long getLong(int index, Long defaultValue) {
|
||||||
Object o = get(index);
|
Object o = get(index);
|
||||||
if (o instanceof Long) return (Long) o;
|
if (o instanceof Long) return (Long) o;
|
||||||
if (o instanceof Integer) return ((Integer) o).longValue();
|
if (o instanceof Integer) return ((Integer) o).longValue();
|
||||||
@@ -57,14 +57,14 @@ public class BdfList extends Vector<Object> {
|
|||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double getFloat(int index) throws FormatException {
|
public Double getDouble(int index) throws FormatException {
|
||||||
Object o = get(index);
|
Object o = get(index);
|
||||||
if (o instanceof Double) return (Double) o;
|
if (o instanceof Double) return (Double) o;
|
||||||
if (o instanceof Float) return ((Float) o).doubleValue();
|
if (o instanceof Float) return ((Float) o).doubleValue();
|
||||||
throw new FormatException();
|
throw new FormatException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double getFloat(int index, Double defaultValue) {
|
public Double getDouble(int index, Double defaultValue) {
|
||||||
Object o = get(index);
|
Object o = get(index);
|
||||||
if (o instanceof Double) return (Double) o;
|
if (o instanceof Double) return (Double) o;
|
||||||
if (o instanceof Float) return ((Float) o).doubleValue();
|
if (o instanceof Float) return ((Float) o).doubleValue();
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ class ForumManagerImpl implements ForumManager {
|
|||||||
for (Entry<MessageId, Metadata> e : metadata.entrySet()) {
|
for (Entry<MessageId, Metadata> e : metadata.entrySet()) {
|
||||||
try {
|
try {
|
||||||
BdfDictionary d = metadataParser.parse(e.getValue());
|
BdfDictionary d = metadataParser.parse(e.getValue());
|
||||||
long timestamp = d.getInteger("timestamp");
|
long timestamp = d.getLong("timestamp");
|
||||||
Author author = null;
|
Author author = null;
|
||||||
Author.Status authorStatus = ANONYMOUS;
|
Author.Status authorStatus = ANONYMOUS;
|
||||||
BdfDictionary d1 = d.getDictionary("author", null);
|
BdfDictionary d1 = d.getDictionary("author", null);
|
||||||
|
|||||||
@@ -331,7 +331,7 @@ class ForumSharingManagerImpl implements ForumSharingManager, AddContactHook,
|
|||||||
for (Entry<MessageId, Metadata> e : metadata.entrySet()) {
|
for (Entry<MessageId, Metadata> e : metadata.entrySet()) {
|
||||||
BdfDictionary d = metadataParser.parse(e.getValue());
|
BdfDictionary d = metadataParser.parse(e.getValue());
|
||||||
if (d.getBoolean("local") != local) continue;
|
if (d.getBoolean("local") != local) continue;
|
||||||
long version = d.getInteger("version");
|
long version = d.getLong("version");
|
||||||
if (latest == null || version > latest.version)
|
if (latest == null || version > latest.version)
|
||||||
latest = new LatestUpdate(e.getKey(), version);
|
latest = new LatestUpdate(e.getKey(), version);
|
||||||
}
|
}
|
||||||
@@ -408,7 +408,7 @@ class ForumSharingManagerImpl implements ForumSharingManager, AddContactHook,
|
|||||||
throws DbException, FormatException {
|
throws DbException, FormatException {
|
||||||
Metadata meta = db.getGroupMetadata(txn, contactGroupId);
|
Metadata meta = db.getGroupMetadata(txn, contactGroupId);
|
||||||
BdfDictionary d = metadataParser.parse(meta);
|
BdfDictionary d = metadataParser.parse(meta);
|
||||||
return new ContactId(d.getInteger("contactId").intValue());
|
return new ContactId(d.getLong("contactId").intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<GroupId> getVisibleForums(Transaction txn,
|
private Set<GroupId> getVisibleForums(Transaction txn,
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ class MessagingManagerImpl implements MessagingManager, AddContactHook,
|
|||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
BdfDictionary d = metadataParser.parse(meta);
|
BdfDictionary d = metadataParser.parse(meta);
|
||||||
return new ContactId(d.getInteger("contactId").intValue());
|
return new ContactId(d.getLong("contactId").intValue());
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new DbException(e);
|
throw new DbException(e);
|
||||||
}
|
}
|
||||||
@@ -173,7 +173,7 @@ class MessagingManagerImpl implements MessagingManager, AddContactHook,
|
|||||||
if (m == null) continue;
|
if (m == null) continue;
|
||||||
try {
|
try {
|
||||||
BdfDictionary d = metadataParser.parse(m);
|
BdfDictionary d = metadataParser.parse(m);
|
||||||
long timestamp = d.getInteger("timestamp");
|
long timestamp = d.getLong("timestamp");
|
||||||
String contentType = d.getString("contentType");
|
String contentType = d.getString("contentType");
|
||||||
boolean local = d.getBoolean("local");
|
boolean local = d.getBoolean("local");
|
||||||
boolean read = d.getBoolean("read");
|
boolean read = d.getBoolean("read");
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ class TransportPropertyManagerImpl implements TransportPropertyManager,
|
|||||||
BdfDictionary d = metadataParser.parse(e.getValue());
|
BdfDictionary d = metadataParser.parse(e.getValue());
|
||||||
if (d.getBoolean("local") == local) {
|
if (d.getBoolean("local") == local) {
|
||||||
TransportId t = new TransportId(d.getString("transportId"));
|
TransportId t = new TransportId(d.getString("transportId"));
|
||||||
long version = d.getInteger("version");
|
long version = d.getLong("version");
|
||||||
LatestUpdate latest = latestUpdates.get(t);
|
LatestUpdate latest = latestUpdates.get(t);
|
||||||
if (latest == null || version > latest.version)
|
if (latest == null || version > latest.version)
|
||||||
latestUpdates.put(t, new LatestUpdate(e.getKey(), version));
|
latestUpdates.put(t, new LatestUpdate(e.getKey(), version));
|
||||||
@@ -324,7 +324,7 @@ class TransportPropertyManagerImpl implements TransportPropertyManager,
|
|||||||
BdfDictionary d = metadataParser.parse(e.getValue());
|
BdfDictionary d = metadataParser.parse(e.getValue());
|
||||||
if (d.getString("transportId").equals(t.getString())
|
if (d.getString("transportId").equals(t.getString())
|
||||||
&& d.getBoolean("local") == local) {
|
&& d.getBoolean("local") == local) {
|
||||||
long version = d.getInteger("version");
|
long version = d.getLong("version");
|
||||||
if (latest == null || version > latest.version)
|
if (latest == null || version > latest.version)
|
||||||
latest = new LatestUpdate(e.getKey(), version);
|
latest = new LatestUpdate(e.getKey(), version);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ public class BdfDictionaryTest extends BriarTestCase {
|
|||||||
d.put("bar", (short) 2);
|
d.put("bar", (short) 2);
|
||||||
d.put("baz", 3);
|
d.put("baz", 3);
|
||||||
d.put("bam", 4L);
|
d.put("bam", 4L);
|
||||||
assertEquals(Long.valueOf(1), d.getInteger("foo"));
|
assertEquals(Long.valueOf(1), d.getLong("foo"));
|
||||||
assertEquals(Long.valueOf(2), d.getInteger("bar"));
|
assertEquals(Long.valueOf(2), d.getLong("bar"));
|
||||||
assertEquals(Long.valueOf(3), d.getInteger("baz"));
|
assertEquals(Long.valueOf(3), d.getLong("baz"));
|
||||||
assertEquals(Long.valueOf(4), d.getInteger("bam"));
|
assertEquals(Long.valueOf(4), d.getLong("bam"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -46,8 +46,8 @@ public class BdfDictionaryTest extends BriarTestCase {
|
|||||||
BdfDictionary d = new BdfDictionary();
|
BdfDictionary d = new BdfDictionary();
|
||||||
d.put("foo", 1F);
|
d.put("foo", 1F);
|
||||||
d.put("bar", 2D);
|
d.put("bar", 2D);
|
||||||
assertEquals(Double.valueOf(1), d.getFloat("foo"));
|
assertEquals(Double.valueOf(1), d.getDouble("foo"));
|
||||||
assertEquals(Double.valueOf(2), d.getFloat("bar"));
|
assertEquals(Double.valueOf(2), d.getDouble("bar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ public class BdfListTest extends BriarTestCase {
|
|||||||
list.add((short) 2);
|
list.add((short) 2);
|
||||||
list.add(3);
|
list.add(3);
|
||||||
list.add(4L);
|
list.add(4L);
|
||||||
assertEquals(Long.valueOf(1), list.getInteger(0));
|
assertEquals(Long.valueOf(1), list.getLong(0));
|
||||||
assertEquals(Long.valueOf(2), list.getInteger(1));
|
assertEquals(Long.valueOf(2), list.getLong(1));
|
||||||
assertEquals(Long.valueOf(3), list.getInteger(2));
|
assertEquals(Long.valueOf(3), list.getLong(2));
|
||||||
assertEquals(Long.valueOf(4), list.getInteger(3));
|
assertEquals(Long.valueOf(4), list.getLong(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -46,8 +46,8 @@ public class BdfListTest extends BriarTestCase {
|
|||||||
BdfList list = new BdfList();
|
BdfList list = new BdfList();
|
||||||
list.add(1F);
|
list.add(1F);
|
||||||
list.add(2D);
|
list.add(2D);
|
||||||
assertEquals(Double.valueOf(1), list.getFloat(0));
|
assertEquals(Double.valueOf(1), list.getDouble(0));
|
||||||
assertEquals(Double.valueOf(2), list.getFloat(1));
|
assertEquals(Double.valueOf(2), list.getDouble(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class MetadataEncoderParserImplTest extends BriarTestCase {
|
|||||||
d.put("test", 1337);
|
d.put("test", 1337);
|
||||||
Metadata metadata = e.encode(d);
|
Metadata metadata = e.encode(d);
|
||||||
|
|
||||||
assertEquals(1337L, (long) p.parse(metadata).getInteger("test", 0L));
|
assertEquals(1337L, (long) p.parse(metadata).getLong("test", 0L));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -42,7 +42,7 @@ public class MetadataEncoderParserImplTest extends BriarTestCase {
|
|||||||
Metadata metadata = e.encode(d);
|
Metadata metadata = e.encode(d);
|
||||||
|
|
||||||
assertEquals(Long.MAX_VALUE,
|
assertEquals(Long.MAX_VALUE,
|
||||||
(long) p.parse(metadata).getInteger("test", 0L));
|
(long) p.parse(metadata).getLong("test", 0L));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -51,7 +51,7 @@ public class MetadataEncoderParserImplTest extends BriarTestCase {
|
|||||||
Metadata metadata = e.encode(d);
|
Metadata metadata = e.encode(d);
|
||||||
|
|
||||||
assertEquals(Double.MAX_VALUE,
|
assertEquals(Double.MAX_VALUE,
|
||||||
p.parse(metadata).getFloat("test", 0.0), 0);
|
p.parse(metadata).getDouble("test", 0.0), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -60,7 +60,7 @@ public class MetadataEncoderParserImplTest extends BriarTestCase {
|
|||||||
Metadata metadata = e.encode(d);
|
Metadata metadata = e.encode(d);
|
||||||
|
|
||||||
assertEquals(Float.MIN_NORMAL,
|
assertEquals(Float.MIN_NORMAL,
|
||||||
p.parse(metadata).getFloat("test", 0.0), 0);
|
p.parse(metadata).getDouble("test", 0.0), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user