当前位置: 首页>>代码示例>>Java>>正文


Java XmlElement.name方法代码示例

本文整理汇总了Java中javax.xml.bind.annotation.XmlElement.name方法的典型用法代码示例。如果您正苦于以下问题:Java XmlElement.name方法的具体用法?Java XmlElement.name怎么用?Java XmlElement.name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.bind.annotation.XmlElement的用法示例。


在下文中一共展示了XmlElement.name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dealXmlElementAnnotation

import javax.xml.bind.annotation.XmlElement; //导入方法依赖的package包/类
/**
 * 处理@{@link XmlElement}注解
 */
@SuppressWarnings("unchecked")
protected void dealXmlElementAnnotation(Element rootElement, Field field, Object entity) {
  XmlElement xmlElementAnnotation = field.getAnnotation(XmlElement.class);
  Element element = rootElement.element(xmlElementAnnotation.name());
  if (Objects.nonNull(element)) {
    Optional<Object> valueOptional = super
        .elementValue(rootElement, field.getType(), xmlElementAnnotation.name());
    valueOptional.ifPresent(value -> {
      try {
        field.set(entity, value);
      } catch (IllegalAccessException e) {
        e.printStackTrace();
      }
    });
  }
}
 
开发者ID:minlia-projects,项目名称:minlia-iot,代码行数:20,代码来源:XmlApiDeserializer.java

示例2: getReturnQName

import javax.xml.bind.annotation.XmlElement; //导入方法依赖的package包/类
private static QName getReturnQName(Method method, WebResult webResult, XmlElement xmlElem) {
    String webResultName = null;
    if (webResult != null && webResult.name().length() > 0) {
        webResultName = webResult.name();
    }
    String xmlElemName = null;
    if (xmlElem != null && !xmlElem.name().equals("##default")) {
        xmlElemName = xmlElem.name();
    }
    if (xmlElemName != null && webResultName != null && !xmlElemName.equals(webResultName)) {
        throw new RuntimeModelerException("@XmlElement(name)="+xmlElemName+" and @WebResult(name)="+webResultName+" are different for method " +method);
    }
    String localPart = RETURN;
    if (webResultName != null) {
        localPart = webResultName;
    } else if (xmlElemName != null) {
        localPart =  xmlElemName;
    }

    String webResultNS = null;
    if (webResult != null && webResult.targetNamespace().length() > 0) {
        webResultNS = webResult.targetNamespace();
    }
    String xmlElemNS = null;
    if (xmlElem != null && !xmlElem.namespace().equals("##default")) {
        xmlElemNS = xmlElem.namespace();
    }
    if (xmlElemNS != null && webResultNS != null && !xmlElemNS.equals(webResultNS)) {
        throw new RuntimeModelerException("@XmlElement(namespace)="+xmlElemNS+" and @WebResult(targetNamespace)="+webResultNS+" are different for method " +method);
    }
    String ns = "";
    if (webResultNS != null) {
        ns = webResultNS;
    } else if (xmlElemNS != null) {
        ns =  xmlElemNS;
    }

    return new QName(ns, localPart);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:40,代码来源:RuntimeModeler.java

示例3: getParameterQName

import javax.xml.bind.annotation.XmlElement; //导入方法依赖的package包/类
private static QName getParameterQName(Method method, WebParam webParam, XmlElement xmlElem, String paramDefault) {
    String webParamName = null;
    if (webParam != null && webParam.name().length() > 0) {
        webParamName = webParam.name();
    }
    String xmlElemName = null;
    if (xmlElem != null && !xmlElem.name().equals("##default")) {
        xmlElemName = xmlElem.name();
    }
    if (xmlElemName != null && webParamName != null && !xmlElemName.equals(webParamName)) {
        throw new RuntimeModelerException("@XmlElement(name)="+xmlElemName+" and @WebParam(name)="+webParamName+" are different for method " +method);
    }
    String localPart = paramDefault;
    if (webParamName != null) {
        localPart = webParamName;
    } else if (xmlElemName != null) {
        localPart =  xmlElemName;
    }

    String webParamNS = null;
    if (webParam != null && webParam.targetNamespace().length() > 0) {
        webParamNS = webParam.targetNamespace();
    }
    String xmlElemNS = null;
    if (xmlElem != null && !xmlElem.namespace().equals("##default")) {
        xmlElemNS = xmlElem.namespace();
    }
    if (xmlElemNS != null && webParamNS != null && !xmlElemNS.equals(webParamNS)) {
        throw new RuntimeModelerException("@XmlElement(namespace)="+xmlElemNS+" and @WebParam(targetNamespace)="+webParamNS+" are different for method " +method);
    }
    String ns = "";
    if (webParamNS != null) {
        ns = webParamNS;
    } else if (xmlElemNS != null) {
        ns =  xmlElemNS;
    }

    return new QName(ns, localPart);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:40,代码来源:RuntimeModeler.java


注:本文中的javax.xml.bind.annotation.XmlElement.name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。