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

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

Syndication:

  • Atom 0.3 に対応。
  • 細かい修正。
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.atom;
14     import org.libspark.syndication.utils.DateUtil;
15
16     use namespace atom;
17
18     /**
19      *  IFeedEntry インターフェイスの実装クラスで Atom に対応した実装を提供します。
20      */
21     public class AtomFeedEntry implements IFeedEntry
22     {
23         /**
24          *  エントリーのデータを保持します。
25          */
26         private var _data:XML;
27
28         /**
29          *  @inheritDoc
30          */
31         public function get author():String
32         {
33             return _data.author.name.toString();
34         }
35
36         /**
37          *  @inheritDoc
38          */
39         public function get title():String
40         {
41             return _data.title.toString();
42         }
43
44         /**
45          *  @inheritDoc
46          */
47         public function get link():String
48         {
49             return _data.link.(@type.match(/^text\/html$/)).@href.toString();
50         }
51
52         /**
53          *  @inheritDoc
54          */
55         public function get description():String
56         {
57             return _data.content.toString();
58         }
59
60         /**
61          *  公開日の情報を保持します。
62          */
63         private var _published:Date;
64
65         /**
66          *  @inheritDoc
67          */
68         public function get published():Date
69         {
70             if (_published == null && !!_data.published.toString())
71             {
72                 _published = DateUtil.parseW3C(_data.published.toString());
73             }
74             return _published;
75         }
76        
77         /**
78          *  カテゴリーの情報を保持します。
79          */
80         private var _categories:Array;
81        
82         /**
83          *  @inheritDoc
84          */
85         public function get categories():Array
86         {
87             if (_categories == null)
88             {
89                 _categories = [];
90                 for each (var nodeData:XML in _data.category)
91                 {
92                     _categories.push(nodeData.@term.toString());
93                 }
94             }
95             return _categories;
96         }
97        
98         /**
99          *  新しい AtomFeedEntry クラスのインスタンスを作成します。
100          *
101          *  @param data             Atom エントリーの XML
102          */
103         public function AtomFeedEntry(data:XML)
104         {
105             _data = data;
106         }
107
108         /**
109          *  @inheritDoc
110          */
111         public function toString():String
112         {
113             return title;
114         }
115     }
116 }
117
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。