root/as3/Syndication/trunk/src/org/libspark/syndication/RSSFeedEntry.as

リビジョン 985, 2.9 kB (コミッタ: nobu, コミット時期: 4 年 前)

Syndication: refs #52 #53

  • コメントを追記。
  • テストを追加。
Line 
1 /**
2  * ActionScript Syndication Library
3  *
4  * Copyright (c) 2008 Takanobu Izukawa (humming.via-kitchen.com) and
5  *                    Spark project    (www.libspark.org)
6  *
7  * Dual licensed under the MIT (MIT-LICENSE.txt)
8  * and GPL (GPL-LICENSE.txt) licenses.
9  *
10  */
11 package org.libspark.syndication
12 {
13     import org.libspark.syndication.namespaces.rss;
14     import org.libspark.syndication.namespaces.rdf;
15     import org.libspark.syndication.namespaces.dc;
16     import org.libspark.syndication.namespaces.content;
17     import org.libspark.syndication.utils.DateUtil;
18
19     use namespace rss;
20     use namespace rdf;
21     use namespace dc;
22     use namespace content;
23
24     /**
25      *  IFeedEntry インターフェイスの実装クラスで RSS 1.0 に対応した実装を提供します。
26      */
27     public class RSSFeedEntry implements IFeedEntry
28     {
29         /**
30          *  エントリーのデータを保持します。
31          */
32         private var _data:XML;
33
34         /**
35          *  @inheritDoc
36          */
37         public function get author():String
38         {
39             return _data.dc::creator.toString();
40         }
41
42         /**
43          *  @inheritDoc
44          */
45         public function get title():String
46         {
47             return _data.title.toString();
48         }
49
50         /**
51          *  @inheritDoc
52          */
53         public function get link():String
54         {
55             return _data.link.toString();
56         }
57
58         /**
59          *  @inheritDoc
60          */
61         public function get description():String
62         {
63             return _data.content::encoded.toString();
64         }
65
66         /**
67          *  公開日の情報を保持します。
68          */
69         private var _published:Date;
70
71         /**
72          *  @inheritDoc
73          */
74         public function get published():Date
75         {
76             if (_published == null && !!_data.dc::date.toString())
77             {
78                 _published = DateUtil.parseW3C(_data.dc::date.toString());
79             }
80             return _published;
81         }
82        
83         /**
84          *  カテゴリーの情報を保持します。
85          */
86         private var _categories:Array;
87        
88         /**
89          *  @inheritDoc
90          */
91         public function get categories():Array
92         {
93             if (_categories == null)
94             {
95                 _categories = [];
96                 for each (var nodeData:XML in _data.dc::subject)
97                 {
98                     _categories.push(nodeData.toString());
99                 }
100             }
101             return _categories;
102         }
103
104         /**
105          *  新しい RSSFeedEntry クラスのインスタンスを作成します。
106          *
107          *  @param data             RSS 1.0 エントリーの XML
108          */
109         public function RSSFeedEntry(data:XML)
110         {
111             _data = data;
112         }
113
114         /**
115          *  @inheritDoc
116          */
117         public function toString():String
118         {
119             return title;
120         }
121     }
122 }
123
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。