53 lines
1.2 KiB
Java
53 lines
1.2 KiB
Java
package eu.eudat.commons.types.descriptiontemplate;
|
|
|
|
import eu.eudat.commons.types.xml.XmlSerializable;
|
|
import org.w3c.dom.Document;
|
|
import org.w3c.dom.Element;
|
|
|
|
public class RuleEntity implements XmlSerializable<RuleEntity> {
|
|
private String target;
|
|
private String value;
|
|
|
|
public String getTarget() {
|
|
return target;
|
|
}
|
|
|
|
public void setTarget(String target) {
|
|
this.target = target;
|
|
}
|
|
|
|
public String getValue() {
|
|
return value;
|
|
}
|
|
|
|
public void setValue(String value) {
|
|
this.value = value;
|
|
}
|
|
|
|
@Override
|
|
public Element toXml(Document doc) {
|
|
Element rule = doc.createElement("rule");
|
|
rule.setAttribute("target", this.target);
|
|
|
|
Element value = doc.createElement("value");
|
|
value.setTextContent(this.value);
|
|
|
|
rule.appendChild(value);
|
|
return rule;
|
|
}
|
|
|
|
@Override
|
|
public RuleEntity fromXml(Element item) {
|
|
this.target = item.getAttribute("target");
|
|
|
|
Element value = (Element) item.getElementsByTagName("value").item(0);
|
|
if (value != null) {
|
|
this.value = value.getTextContent();
|
|
}
|
|
|
|
return this;
|
|
}
|
|
|
|
|
|
}
|