本文整理汇总了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<RsRoot> maybeRoot = rsBuilder.setInputStream(inStream).build();
* </pre>
* <p>We can test what concrete class was unmarshalled by obtaining the QName:</p>
* <pre>
* Optional<QName> maybeQName = rsBuilder.getQName();
* </pre>
* <p>Or directly test one of two possibilities:</p>
* <pre>
* Optional<Sitemapindex> maybeSitemapindex = rsBuilder.getSitemapindex();
* Optional<Urlset> 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);
}