日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢(xún)
選擇下列產(chǎn)品馬上在線(xiàn)溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
AndroidXML讀寫(xiě)(三)

消息基本上是相當(dāng)直觀(guān)的。通過(guò)允許日期和鏈接作為簡(jiǎn)單的對(duì)象被訪(fǎng)問(wèn),同時(shí)將它們表示為較強(qiáng)類(lèi)型的對(duì)象(de >java.util.Datede > 和 de >java.net.URLde >),它隱藏了一些內(nèi)部狀態(tài)。它是一個(gè)典型的 Value Object,因此它基于其內(nèi)部狀態(tài)實(shí)現(xiàn)了 de >equals()de > 和 de >hashCode()de >。它還實(shí)現(xiàn)了 de >Comparablede > 接口,因此您可以使用它進(jìn)行排序(按日期)。在實(shí)踐中,提要中的數(shù)據(jù)始終是有序的,因?yàn)闆](méi)有必要再進(jìn)行排序。

我們提供的服務(wù)有:成都網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、微信公眾號(hào)開(kāi)發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、磴口ssl等。為超過(guò)千家企事業(yè)單位解決了網(wǎng)站和推廣的問(wèn)題。提供周到的售前咨詢(xún)和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的磴口網(wǎng)站制作公司

每個(gè)解析器實(shí)現(xiàn)都需要提供一個(gè) URL 給 Androidster 提要,并使用它打開(kāi)一個(gè)到 Androidster 站點(diǎn)的 HTTP 連接。這一常見(jiàn)行為自然是在 Java 代碼中建模,我們使用了一個(gè)抽象基類(lèi),所示。

基本提要解析器類(lèi)

java代碼:

 
 
  1. public abstract class BaseFeedParser implements FeedParser { 
  2. // names of the XML tags 
  3. static final String PUB_DATE = "pubDate"; 
  4. static final String DESCRIPTION = "description"; 
  5. static final String LINK = "link"; 
  6. static final String TITLE = "title"; 
  7. static final String ITEM = "item"; 
  8. final URL feedUrl; 
  9. protected BaseFeedParser(String feedUrl){ 
  10. try { 
  11. this.feedUrl = new URL(feedUrl); 
  12. } catch (MalformedURLException e) { 
  13. throw new RuntimeException(e); 
  14. protected InputStream getInputStream() { 
  15. try { 
  16. return feedUrl.openConnection().getInputStream(); 
  17. } catch (IOException e) { 
  18. throw new RuntimeException(e); 

基類(lèi)存儲(chǔ) de >feedUrlde > 并使用它打開(kāi)了一個(gè) de >java.io.InputStreamde >。如果出現(xiàn)任何差錯(cuò),它會(huì)拋出一個(gè) de >RuntimeExceptionde >,造成應(yīng)用程序出現(xiàn)故障?;?lèi)還為標(biāo)記的名稱(chēng)定義了一些簡(jiǎn)單的常量。顯示了提要中的一些示例內(nèi)容,以便于您理解這些標(biāo)記的重要性。

示例 XML 提要

java代碼:

 
 
  1. < ?xml version="1.0" encoding="UTF-8"? > 
  2. < !-- generator="FeedCreator 1.7.2" -- > 
  3. < rss version="2.0" > 
  4. < channel > 
  5. < title >android_news< /title > 
  6. < description >android_news< /description > 
  7. < link >< /link > 
  8. < lastBuildDate >Sun, 19 Apr 2009 19:43:45 +0100< /lastBuildDate > 
  9. < generator >FeedCreator 1.7.2< /generator > 
  10. < item > 
  11. < title >Samsung S8000 to Run Android, Play DivX, Take Over the World< /title > 
  12. < link >< /link > 
  13. < description >More details have emerged on the first Samsung handset 
  14. to run Android. A yet-to-be announced phone called the S8000 is being 
  15. reported ...< /description > 
  16. < pubDate >Thu, 16 Apr 2009 07:18:51 +0100< /pubDate > 
  17. < /item > 
  18. < item > 
  19. < title >Android Cupcake Update on the Horizon< /title > 
  20. < link >< /link > 
  21. < description >After months of discovery and hearsay, the Android 
  22. build that we have all been waiting for is about to finally make it 
  23. out ...< /description > 
  24. < pubDate >Tue, 14 Apr 2009 04:13:21 +0100< /pubDate > 
  25. < /item > 
  26. < /channel > 
  27. < /rss >

分享題目:AndroidXML讀寫(xiě)(三)
分享鏈接:http://www.5511xx.com/article/djiispi.html