diff --git a/bramble-api/src/main/java/org/briarproject/bramble/api/data/BdfDictionary.java b/bramble-api/src/main/java/org/briarproject/bramble/api/data/BdfDictionary.java
index 11d6f8a08..2124cd14e 100644
--- a/bramble-api/src/main/java/org/briarproject/bramble/api/data/BdfDictionary.java
+++ b/bramble-api/src/main/java/org/briarproject/bramble/api/data/BdfDictionary.java
@@ -10,6 +10,27 @@ import java.util.TreeMap;
import javax.annotation.Nullable;
import javax.annotation.concurrent.NotThreadSafe;
+/**
+ * A BDF dictionary contains zero or more key-value pairs, where the keys
+ * are strings and the values are BDF objects, which may be primitive types
+ * (null, boolean, integer, float, string, raw) or nested containers (list,
+ * dictionary).
+ *
+ * Note that a BDF integer has the same range as a Java long, while a BDF
+ * float has the same range as a Java double. Method names in this class
+ * correspond to the Java types.
+ *
+ * The getX() methods throw {@link FormatException} if the specified key is
+ * absent, the value is null, or the value does not have the requested type.
+ *
+ * The getOptionalX() methods return null if the specified key is absent or
+ * the value is null, or throw {@link FormatException} if the value does not
+ * have the requested type.
+ *
+ * The getX() methods that take a default value return the default value if
+ * the specified key is absent or the value is null, or throw
+ * {@link FormatException} if the value does not have the requested type.
+ */
@NotThreadSafe
public final class BdfDictionary extends TreeMap {
@@ -80,12 +101,33 @@ public final class BdfDictionary extends TreeMap {
return value == null ? defaultValue : value;
}
+ /**
+ * Returns the integer with the specified key.
+ *
+ * This method should be used in preference to
+ * getLong(key).intValue() as it checks for
+ * overflow/underflow.
+ *
+ * @throws FormatException if there is no value at the specified key,
+ * or if the value is null or cannot be represented as a Java int.
+ */
public Integer getInt(String key) throws FormatException {
Integer value = getOptionalInt(key);
if (value == null) throw new FormatException();
return value;
}
+ /**
+ * Returns the integer with the specified key, or null if the key is
+ * absent or the value is null.
+ *
+ * This method should be used in preference to
+ * getOptionalLong(key).intValue() as it checks for
+ * overflow/underflow.
+ *
+ * @throws FormatException if the value at the specified key is not null
+ * and cannot be represented as a Java int.
+ */
@Nullable
public Integer getOptionalInt(String key) throws FormatException {
Long value = getOptionalLong(key);
@@ -96,6 +138,17 @@ public final class BdfDictionary extends TreeMap {
return value.intValue();
}
+ /**
+ * Returns the integer with the specified key, or the given default
+ * value if the key is absent or the value is null.
+ *
+ * This method should be used in preference to
+ * getLong(key, defaultValue).intValue() as it checks for
+ * overflow/underflow.
+ *
+ * @throws FormatException if the value at the specified key is not null
+ * and cannot be represented as a Java int.
+ */
public Integer getInt(String key, Integer defaultValue)
throws FormatException {
Integer value = getOptionalInt(key);
diff --git a/bramble-api/src/main/java/org/briarproject/bramble/api/data/BdfEntry.java b/bramble-api/src/main/java/org/briarproject/bramble/api/data/BdfEntry.java
index 3fb4b2678..42b52fc2e 100644
--- a/bramble-api/src/main/java/org/briarproject/bramble/api/data/BdfEntry.java
+++ b/bramble-api/src/main/java/org/briarproject/bramble/api/data/BdfEntry.java
@@ -6,6 +6,11 @@ import java.util.Map.Entry;
import javax.annotation.concurrent.Immutable;
+/**
+ * A convenience class for building {@link BdfDictionary BdfDictionaries}
+ * via the {@link BdfDictionary#of(Entry[]) factory method}. Entries in
+ * BdfDictionaries do not have to be BdfEntries.
+ */
@Immutable
@NotNullByDefault
public class BdfEntry implements Entry, Comparable {
diff --git a/bramble-api/src/main/java/org/briarproject/bramble/api/data/BdfList.java b/bramble-api/src/main/java/org/briarproject/bramble/api/data/BdfList.java
index 6ba6747cc..bce11b079 100644
--- a/bramble-api/src/main/java/org/briarproject/bramble/api/data/BdfList.java
+++ b/bramble-api/src/main/java/org/briarproject/bramble/api/data/BdfList.java
@@ -12,6 +12,29 @@ import javax.annotation.concurrent.NotThreadSafe;
import static org.briarproject.bramble.api.data.BdfDictionary.NULL_VALUE;
+/**
+ * A BDF list contains zero or more BDF objects, which may be primitive types
+ * (null, boolean, integer, float, string, raw) or nested containers (list,
+ * dictionary).
+ *
+ * Note that a BDF integer has the same range as a Java long, while a BDF
+ * float has the same range as a Java double. Method names in this class
+ * correspond to the Java types.
+ *
+ * The getX() methods throw {@link FormatException} if the object at the
+ * specified index is null or does not have the requested type.
+ *
+ * The getOptionalX() methods return null if the object at the specified
+ * index is null, or throw {@link FormatException} if the object does not
+ * have the requested type.
+ *
+ * The getX() methods that take a default value return the default value if
+ * the object at the specified index is null, or throw
+ * {@link FormatException} if the object does not have the requested type.
+ *
+ * All of the getters throw {@link FormatException} if the specified index is
+ * out of range.
+ */
@NotThreadSafe
public final class BdfList extends ArrayList