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


Java JAXBElement.getName方法代码示例

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


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

示例1: build

import javax.xml.bind.JAXBElement; //导入方法依赖的package包/类
/**
 * Build a class hierarchy from the input previously given with one of <code>set</code>-methods.
 * <p>Example usage:</p>
 * <pre>
 *   RsBuilder rsBuilder = new RsBuilder(new ResourceSyncContext());
 *   Optional&lt;RsRoot&gt; maybeRoot = rsBuilder.setInputStream(inStream).build();
 * </pre>
 * <p>We can test what concrete class was unmarshalled by obtaining the QName:</p>
 * <pre>
 *   Optional&lt;QName&gt; maybeQName = rsBuilder.getQName();
 * </pre>
 * <p>Or directly test one of two possibilities:</p>
 * <pre>
 *   Optional&lt;Sitemapindex&gt; maybeSitemapindex = rsBuilder.getSitemapindex();
 *   Optional&lt;Urlset&gt; maybeUrlset = rsBuilder.getUrlset();
 * </pre>
 *
 *
 * @return Optional of RsRoot
 * @throws JAXBException for invalid input
 */
@SuppressWarnings ("unchecked")
public Optional<RsRoot> build() throws JAXBException {
  latestQName = null;
  urlset = null;
  sitemapindex = null;

  JAXBElement<RsRoot> je = null;
  RsRoot rsRoot = null;
  Unmarshaller unmarshaller = rsContext.createUnmarshaller();
  if (file != null) {
    je = (JAXBElement<RsRoot>) unmarshaller.unmarshal(file);
    file = null;
  } else if (inputSource != null) {
    je = (JAXBElement<RsRoot>) unmarshaller.unmarshal(inputSource);
    inputSource = null;
  } else if (inputStream != null) {
    je = (JAXBElement<RsRoot>) unmarshaller.unmarshal(inputStream);
    inputStream = null;
  } else if (node != null) {
    je = (JAXBElement<RsRoot>) unmarshaller.unmarshal(node);
    node = null;
  } else if (reader != null) {
    je = (JAXBElement<RsRoot>) unmarshaller.unmarshal(reader);
    reader = null;
  } else if (source != null) {
    je = (JAXBElement<RsRoot>) unmarshaller.unmarshal(source);
    source = null;
  } else if (url != null) {
    je = (JAXBElement<RsRoot>) unmarshaller.unmarshal(url);
    url = null;
  } else if (xmlEventReader != null) {
    je = (JAXBElement<RsRoot>) unmarshaller.unmarshal(xmlEventReader);
    xmlEventReader = null;
  } else if (xmlStreamReader != null) {
    je = (JAXBElement<RsRoot>) unmarshaller.unmarshal(xmlStreamReader);
    xmlStreamReader = null;
  }

  if (je != null) {
    latestQName = je.getName();
    rsRoot = je.getValue();
    if (latestQName.equals(Urlset.QNAME)) {
      urlset = (Urlset) rsRoot;
    } else if (latestQName.equals(Sitemapindex.QNAME)) {
      sitemapindex = (Sitemapindex) rsRoot;
    }
  }
  return Optional.ofNullable(rsRoot);
}
 
开发者ID:EHRI,项目名称:rs-aggregator,代码行数:71,代码来源:RsBuilder.java


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