* basically a key/value pair with optional types and an optional group name.
*
* @author niki
- *
+ *
*/
public class Data extends BaseClass<TypeInfo> {
public enum DataPart {
}
/**
- * Check if this {@link Data} has the "preferred" flag.
+ * Return the preferred value of this {@link Data}, or
+ * {@link Integer#MAX_VALUE} if none.
*
- * @return TRUE if it has
+ * @return the preferred value
*/
- public boolean isPreferred() {
+ public int getPreferred() {
for (TypeInfo type : this) {
- if (type.getName().equals("TYPE") && type.getValue().equals("pref")) {
- return true;
+ if (type.getName().equals("PRE")) {
+ try {
+ return Integer.parseInt(type.getValue());
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ }
}
}
- return false;
+ return Integer.MAX_VALUE;
}
/**
public String getState() {
return ("" + name + value + group).replace(' ', '_');
}
+
+ @Override
+ public String toString() {
+ String out = name + ": " + value;
+ if (group != null && !group.isEmpty()) {
+ out += " (" + group + ")";
+ }
+ if (b64 >= 0) {
+ out += " [" + b64 + "]";
+ }
+
+ return out;
+ }
}