gpt4 book ai didi

org.opendaylight.controller.netconf.util.xml.XmlElement.getName()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-27 12:49:05 27 4
gpt4 key购买 nike

本文整理了Java中org.opendaylight.controller.netconf.util.xml.XmlElement.getName()方法的一些代码示例,展示了XmlElement.getName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlElement.getName()方法的具体详情如下:
包路径:org.opendaylight.controller.netconf.util.xml.XmlElement
类名称:XmlElement
方法名:getName

XmlElement.getName介绍

暂无

代码示例

代码示例来源:origin: org.opendaylight.controller/netconf-util

@Override
  public boolean apply(XmlElement xmlElement) {
    return xmlElement.getName().equals(childName);
  }
}));

代码示例来源:origin: org.opendaylight.controller/netconf-util

@Override
public String toString() {
  final StringBuilder sb = new StringBuilder("XmlElement{");
  sb.append("name='").append(getName()).append('\'');
  if (element.getNamespaceURI() != null) {
    try {
      sb.append(", namespace='").append(getNamespace()).append('\'');
    } catch (MissingNameSpaceException e) {
      LOG.trace("Missing namespace for element.");
    }
  }
  sb.append('}');
  return sb.toString();
}

代码示例来源:origin: org.opendaylight.controller/netconf-util

@Override
  public boolean apply(XmlElement xmlElement) {
    return xmlElement.getName().equals(childName);
  }
}));

代码示例来源:origin: org.opendaylight.controller/netconf-util

public OperationNameAndNamespace(final Document message) throws NetconfDocumentedException {
  XmlElement requestElement = null;
  requestElement = getRequestElementWithCheck(message);
  operationElement = requestElement.getOnlyChildElement();
  operationName = operationElement.getName();
  namespace = operationElement.getNamespace();
}

代码示例来源:origin: org.opendaylight.controller/netconf-util

@Override
  public boolean apply(XmlElement xmlElement) {
    return xmlElement.getName().equals(childName);
  }
}));

代码示例来源:origin: org.opendaylight.controller/netconf-util

private static boolean isHelloMessage(final Document document) {
    XmlElement element = XmlElement.fromDomElement(document.getDocumentElement());
    try {
      // accept even if hello has no namespace
      return element.getName().equals(HELLO_TAG) &&
          (!element.hasNamespace() || element.getNamespace().equals(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0));
    } catch (MissingNameSpaceException e) {
      // Cannot happen, since we check for hasNamespace
      throw new IllegalStateException(e);
    }
  }
}

代码示例来源:origin: org.opendaylight.controller/netconf-util

@Override
  public boolean apply(XmlElement xmlElement) {
    return xmlElement.getName().equals(childName);
  }
}));

代码示例来源:origin: org.opendaylight.controller/netconf-util

@Override
  public boolean apply(XmlElement xmlElement) {
    return xmlElement.getName().equals(childName);
  }
}));

代码示例来源:origin: org.opendaylight.controller/netconf-util

public void checkName(String expectedName) throws UnexpectedElementException {
  if (!getName().equals(expectedName)){
    throw new UnexpectedElementException(String.format("Expected %s xml element but was %s", expectedName,
        getName()),
        NetconfDocumentedException.ErrorType.application,
        NetconfDocumentedException.ErrorTag.operation_failed,
        NetconfDocumentedException.ErrorSeverity.error);
  }
}

代码示例来源:origin: org.opendaylight.controller/netconf-util

public static Document checkIsMessageOk(Document response) throws NetconfDocumentedException {
    XmlElement element = XmlElement.fromDomDocument(response);
    Preconditions.checkState(element.getName().equals(XmlNetconfConstants.RPC_REPLY_KEY));
    element = element.getOnlyChildElement();
    if (element.getName().equals(XmlNetconfConstants.OK)) {
      return response;
    }
    LOG.warn("Can not load last configuration. Operation failed.");
    throw new IllegalStateException("Can not load last configuration. Operation failed: "
        + XmlUtil.toString(response));
  }
}

代码示例来源:origin: org.opendaylight.controller/netconf-util

