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