国产gaysexchina男同gay,japanrcep老熟妇乱子伦视频,吃奶呻吟打开双腿做受动态图,成人色网站,国产av一区二区三区最新精品

FRAGMENT

2018-12-31 21:01 更新

Marshaller.JAXB_FRAGMENT

JAXB_FRAGMENT是一個(gè)多面手,在不同的輸出場(chǎng)景下,表現(xiàn)出不同的效果。

    @Test
    public void test5_1() throws JAXBException {
        Marshaller marshaller = context.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
        marshaller.marshal(one, System.out);
    }

在這里指定JAXB_FRAGMENT=true,表明結(jié)果不再聲明XML頭信息,得到的結(jié)果:



<one>
    <name>Test one</name>
</one>

可以看到,第一行的XML聲明不見了。

如果使用到了SAX方式(見下一小節(jié)),可以發(fā)現(xiàn)如下不同:

    @Test
    public void test5_2() throws JAXBException {
        Marshaller marshaller = context.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
//      marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
        marshaller.marshal(one, new MyContentHandler());
    }

輸出結(jié)果:

startDocument
endDocument

如果將注釋的一行代碼放開,再次運(yùn)行程序?qū)⒉荒艿玫饺魏屋敵觥?code>JAXB_FRAGMENT的默認(rèn)值為false,在其他場(chǎng)景下也有不同的表現(xiàn)。

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)