* @param types
* the types of this {@link Data}
* @param name
- * its name
+ * its name (<b>MUST NOT</b> be NULL)
* @param value
- * its value
+ * its value (<b>MUST NOT</b> be NULL)
* @param group
- * its group if any
+ * its group if any (or NULL if none)
*/
public Data(List<TypeInfo> types, String name, String value, String group) {
super(types);
- this.name = name;
- this.value = value;
+ this.name = name.toUpperCase();
+ this.value = value.toString(); // crash NOW if null
this.group = group;
b64 = -1;
public boolean isBinary() {
return b64 >= 0;
}
+
+ /**
+ * Check if this {@link Data} has the "preferred" flag.
+ *
+ * @return TRUE if it has
+ */
+ public boolean isPreferred() {
+ for (TypeInfo type : this) {
+ if (type.getName().equals("TYPE") && type.getValue().equals("pref")) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public String getId() {
+ return "" + name;
+ }
+
+ @Override
+ public String getState() {
+ return ("" + name + value + group).replace(' ', '_');
+ }
}