package foundation.icall.callout;
|
|
import java.util.List;
|
|
import org.dom4j.Element;
|
|
import foundation.data.entity.Entity;
|
import foundation.data.entity.EntitySet;
|
import foundation.translator.Translator;
|
import foundation.util.MapList;
|
|
public class HttpServerMeta implements IRemoteSourceMeta {
|
|
private String name;
|
private String className;
|
private boolean active;
|
private MapList<String, String> items;
|
|
public HttpServerMeta() {
|
items = new MapList<String, String>();
|
}
|
|
public void load(Entity entity) {
|
name = entity.getString("name");
|
className = entity.getString("classname");
|
active = entity.getBoolean("is_active", false);
|
}
|
|
public void loadItems(EntitySet elementList) {
|
String name, value;
|
|
for (Entity entity: elementList) {
|
name = entity.getString("element");
|
value = entity.getString("value");
|
|
items.add(name, value);
|
}
|
}
|
|
public void load(Element element) {
|
//1.
|
name = element.attributeValue("name");
|
className = element.attributeValue("classname");
|
active = Translator.toBoolean(element.attributeValue("active"), false);
|
|
//2.
|
List<Element> children = element.elements();
|
for (Element child: children) {
|
String name = child.getName();
|
String value = child.getText();
|
|
items.add(name, value);
|
}
|
}
|
|
@Override
|
public IRemoteSource createRemoteSource() {
|
try {
|
HttpServerSource result = HttpServerSource.newInstance(this);
|
return result;
|
}
|
catch (Exception e) {
|
e.printStackTrace();
|
return null;
|
}
|
}
|
|
@Override
|
public String getName() {
|
return name;
|
}
|
|
public String getClassName() {
|
return className;
|
}
|
|
public boolean isActive() {
|
return active;
|
}
|
|
public String getString(String name) {
|
return items.get(name);
|
}
|
|
}
|