public String getTextContent() throws NetconfDocumentedException {
  NodeList childNodes = element.getChildNodes();
  if (childNodes.getLength() == 0) {
    return DEFAULT_NAMESPACE_PREFIX;
  }
  for(int i = 0; i < childNodes.getLength(); i++) {
    Node textChild = childNodes.item(i);
    if (textChild instanceof Text) {
      String content = textChild.getTextContent();
      return content.trim();
    }
  }
  throw new NetconfDocumentedException(getName() + " should contain text.",
      NetconfDocumentedException.ErrorType.application,
      NetconfDocumentedException.ErrorTag.invalid_value,
      NetconfDocumentedException.ErrorSeverity.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 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/mdsal-netconf-connector

private static Optional<Datastore> parseSource(final XmlElement xml) throws NetconfDocumentedException {
  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.controller/sal-netconf-connector

private static boolean isNotification(final NetconfMessage message) {
  final XmlElement xmle = XmlElement.fromDomDocument(message.getDocument());
  return XmlNetconfConstants.NOTIFICATION_ELEMENT_NAME.equals(xmle.getName()) ;
}

代码示例来源:origin: org.opendaylight.controller/mdsal-netconf-connector

private Datastore extractTargetParameter(final XmlElement operationElement) throws NetconfDocumentedException {
  final NodeList elementsByTagName = operationElement.getDomElement().getElementsByTagName(TARGET_KEY);
  // Direct lookup instead of using XmlElement class due to performance
  if (elementsByTagName.getLength() == 0) {
    throw new NetconfDocumentedException("Missing target element", ErrorType.rpc, ErrorTag.missing_attribute, ErrorSeverity.error);
  } else if (elementsByTagName.getLength() > 1) {
    throw new NetconfDocumentedException("Multiple target elements", ErrorType.rpc, ErrorTag.unknown_attribute, ErrorSeverity.error);
  } else {
    final XmlElement targetChildNode = XmlElement.fromDomElement((Element) elementsByTagName.item(0)).getOnlyChildElement();
    return Datastore.valueOf(targetChildNode.getName());
  }
}

代码示例来源:origin: org.opendaylight.controller/config-netconf-connector

static Datastore extractTargetParameter(final XmlElement operationElement) throws NetconfDocumentedException {
  final XmlElement targetChildNode;
  try {
    final XmlElement targetElement = operationElement.getOnlyChildElementWithSameNamespace(TARGET_KEY);
    targetChildNode = targetElement.getOnlyChildElementWithSameNamespace();
  } catch (final MissingNameSpaceException | UnexpectedNamespaceException e) {
    LOG.trace("Can't get only child element with same namespace", e);
    throw NetconfDocumentedException.wrap(e);
  }
  return Datastore.valueOf(targetChildNode.getName());
}

代码示例来源:origin: org.opendaylight.controller/mdsal-netconf-connector

static Datastore extractTargetParameter(final XmlElement operationElement) throws NetconfDocumentedException {
  final XmlElement targetChildNode;
  try {
    final XmlElement targetElement = operationElement.getOnlyChildElementWithSameNamespace(TARGET_KEY);
    targetChildNode = targetElement.getOnlyChildElementWithSameNamespace();
  } catch (final MissingNameSpaceException | UnexpectedNamespaceException e) {
    LOG.trace("Can't get only child element with same namespace", e);
    throw NetconfDocumentedException.wrap(e);
  }
  return Datastore.valueOf(targetChildNode.getName());
}

代码示例来源:origin: org.opendaylight.controller/config-netconf-connector

public static Datastore fromXml(XmlElement xml) throws UnexpectedNamespaceException, UnexpectedElementException, MissingNameSpaceException, NetconfDocumentedException {
  xml.checkName(GET_CONFIG);
  xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
  XmlElement sourceElement = xml.getOnlyChildElement(XmlNetconfConstants.SOURCE_KEY,
      XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
  XmlElement sourceNode = sourceElement.getOnlyChildElement();
  String sourceParsed = sourceNode.getName();
  LOG.debug("Setting source datastore to '{}'", sourceParsed);
  Datastore sourceDatastore = Datastore.valueOf(sourceParsed);
  // Filter option: ignore for now, TODO only load modules specified by the filter
  return sourceDatastore;
}

代码示例来源:origin: org.opendaylight.controller/config-netconf-connector

private void checkXml(XmlElement xml) throws NetconfDocumentedException {
  xml.checkName(VALIDATE);
  xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
  XmlElement sourceElement = xml.getOnlyChildElement(XmlNetconfConstants.SOURCE_KEY,
      XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
  XmlElement sourceChildNode = sourceElement.getOnlyChildElement();
  sourceChildNode.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
  String datastoreValue = sourceChildNode.getName();
  Datastore sourceDatastore = Datastore.valueOf(datastoreValue);
  if (sourceDatastore != Datastore.candidate){
    throw new NetconfDocumentedException( "Only " + Datastore.candidate
        + " is supported as source for " + VALIDATE + " but was " + datastoreValue,ErrorType.application,ErrorTag.data_missing,ErrorSeverity.error);
  }
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com