本文整理了Java中org.opendaylight.controller.config.util.xml.XmlElement.getOnlyChildElementOptionally()
方法的一些代码示例,展示了XmlElement.getOnlyChildElementOptionally()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlElement.getOnlyChildElementOptionally()
方法的具体详情如下:
包路径:org.opendaylight.controller.config.util.xml.XmlElement
类名称:XmlElement
方法名:getOnlyChildElementOptionally
暂无
代码示例来源:origin: org.opendaylight.netconf/mdsal-netconf-connector
private XmlElement getElement(final XmlElement operationElement, String elementName) throws DocumentedException {
final Optional<XmlElement> childNode = operationElement.getOnlyChildElementOptionally(elementName);
if (!childNode.isPresent()) {
throw new DocumentedException(elementName + " element is missing",
ErrorType.protocol,
ErrorTag.missing_element,
ErrorSeverity.error);
}
return childNode.get();
}
代码示例来源:origin: org.opendaylight.controller/config-util
public Optional<XmlElement> getOnlyChildElementWithSameNamespaceOptionally() {
Optional<XmlElement> child = getOnlyChildElementOptionally();
if (child.isPresent()
&& child.get().getNamespaceOptionally().isPresent()
&& getNamespaceOptionally().isPresent()
&& getNamespaceOptionally().get().equals(child.get().getNamespaceOptionally().get())) {
return child;
}
return Optional.absent();
}
代码示例来源:origin: org.opendaylight.netconf/mdsal-netconf-connector
/**
*
* @param operationElement operation element
* @return if Filter is present and not empty returns Optional of the InstanceIdentifier to the read location in datastore.
* empty filter returns Optional.absent() which should equal an empty <data/> container in the response.
* if filter is not present we want to read the entire datastore - return ROOT.
* @throws DocumentedException
*/
protected Optional<YangInstanceIdentifier> getDataRootFromFilter(XmlElement operationElement) throws DocumentedException {
Optional<XmlElement> filterElement = operationElement.getOnlyChildElementOptionally(FILTER);
if (filterElement.isPresent()) {
if (filterElement.get().getChildElements().size() == 0) {
return Optional.absent();
}
return Optional.of(getInstanceIdentifierFromFilter(filterElement.get()));
} else {
return Optional.of(ROOT);
}
}
代码示例来源:origin: org.opendaylight.netconf/mdsal-netconf-connector
private static Optional<Datastore> parseSource(final XmlElement xml) throws DocumentedException {
final Optional<XmlElement> sourceElement = xml.getOnlyChildElementOptionally(XmlNetconfConstants.SOURCE_KEY,
XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
return sourceElement.isPresent() ?
Optional.of(Datastore.valueOf(sourceElement.get().getOnlyChildElement().getName())) : Optional.<Datastore>absent();
}
代码示例来源:origin: org.opendaylight.netconf/netconf-util
public static Collection<String> extractCapabilitiesFromHello(Document doc) throws NetconfDocumentedException {
XmlElement responseElement = XmlElement.fromDomDocument(doc);
// Extract child element <capabilities> from <hello> with or without(fallback) the same namespace
Optional<XmlElement> capabilitiesElement = responseElement
.getOnlyChildElementWithSameNamespaceOptionally(XmlNetconfConstants.CAPABILITIES)
.or(responseElement
.getOnlyChildElementOptionally(XmlNetconfConstants.CAPABILITIES));
List<XmlElement> caps = capabilitiesElement.get().getChildElements(XmlNetconfConstants.CAPABILITY);
return Collections2.transform(caps, new Function<XmlElement, String>() {
@Override
public String apply(@Nonnull XmlElement input) {
// Trim possible leading/tailing whitespace
try {
return input.getTextContent().trim();
} catch (DocumentedException e) {
LOG.trace("Error fetching input text content",e);
return null;
}
}
});
}
}
代码示例来源:origin: org.opendaylight.netconf/netconf-util
public static Document applyRpcSubtreeFilter(Document requestDocument, Document rpcReply) throws DocumentedException {
OperationNameAndNamespace operationNameAndNamespace = new OperationNameAndNamespace(requestDocument);
if (XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0.equals(operationNameAndNamespace.getNamespace()) &&
XmlNetconfConstants.GET.equals(operationNameAndNamespace.getOperationName()) ||
XmlNetconfConstants.GET_CONFIG.equals(operationNameAndNamespace.getOperationName())) {
// process subtree filtering here, in case registered netconf operations do
// not implement filtering.
Optional<XmlElement> maybeFilter = operationNameAndNamespace.getOperationElement().getOnlyChildElementOptionally(
XmlNetconfConstants.FILTER, XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
if (!maybeFilter.isPresent()) {
return rpcReply;
}
XmlElement filter = maybeFilter.get();
if (isSupported(filter)) {
// do
return filtered(maybeFilter.get(), rpcReply);
}
}
return rpcReply; // return identical document
}
代码示例来源:origin: org.opendaylight.netconf/config-netconf-connector
.getOnlyChildElementOptionally(RpcFacade.CONTEXT_INSTANCE);
内容来源于网络,如有侵权,请联系作者删除!