Source Code Cross Referenced for RSS10Feed.java in  » Wiki-Engine » JSPWiki » com » ecyrd » jspwiki » rss » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Wiki Engine » JSPWiki » com.ecyrd.jspwiki.rss 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:            JSPWiki - a JSP-based WikiWiki clone.
003:
004:            Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
005:
006:            This program is free software; you can redistribute it and/or modify
007:            it under the terms of the GNU Lesser General Public License as published by
008:            the Free Software Foundation; either version 2.1 of the License, or
009:            (at your option) any later version.
010:
011:            This program is distributed in the hope that it will be useful,
012:            but WITHOUT ANY WARRANTY; without even the implied warranty of
013:            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:            GNU Lesser General Public License for more details.
015:
016:            You should have received a copy of the GNU Lesser General Public License
017:            along with this program; if not, write to the Free Software
018:            Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:         */
020:        package com.ecyrd.jspwiki.rss;
021:
022:        import java.text.SimpleDateFormat;
023:        import java.util.Calendar;
024:        import java.util.Iterator;
025:
026:        import org.apache.ecs.xml.XML;
027:
028:        import com.ecyrd.jspwiki.WikiContext;
029:        import com.ecyrd.jspwiki.WikiEngine;
030:        import com.ecyrd.jspwiki.WikiPage;
031:
032:        /**
033:         *  @author jalkanen
034:         *
035:         *  @since 
036:         */
037:        public class RSS10Feed extends Feed {
038:            public RSS10Feed(WikiContext context) {
039:                super (context);
040:            }
041:
042:            private XML getRDFItems() {
043:                XML items = new XML("items");
044:
045:                XML rdfseq = new XML("rdf:Seq");
046:
047:                for (Iterator i = m_entries.iterator(); i.hasNext();) {
048:                    Entry e = (Entry) i.next();
049:
050:                    String url = e.getURL();
051:
052:                    rdfseq.addElement(new XML("rdf:li").addAttribute(
053:                            "rdf:resource", url));
054:                }
055:
056:                items.addElement(rdfseq);
057:
058:                return items;
059:            }
060:
061:            private void addItemList(XML root) {
062:                SimpleDateFormat iso8601fmt = new SimpleDateFormat(
063:                        "yyyy-MM-dd'T'HH:mm:ss'Z'");
064:
065:                WikiEngine engine = m_wikiContext.getEngine();
066:
067:                for (Iterator i = m_entries.iterator(); i.hasNext();) {
068:                    Entry e = (Entry) i.next();
069:
070:                    String url = e.getURL();
071:
072:                    XML item = new XML("item");
073:                    item.addAttribute("rdf:about", url);
074:
075:                    item.addElement(new XML("title").addElement(format(e
076:                            .getTitle())));
077:
078:                    item.addElement(new XML("link").addElement(url));
079:
080:                    XML content = new XML("description");
081:
082:                    // TODO: Add a size limiter here
083:                    content.addElement(format(e.getContent()));
084:
085:                    item.addElement(content);
086:
087:                    WikiPage p = e.getPage();
088:
089:                    if (p.getVersion() != -1) {
090:                        item.addElement(new XML("wiki:version")
091:                                .addElement(Integer.toString(p.getVersion())));
092:                    }
093:
094:                    if (p.getVersion() > 1) {
095:                        item.addElement(new XML("wiki:diff").addElement(engine
096:                                .getURL(WikiContext.DIFF, p.getName(), "r1=-1",
097:                                        true)));
098:                    }
099:
100:                    //
101:                    //  Modification date.
102:                    //
103:                    Calendar cal = Calendar.getInstance();
104:                    cal.setTime(p.getLastModified());
105:                    cal.add(Calendar.MILLISECOND, -(cal
106:                            .get(Calendar.ZONE_OFFSET) + (cal.getTimeZone()
107:                            .inDaylightTime(p.getLastModified()) ? cal
108:                            .get(Calendar.DST_OFFSET) : 0)));
109:
110:                    item.addElement(new XML("dc:date").addElement(iso8601fmt
111:                            .format(cal.getTime())));
112:
113:                    //
114:                    //  Author
115:                    String author = e.getAuthor();
116:                    if (author == null)
117:                        author = "unknown";
118:
119:                    XML contributor = new XML("dc:creator");
120:
121:                    item.addElement(contributor);
122:
123:                    /*
124:                    XML description = new XML("rdf:Description");
125:                    if( m_wikiContext.getEngine().pageExists(author) )
126:                    {
127:                        description.addAttribute( "link", engine.getURL( WikiContext.VIEW, 
128:                                                                         author,
129:                                                                         null,
130:                                                                         true ) );
131:                    }
132:                    
133:                    description.addElement( new XML("value").addElement( format(author) ) );
134:                    contributor.addElement( description );
135:                     */
136:
137:                    // Not too many aggregators seem to like this.  Therefore we're
138:                    // just adding the name here.
139:                    contributor.addElement(format(author));
140:
141:                    //  PageHistory
142:
143:                    item
144:                            .addElement(new XML("wiki:history")
145:                                    .addElement(engine.getURL(WikiContext.INFO,
146:                                            p.getName(), null, true)));
147:
148:                    //
149:                    //  Add to root
150:                    //
151:
152:                    root.addElement(item);
153:                }
154:            }
155:
156:            private XML getChannelElement() {
157:                XML channel = new XML("channel");
158:
159:                channel.addAttribute("rdf:about", m_feedURL);
160:
161:                channel.addElement(new XML("link").addElement(m_feedURL));
162:
163:                if (m_channelTitle != null)
164:                    channel.addElement(new XML("title")
165:                            .addElement(format(m_channelTitle)));
166:
167:                if (m_channelDescription != null)
168:                    channel.addElement(new XML("description")
169:                            .addElement(format(m_channelDescription)));
170:
171:                if (m_channelLanguage != null)
172:                    channel.addElement(new XML("dc:language")
173:                            .addElement(m_channelLanguage));
174:
175:                channel.setPrettyPrint(true);
176:
177:                channel.addElement(getRDFItems());
178:
179:                return channel;
180:            }
181:
182:            /* (non-Javadoc)
183:             * @see com.ecyrd.jspwiki.rss.Feed#getString()
184:             */
185:            public String getString() {
186:                XML root = new XML("rdf:RDF");
187:
188:                root.addAttribute("xmlns:rdf",
189:                        "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
190:                root.addAttribute("xmlns", "http://purl.org/rss/1.0/");
191:                root.addAttribute("xmlns:dc",
192:                        "http://purl.org/dc/elements/1.1/");
193:                root.addAttribute("xmlns:wiki",
194:                        "http://purl.org/rss/1.0/modules/wiki/");
195:
196:                root.addElement(getChannelElement());
197:
198:                addItemList(root);
199:
200:                root.setPrettyPrint(true);
201:
202:                return root.toString();
203:            }
204:
205:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.