freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

xstream使用文檔-wenkub

2023-07-04 15:15:22 本頁面
 

【正文】 = writer。import 。這個(gè)就是核心所在,即將一個(gè)java對象轉(zhuǎn)成了xml。這兩句表示對于xml中的每個(gè)結(jié)點(diǎn),所映射的Java類。例如:XStream xstream = new XStream(new DomDriver())。 }} 運(yùn)行測試類,輸出結(jié)果如下: 代碼解析.XStream xstream = new XStream()。 String xml = (joe)。 (phonenumber, )。,代碼如下:package 。 } public String getNumber() { return number。 public PhoneNumber(int code, String number) { = code。 } public void setFax(PhoneNumber fax) { = fax。 } public void setLastname(String lastname) { = lastname。 = lastName。 private String lastname。 安裝XStream的安裝方法比較簡單。l 序列化/逆序列化類的字段不需要 getter 和 setter 方法。XStream使用文檔 作者:胡少鋒 Email:hsf2011年11月1 基本介紹 前言XStream 是一個(gè)輕量級的、簡單易用的開放源代碼 Java庫,用于將 Java 對象序列化為 XML 或者再轉(zhuǎn)換回來。l 序列化/逆序列化的類不需要有默認(rèn)構(gòu)造函數(shù)。如下圖所示:3 開始一個(gè)例子 新建一個(gè)空的java project工程通過eclipse向?qū)陆ㄒ粋€(gè)Java Project工程,并將上面提的兩個(gè)類添加到類路徑下。 private PhoneNumber phone。 } public String getFirstname() { return firstname。 } public PhoneNumber getPhone() { return phone。 }}package 。 = number。 } public void setNumber(String number) { = number。import 。 Person joe = new Person(Joe, Walnes)。 (xml)。直接實(shí)例化一個(gè)XStream對象,不用任何參數(shù)。 XStream xstream = new XStream(new StaxDriver())。也就是person結(jié)點(diǎn)映射到了Person類;而phonenumber則映射到了PhoneNumber類。繼續(xù)下面的代碼:Person newJoe = (Person)(xml)。import 。 } public void add(Entry entry) { (entry)。 public Author(String name) { = name。 private String description。public class Main { public static void main(String[] args) { Blog teamBlog = new Blog(new Author(Guilherme Silveira))。 ((teamBlog))。 (new Entry(tutorial, Today we have developed a nice alias tutorial. Tell your friends! NOW!))。 (entry, )。修改上述的main函數(shù),如下: public static void main(String[] args) { Blog teamBlog = new Blog(new Author(Guilherme Silveira))。 (blog, )。 ((teamBlog))。 (new Entry(tutorial, Today we have developed a nice alias tutorial. Tell your friends! NOW!))。 (entry, )。 }運(yùn)行上面函數(shù),輸出結(jié)果如下:blog author nameGuilherme Silveira/name /author entry titlefirst/title descriptionMy first blog entry./description /entry entry titletutorial/title descriptionToday we have developed a nice alias tutorial. Tell your friends! NOW!/description /entry/blog 對package進(jìn)行aliasXStream另外一個(gè)功能是對package進(jìn)行alias,雖然這個(gè)功能比較少用。 XStream xstream = new XStream()。 簡單介紹從上面的xml中看到,blog中有author子結(jié)點(diǎn),看起來比較啰嗦,可能我們想把a(bǔ)uthor子節(jié)點(diǎn)作為blog的屬性,如下:blog author=Guilherme Silveira那么就需要用到屬性轉(zhuǎn)換功能。 } public Object fromString(String name) { return new Author(name)。 (new Entry(first, My first blog entry.))。 (author, )。 (, writer)。 }}運(yùn)行上面,輸出如下:blog author=Guilherme Silveira entry titlefirst/title descriptionMy first blog entry./description /entry entry titletutorial/title descriptionToday we have developed a nice alias tutorial. Tell your friends! NOW!/description /entry/blog 對象轉(zhuǎn)換器ObjectConverter下面講解ObjectConverter實(shí)例。 } public void setName(String name) { = name。 (Guilherme)。 }}運(yùn)行以上主函數(shù),輸出結(jié)果如下:person nameGuilherme/name/person現(xiàn)在假如我們需要輸出如下的結(jié)果:person fullnameGuilherme/fullname/person那么最簡單的辦法就是使用aliasFiled方法,如下:package 。 XStream xStream = new XStream()。 }}但是,下面我們將通過ObjectConverter實(shí)現(xiàn)上面的功能。import 。 } public void marshal(Obj
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1