71 lines
1.6 KiB
Java
71 lines
1.6 KiB
Java
package org.hwo.servicelink.register;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import javax.xml.xpath.XPath;
|
|
import javax.xml.xpath.XPathConstants;
|
|
import javax.xml.xpath.XPathFactory;
|
|
|
|
import org.hwo.xml.NodeListIterator;
|
|
import org.w3c.dom.Element;
|
|
import org.w3c.dom.Node;
|
|
import org.w3c.dom.NodeList;
|
|
|
|
public class ServiceRegisterList {
|
|
ServiceRegisterRegistry registry;
|
|
String label;
|
|
String id;
|
|
|
|
List<ServiceRegisterInstance> serviceRegisterInstances;
|
|
|
|
XPath xpath;
|
|
|
|
public ServiceRegisterList(ServiceRegisterRegistry registry){
|
|
this.registry = registry;
|
|
this.label = "-";
|
|
this.xpath = XPathFactory.newInstance().newXPath();
|
|
this.serviceRegisterInstances = new ArrayList<ServiceRegisterInstance>();
|
|
}
|
|
|
|
public ServiceRegisterRegistry getRegistry() {
|
|
return registry;
|
|
}
|
|
|
|
public String getLabel() {
|
|
return label;
|
|
}
|
|
public void setLabel(String label) {
|
|
this.label = label;
|
|
}
|
|
|
|
public String getId() {
|
|
return id;
|
|
}
|
|
public void setId(String id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public void createFromNode(Node registerListNode){
|
|
Element registerListElement = (Element)registerListNode;
|
|
|
|
setId(registerListElement.getAttribute("id"));
|
|
setLabel(registerListElement.getAttribute("label"));
|
|
|
|
try {
|
|
NodeList serviceRegisterList = (NodeList)xpath.evaluate("Register", registerListNode, XPathConstants.NODESET);
|
|
for (Node registerNode: NodeListIterator.create(serviceRegisterList)){
|
|
ServiceRegisterInstance sri = ServiceRegisterInstance.fromRegisterNode(this, registerNode);
|
|
this.serviceRegisterInstances.add(sri);
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e){
|
|
e.printStackTrace();
|
|
}
|
|
|
|
}
|
|
|
|
}
|