use of org.eclipse.kura.core.configuration.metatype.Tdesignate in project kura by eclipse.
the class XmlJavaMetadataMapper method unmarshal.
@SuppressWarnings("unchecked")
@Override
public <T> T unmarshal(Document doc) {
Element metadata = doc.getDocumentElement();
Tmetadata tMetadata = parseMetadataAttributes(metadata);
NodeList metadataChilds = metadata.getChildNodes();
Element[] metadataChildsArray = getElementNodes(metadataChilds);
for (Element node : metadataChildsArray) {
String localName = node.getNodeName();
if (localName.equals("OCD")) {
Tocd tocd = parseOCD(node);
tMetadata.setOCD(tocd);
} else if (localName.equals("Designate")) {
Tdesignate tDesignate = parseDesignate(node);
tMetadata.setDesignate(tDesignate);
}
}
return (T) tMetadata;
}
use of org.eclipse.kura.core.configuration.metatype.Tdesignate in project kura by eclipse.
the class XmlJavaMetadataMapper method parseDesignate.
private Tdesignate parseDesignate(Element designate) {
String pid = designate.getAttribute(METADATA_DESIGNATE_PID);
String factoryPid = designate.getAttribute(METADATA_DESIGNATE_FACTORY_PID);
String bundle = designate.getAttribute(METADATA_DESIGNATE_BUNDLE);
Boolean optional = Boolean.parseBoolean(designate.getAttribute(METADATA_DESIGNATE_OPTIONAL));
Boolean merge = Boolean.parseBoolean(designate.getAttribute(METADATA_DESIGNATE_MERGE));
Tdesignate tDesignate = new Tdesignate();
if (!pid.trim().isEmpty()) {
tDesignate.setPid(pid);
}
if (!factoryPid.trim().isEmpty()) {
tDesignate.setFactoryPid(factoryPid);
}
if (!bundle.trim().isEmpty()) {
tDesignate.setBundle(bundle);
}
tDesignate.setOptional(optional);
tDesignate.setMerge(merge);
NodeList objectsChilds = designate.getChildNodes();
Element[] objectsChildElements = getElementNodes(objectsChilds);
for (Element node : objectsChildElements) {
String localName = node.getNodeName();
if (localName.equals(METADATA_DESIGNATE_OBJECT)) {
// parse Object
Tobject tObject = parseObject(node);
tDesignate.setObject(tObject);
}
}
return tDesignate;
}
Aggregations