- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.opendaylight.controller.netconf.util.xml.XmlElement.getChildElements()
方法的一些代码示例,展示了XmlElement.getChildElements()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlElement.getChildElements()
方法的具体详情如下:
包路径:org.opendaylight.controller.netconf.util.xml.XmlElement
类名称:XmlElement
方法名:getChildElements
暂无
代码示例来源:origin: org.opendaylight.controller/netconf-impl
private static void addSubtree(XmlElement filter, XmlElement src, XmlElement dst) throws NetconfDocumentedException {
for (XmlElement srcChild : src.getChildElements()) {
for (XmlElement filterChild : filter.getChildElements()) {
addSubtree2(filterChild, srcChild, dst);
}
}
}
代码示例来源:origin: org.opendaylight.controller/netconf-util
public Optional<XmlElement> getOnlyChildElementOptionally(String childName) {
List<XmlElement> nameElements = getChildElements(childName);
if (nameElements.size() != 1) {
return Optional.absent();
}
return Optional.of(nameElements.get(0));
}
代码示例来源:origin: org.opendaylight.controller/netconf-util
public Optional<XmlElement> getOnlyChildElementOptionally() {
List<XmlElement> children = getChildElements();
if (children.size() != 1) {
return Optional.absent();
}
return Optional.of(children.get(0));
}
代码示例来源:origin: org.opendaylight.controller/netconf-util
public void checkUnrecognisedElements(List<XmlElement> recognisedElements,
XmlElement... additionalRecognisedElements) throws NetconfDocumentedException {
List<XmlElement> childElements = getChildElements();
childElements.removeAll(recognisedElements);
for (XmlElement additionalRecognisedElement : additionalRecognisedElements) {
childElements.remove(additionalRecognisedElement);
}
if (!childElements.isEmpty()){
throw new NetconfDocumentedException(String.format("Unrecognised elements %s in %s", childElements, this),
NetconfDocumentedException.ErrorType.application,
NetconfDocumentedException.ErrorTag.invalid_value,
NetconfDocumentedException.ErrorSeverity.error);
}
}
代码示例来源:origin: org.opendaylight.controller/netconf-util
public XmlElement getOnlyChildElement() throws NetconfDocumentedException {
List<XmlElement> children = getChildElements();
if (children.size() != 1){
throw new NetconfDocumentedException(String.format( "One element expected in %s but was %s", toString(),
children.size()),
NetconfDocumentedException.ErrorType.application,
NetconfDocumentedException.ErrorTag.invalid_value,
NetconfDocumentedException.ErrorSeverity.error);
}
return children.get(0);
}
代码示例来源:origin: org.opendaylight.controller/config-netconf-connector
private static Map<String, AttributeConfigElement> sortAttributes(
final Map<String, AttributeConfigElement> attributes, final XmlElement xml) {
final Map<String, AttributeConfigElement> sorted = Maps.newLinkedHashMap();
for (XmlElement xmlElement : xml.getChildElements()) {
final String name = xmlElement.getName();
if (!CONTEXT_INSTANCE.equals(name)) { // skip context
// instance child node
// because it
// specifies
// ObjectName
final AttributeConfigElement value = attributes.get(name);
if (value == null) {
throw new IllegalArgumentException("Cannot find yang mapping for node " + xmlElement);
}
sorted.put(name, value);
}
}
return sorted;
}
代码示例来源:origin: org.opendaylight.controller/netconf-util
public static boolean isErrorMessage(XmlElement xmlElement) throws NetconfDocumentedException {
if(xmlElement.getChildElements().size() != 1) {
return false;
}
return xmlElement.getOnlyChildElement().getName().equals(XmlNetconfConstants.RPC_ERROR);
}
代码示例来源:origin: org.opendaylight.controller/netconf-util
public static boolean isOKMessage(XmlElement xmlElement) throws NetconfDocumentedException {
if(xmlElement.getChildElements().size() != 1) {
return false;
}
return xmlElement.getOnlyChildElement().getName().equals(XmlNetconfConstants.OK);
}
代码示例来源:origin: org.opendaylight.controller/netconf-util
public XmlElement getOnlyChildElement(String childName) throws NetconfDocumentedException {
List<XmlElement> nameElements = getChildElements(childName);
if (nameElements.size() != 1){
throw new NetconfDocumentedException("One element " + childName + " expected in " + toString(),
NetconfDocumentedException.ErrorType.application,
NetconfDocumentedException.ErrorTag.invalid_value,
NetconfDocumentedException.ErrorSeverity.error);
}
return nameElements.get(0);
}
代码示例来源:origin: org.opendaylight.controller/netconf-testtool
private boolean containsDelete(final XmlElement element) {
for (final Attr o : element.getAttributes().values()) {
if (o.getLocalName().equals(OPERATION)
&& (o.getValue().equals(DELETE_EDIT_CONFIG) || o.getValue()
.equals(REMOVE_EDIT_CONFIG))) {
return true;
}
}
for (final XmlElement xmlElement : element.getChildElements()) {
if (containsDelete(xmlElement)) {
return true;
}
}
return false;
}
}
代码示例来源:origin: org.opendaylight.controller/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 NetconfDocumentedException
*/
protected Optional<YangInstanceIdentifier> getDataRootFromFilter(XmlElement operationElement) throws NetconfDocumentedException {
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.controller/config-netconf-connector
public Map<String, AttributeConfigElement> fromXml(XmlElement configRootNode) throws NetconfDocumentedException {
Map<String, AttributeConfigElement> retVal = Maps.newHashMap();
// FIXME add identity map to runtime data
Map<String, AttributeReadingStrategy> strats = new ObjectXmlReader().prepareReading(yangToAttrConfig,
Collections.<String, Map<Date, EditConfig.IdentityMapping>> emptyMap());
for (Entry<String, AttributeReadingStrategy> readStratEntry : strats.entrySet()) {
List<XmlElement> configNodes = configRootNode.getChildElements(readStratEntry.getKey());
AttributeConfigElement readElement = readStratEntry.getValue().readElement(configNodes);
retVal.put(readStratEntry.getKey(), readElement);
}
resolveConfiguration(retVal);
return retVal;
}
代码示例来源:origin: org.opendaylight.controller/sal-netconf-connector
private static Map.Entry<Date, XmlElement> stripNotification(final NetconfMessage message) {
final XmlElement xmlElement = XmlElement.fromDomDocument(message.getDocument());
final List<XmlElement> childElements = xmlElement.getChildElements();
Preconditions.checkArgument(childElements.size() == 2, "Unable to parse notification %s, unexpected format", message);
final XmlElement eventTimeElement;
final XmlElement notificationElement;
if (childElements.get(0).getName().equals(EVENT_TIME)) {
eventTimeElement = childElements.get(0);
notificationElement = childElements.get(1);
}
else if(childElements.get(1).getName().equals(EVENT_TIME)) {
eventTimeElement = childElements.get(1);
notificationElement = childElements.get(0);
} else {
throw new IllegalArgumentException("Notification payload does not contain " + EVENT_TIME + " " + message);
}
try {
return new AbstractMap.SimpleEntry<>(EVENT_TIME_FORMAT.get().parse(eventTimeElement.getTextContent()), notificationElement);
} catch (NetconfDocumentedException e) {
throw new IllegalArgumentException("Notification payload does not contain " + EVENT_TIME + " " + message);
} catch (ParseException e) {
LOG.warn("Unable to parse event time from {}. Setting time to {}", eventTimeElement, NetconfNotification.UNKNOWN_EVENT_TIME, e);
return new AbstractMap.SimpleEntry<>(NetconfNotification.UNKNOWN_EVENT_TIME, notificationElement);
}
}
代码示例来源:origin: org.opendaylight.controller/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 (NetconfDocumentedException e) {
LOG.trace("Error fetching input text content",e);
return null;
}
}
});
}
}
代码示例来源:origin: org.opendaylight.controller/netconf-impl
if (matches != MatchingResult.NO_MATCH && matches != MatchingResult.CONTENT_MISMATCH) {
boolean filterHasChildren = filter.getChildElements().isEmpty() == false;
for (XmlElement srcChild : src.getChildElements()) {
for (XmlElement filterChild : filter.getChildElements()) {
MatchingResult childMatch = addSubtree2(filterChild, srcChild, XmlElement.fromDomElement(copied));
if (childMatch == MatchingResult.CONTENT_MISMATCH) {
if (numberOfTextMatchingChildren == filter.getChildElements().size()) {
代码示例来源:origin: org.opendaylight.controller/config-netconf-connector
public static Services fromXml(XmlElement xml) throws NetconfDocumentedException {
Map<String, Map<String, Map<String, String>>> retVal = Maps.newHashMap();
List<XmlElement> services = xml.getChildElements(SERVICE_KEY);
xml.checkUnrecognisedElements(services);
List<XmlElement> instances = service.getChildElements(XmlNetconfConstants.INSTANCE_KEY);
service.checkUnrecognisedElements(instances, typeElement);
代码示例来源:origin: org.opendaylight.controller/mdsal-netconf-connector
@VisibleForTesting
protected YangInstanceIdentifier getInstanceIdentifierFromFilter(XmlElement filterElement) throws NetconfDocumentedException {
if (filterElement.getChildElements().size() != 1) {
throw new NetconfDocumentedException("Multiple filter roots not supported yet",
ErrorType.application, ErrorTag.operation_not_supported, ErrorSeverity.error);
}
XmlElement element = filterElement.getOnlyChildElement();
DataSchemaNode schemaNode = getSchemaNodeFromNamespace(element);
return getReadPointFromNode(YangInstanceIdentifier.builder().build(), filterToNormalizedNode(element, schemaNode));
}
代码示例来源:origin: org.opendaylight.controller/config-netconf-connector
private Element toXml(Document doc, Object result, AttributeIfc returnType, String namespace, String elementName) throws NetconfDocumentedException {
AttributeMappingStrategy<?, ? extends OpenType<?>> mappingStrategy = new ObjectMapper().prepareStrategy(returnType);
Optional<?> mappedAttributeOpt = mappingStrategy.mapAttribute(result);
Preconditions.checkState(mappedAttributeOpt.isPresent(), "Unable to map return value %s as %s", result, returnType.getOpenType());
// FIXME: multiple return values defined as leaf-list and list in yang should not be wrapped in output xml element,
// they need to be appended directly under rpc-reply element
//
// Either allow List of Elements to be returned from NetconfOperation or
// pass reference to parent output xml element for netconf operations to
// append result(s) on their own
Element tempParent = XmlUtil.createElement(doc, "output", Optional.of(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0));
new ObjectXmlWriter().prepareWritingStrategy(elementName, returnType, doc).writeElement(tempParent, namespace, mappedAttributeOpt.get());
XmlElement xmlElement = XmlElement.fromDomElement(tempParent);
return xmlElement.getChildElements().size() > 1 ? tempParent : xmlElement.getOnlyChildElement().getDomElement();
}
代码示例来源:origin: org.opendaylight.controller/netconf-testtool
@Override
protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement) throws NetconfDocumentedException {
final XmlElement configElementData = operationElement.getOnlyChildElement(XmlNetconfConstants.CONFIG_KEY);
containsDelete(configElementData);
if(containsDelete(configElementData)){
storage.resetConfigList();
} else {
storage.setConfigList(configElementData.getChildElements());
}
return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.<String>absent());
}
代码示例来源:origin: org.opendaylight.controller/mdsal-netconf-connector
@Override
protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement) throws NetconfDocumentedException {
final Datastore targetDatastore = extractTargetParameter(operationElement);
if (targetDatastore == Datastore.running) {
throw new NetconfDocumentedException("edit-config on running datastore is not supported",
ErrorType.protocol,
ErrorTag.operation_not_supported,
ErrorSeverity.error);
}
final ModifyAction defaultAction = getDefaultOperation(operationElement);
final XmlElement configElement = getElement(operationElement, CONFIG_KEY);
for (XmlElement element : configElement.getChildElements()) {
final String ns = element.getNamespace();
final DataSchemaNode schemaNode = getSchemaNodeFromNamespace(ns, element).get();
final DataTreeChangeTracker changeTracker = new DataTreeChangeTracker(defaultAction);
final DomToNormalizedNodeParserFactory.BuildingStrategyProvider editOperationStrategyProvider = new EditOperationStrategyProvider(changeTracker);
parseIntoNormalizedNode(schemaNode, element, editOperationStrategyProvider);
executeOperations(changeTracker);
}
return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.<String>absent());
}
我想了解 Ruby 方法 methods() 是如何工作的。 我尝试使用“ruby 方法”在 Google 上搜索,但这不是我需要的。 我也看过 ruby-doc.org,但我没有找到这种方法。
Test 方法 对指定的字符串执行一个正则表达式搜索,并返回一个 Boolean 值指示是否找到匹配的模式。 object.Test(string) 参数 object 必选项。总是一个
Replace 方法 替换在正则表达式查找中找到的文本。 object.Replace(string1, string2) 参数 object 必选项。总是一个 RegExp 对象的名称。
Raise 方法 生成运行时错误 object.Raise(number, source, description, helpfile, helpcontext) 参数 object 应为
Execute 方法 对指定的字符串执行正则表达式搜索。 object.Execute(string) 参数 object 必选项。总是一个 RegExp 对象的名称。 string
Clear 方法 清除 Err 对象的所有属性设置。 object.Clear object 应为 Err 对象的名称。 说明 在错误处理后,使用 Clear 显式地清除 Err 对象。此
CopyFile 方法 将一个或多个文件从某位置复制到另一位置。 object.CopyFile source, destination[, overwrite] 参数 object 必选
Copy 方法 将指定的文件或文件夹从某位置复制到另一位置。 object.Copy destination[, overwrite] 参数 object 必选项。应为 File 或 F
Close 方法 关闭打开的 TextStream 文件。 object.Close object 应为 TextStream 对象的名称。 说明 下面例子举例说明如何使用 Close 方
BuildPath 方法 向现有路径后添加名称。 object.BuildPath(path, name) 参数 object 必选项。应为 FileSystemObject 对象的名称
GetFolder 方法 返回与指定的路径中某文件夹相应的 Folder 对象。 object.GetFolder(folderspec) 参数 object 必选项。应为 FileSy
GetFileName 方法 返回指定路径(不是指定驱动器路径部分)的最后一个文件或文件夹。 object.GetFileName(pathspec) 参数 object 必选项。应为
GetFile 方法 返回与指定路径中某文件相应的 File 对象。 object.GetFile(filespec) 参数 object 必选项。应为 FileSystemObject
GetExtensionName 方法 返回字符串,该字符串包含路径最后一个组成部分的扩展名。 object.GetExtensionName(path) 参数 object 必选项。应
GetDriveName 方法 返回包含指定路径中驱动器名的字符串。 object.GetDriveName(path) 参数 object 必选项。应为 FileSystemObjec
GetDrive 方法 返回与指定的路径中驱动器相对应的 Drive 对象。 object.GetDrive drivespec 参数 object 必选项。应为 FileSystemO
GetBaseName 方法 返回字符串,其中包含文件的基本名 (不带扩展名), 或者提供的路径说明中的文件夹。 object.GetBaseName(path) 参数 object 必
GetAbsolutePathName 方法 从提供的指定路径中返回完整且含义明确的路径。 object.GetAbsolutePathName(pathspec) 参数 object
FolderExists 方法 如果指定的文件夹存在,则返回 True;否则返回 False。 object.FolderExists(folderspec) 参数 object 必选项
FileExists 方法 如果指定的文件存在返回 True;否则返回 False。 object.FileExists(filespec) 参数 object 必选项。应为 FileS
我是一名优秀的程序员,十分优秀!