argos/dmp-backend/src/main/java/models/components/commons/datafield/ComboBoxData.java

84 lines
1.7 KiB
Java
Raw Normal View History

package models.components.commons.datafield;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import utilities.XmlSerializable;
2017-12-13 13:01:43 +01:00
public abstract class ComboBoxData<T> extends FieldData<T>{
public class Option implements XmlSerializable<Option>{
private String label;
private String value;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public Element toXml(Document doc) {
Element option = doc.createElement("option");
option.setAttribute("label", this.label);
option.setAttribute("value",this.value);
return option;
}
@Override
public Option fromXml(Element item) {
this.label = item.getAttribute("label");
this.value = item.getAttribute("value");
return this;
}
}
private String type;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
2017-12-13 13:01:43 +01:00
@Override
public Element toXml(Document doc) {
Element root = doc.createElement("data");
root.setAttribute("type", this.type);
return root;
}
@Override
2017-12-13 13:01:43 +01:00
public T fromXml(Element item) {
this.type = item.getAttribute("type");
2017-12-13 13:01:43 +01:00
return (T)this;
}
@Override
2017-12-13 13:01:43 +01:00
public T fromData(Object data) {
if(data!=null){
this.type = (String)((Map<String,Object>)data).get("type");
}
2017-12-05 17:56:21 +01:00
2017-12-13 13:01:43 +01:00
return (T)this;
}
@Override
public Object toData() {
// TODO Auto-generated method stub
return null;
}
}