gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-21 02:51:05 24 4
gpt4 key购买 nike

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

XmlElement.getName介绍

暂无

代码示例

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

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

代码示例来源:origin: org.opendaylight.controller/config-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/config-util

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

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

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

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

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

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

/**
 * Validates filter content against this validator schema context. If the filter is valid, method returns {@link YangInstanceIdentifier}
 * of node which can be used as root for data selection.
 * @param filterContent filter content
 * @return YangInstanceIdentifier
 * @throws DocumentedException if filter content is not valid
 */
public YangInstanceIdentifier validate(XmlElement filterContent) throws DocumentedException {
  try {
    final URI namespace = new URI(filterContent.getNamespace());
    final Module module = schemaContext.getCurrentContext().findModuleByNamespaceAndRevision(namespace, null);
    final DataSchemaNode schema = getRootDataSchemaNode(module, namespace, filterContent.getName());
    final FilterTree filterTree = validateNode(filterContent, schema, new FilterTree(schema.getQName(), Type.OTHER));
    return getFilterDataRoot(filterTree, YangInstanceIdentifier.builder());
  } catch (DocumentedException e) {
    throw e;
  } catch (Exception e) {
    throw new DocumentedException("Validation failed. Cause: " + e.getMessage(),
        DocumentedException.ErrorType.application,
        DocumentedException.ErrorTag.unknown_namespace,
        DocumentedException.ErrorSeverity.error);
  }
}

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

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

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

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

代码示例来源:origin: org.opendaylight.controller/config-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()),
        DocumentedException.ErrorType.application,
        DocumentedException.ErrorTag.operation_failed,
        DocumentedException.ErrorSeverity.error);
  }
}

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

public static Document checkIsMessageOk(Document response) throws DocumentedException {
  XmlElement element = XmlElement.fromDomDocument(response);
  Preconditions.checkState(element.getName().equals(XmlMappingConstants.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/config-util

public String getTextContent() throws DocumentedException {
  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 DocumentedException(getName() + " should contain text.",
      DocumentedException.ErrorType.application,
      DocumentedException.ErrorTag.invalid_value,
      DocumentedException.ErrorSeverity.error
  );
}

代码示例来源: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 boolean isOKMessage(XmlElement xmlElement) throws NetconfDocumentedException {
  if(xmlElement.getChildElements().size() != 1) {
    return false;
  }
  try {
    return xmlElement.getOnlyChildElement().getName().equals(XmlNetconfConstants.OK);
  } catch (DocumentedException e) {
    throw new NetconfDocumentedException(e);
  }
}

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

public static boolean isErrorMessage(XmlElement xmlElement) throws NetconfDocumentedException {
  if(xmlElement.getChildElements().size() != 1) {
    return false;
  }
  try {
    return xmlElement.getOnlyChildElement().getName().equals(DocumentedException.RPC_ERROR);
  } catch (DocumentedException e) {
    throw new NetconfDocumentedException(e);
  }
}

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

private Datastore extractTargetParameter(final XmlElement operationElement) throws DocumentedException {
  final NodeList elementsByTagName = operationElement.getDomElement().getElementsByTagName(TARGET_KEY);
  // Direct lookup instead of using XmlElement class due to performance
  if (elementsByTagName.getLength() == 0) {
    throw new DocumentedException("Missing target element", ErrorType.rpc, ErrorTag.missing_attribute, ErrorSeverity.error);
  } else if (elementsByTagName.getLength() > 1) {
    throw new DocumentedException("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.netconf/mdsal-netconf-connector

static Datastore extractTargetParameter(final XmlElement operationElement) throws DocumentedException {
  final XmlElement targetElement = operationElement.getOnlyChildElementWithSameNamespace(TARGET_KEY);
  final XmlElement targetChildNode = targetElement.getOnlyChildElementWithSameNamespace();
  return Datastore.valueOf(targetChildNode.getName());
}

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

static Datastore extractTargetParameter(final XmlElement operationElement) throws DocumentedException {
  final XmlElement targetElement = operationElement.getOnlyChildElementWithSameNamespace(TARGET_KEY);
  final XmlElement targetChildNode = targetElement.getOnlyChildElementWithSameNamespace();
  return Datastore.valueOf(targetChildNode.getName());
}

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

public static Datastore fromXml(XmlElement xml) throws DocumentedException {
  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.netconf/mdsal-netconf-connector

private Optional<DataSchemaNode> getSchemaNodeFromNamespace(final String namespace, final XmlElement element) throws DocumentedException{
  Optional<DataSchemaNode> dataSchemaNode = Optional.absent();
  try {
    //returns module with newest revision since findModuleByNamespace returns a set of modules and we only need the newest one
    final Module module = schemaContext.getCurrentContext().findModuleByNamespaceAndRevision(new URI(namespace), null);
    if (module == null) {
      // no module is present with this namespace
      throw new NetconfDocumentedException("Unable to find module by namespace: " + namespace,
          ErrorType.application, ErrorTag.unknown_namespace, ErrorSeverity.error);
    }
    DataSchemaNode schemaNode =
        module.getDataChildByName(QName.create(module.getQNameModule(), element.getName()));
    if (schemaNode != null) {
      dataSchemaNode = Optional.of(schemaNode);
    } else {
      throw new DocumentedException("Unable to find node with namespace: " + namespace + "in module: " + module.toString(),
          ErrorType.application,
          ErrorTag.unknown_namespace,
          ErrorSeverity.error);
    }
  } catch (URISyntaxException e) {
    LOG.debug("Unable to create URI for namespace : {}", namespace);
  }
  return dataSchemaNode;
}

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

private void checkXml(XmlElement xml) throws DocumentedException {
  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 DocumentedException( "Only " + Datastore.candidate
        + " is supported as source for " + VALIDATE + " but was " + datastoreValue, ErrorType.application, ErrorTag.data_missing, ErrorSeverity.error);
  }
}

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