Source Code Cross Referenced for Channel.java in  » Library » Apache-commons-betwixt-0.8-src » org » apache » commons » digester » 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 » Library » Apache commons betwixt 0.8 src » org.apache.commons.digester.rss 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        package org.apache.commons.digester.rss;
019:
020:        import java.io.OutputStream;
021:        import java.io.OutputStreamWriter;
022:        import java.io.PrintWriter;
023:        import java.io.Serializable;
024:        import java.io.UnsupportedEncodingException;
025:        import java.io.Writer;
026:        import java.util.ArrayList;
027:
028:        /**
029:         * <p>Implementation object representing a <strong>channel</strong> in the
030:         * <em>Rich Site Summary</em> DTD, version 0.91.  This class may be subclassed
031:         * to further specialize its behavior.</p>
032:         */
033:
034:        public class Channel implements  Serializable {
035:
036:            // ----------------------------------------------------- Instance Variables
037:
038:            /**
039:             * The set of items associated with this Channel.
040:             */
041:            protected ArrayList items = new ArrayList();
042:
043:            /**
044:             * The set of skip days for this channel.
045:             */
046:            protected ArrayList skipDays = new ArrayList();
047:
048:            /**
049:             * The set of skip hours for this channel.
050:             */
051:            protected ArrayList skipHours = new ArrayList();
052:
053:            // ------------------------------------------------------------- Properties
054:
055:            /**
056:             * The channel copyright (1-100 characters).
057:             */
058:            protected String copyright = null;
059:
060:            public String getCopyright() {
061:                return (this .copyright);
062:            }
063:
064:            public void setCopyright(String copyright) {
065:                this .copyright = copyright;
066:            }
067:
068:            /**
069:             * The channel description (1-500 characters).
070:             */
071:            protected String description = null;
072:
073:            public String getDescription() {
074:                return (this .description);
075:            }
076:
077:            public void setDescription(String description) {
078:                this .description = description;
079:            }
080:
081:            /**
082:             * The channel description file URL (1-500 characters).
083:             */
084:            protected String docs = null;
085:
086:            public String getDocs() {
087:                return (this .docs);
088:            }
089:
090:            public void setDocs(String docs) {
091:                this .docs = docs;
092:            }
093:
094:            /**
095:             * The image describing this channel.
096:             */
097:            protected Image image = null;
098:
099:            public Image getImage() {
100:                return (this .image);
101:            }
102:
103:            public void setImage(Image image) {
104:                this .image = image;
105:            }
106:
107:            /**
108:             * The channel language (2-5 characters).
109:             */
110:            protected String language = null;
111:
112:            public String getLanguage() {
113:                return (this .language);
114:            }
115:
116:            public void setLanguage(String language) {
117:                this .language = language;
118:            }
119:
120:            /**
121:             * The channel last build date (1-100 characters).
122:             */
123:            protected String lastBuildDate = null;
124:
125:            public String getLastBuildDate() {
126:                return (this .lastBuildDate);
127:            }
128:
129:            public void setLastBuildDate(String lastBuildDate) {
130:                this .lastBuildDate = lastBuildDate;
131:            }
132:
133:            /**
134:             * The channel link (1-500 characters).
135:             */
136:            protected String link = null;
137:
138:            public String getLink() {
139:                return (this .link);
140:            }
141:
142:            public void setLink(String link) {
143:                this .link = link;
144:            }
145:
146:            /**
147:             * The managing editor (1-100 characters).
148:             */
149:            protected String managingEditor = null;
150:
151:            public String getManagingEditor() {
152:                return (this .managingEditor);
153:            }
154:
155:            public void setManagingEditor(String managingEditor) {
156:                this .managingEditor = managingEditor;
157:            }
158:
159:            /**
160:             * The channel publication date (1-100 characters).
161:             */
162:            protected String pubDate = null;
163:
164:            public String getPubDate() {
165:                return (this .pubDate);
166:            }
167:
168:            public void setPubDate(String pubDate) {
169:                this .pubDate = pubDate;
170:            }
171:
172:            /**
173:             * The channel rating (20-500 characters).
174:             */
175:            protected String rating = null;
176:
177:            public String getRating() {
178:                return (this .rating);
179:            }
180:
181:            public void setRating(String rating) {
182:                this .rating = rating;
183:            }
184:
185:            /**
186:             * The text input description for this channel.
187:             */
188:            protected TextInput textInput = null;
189:
190:            public TextInput getTextInput() {
191:                return (this .textInput);
192:            }
193:
194:            public void setTextInput(TextInput textInput) {
195:                this .textInput = textInput;
196:            }
197:
198:            /**
199:             * The channel title (1-100 characters).
200:             */
201:            protected String title = null;
202:
203:            public String getTitle() {
204:                return (this .title);
205:            }
206:
207:            public void setTitle(String title) {
208:                this .title = title;
209:            }
210:
211:            /**
212:             * The RSS specification version number used to create this Channel.
213:             */
214:            protected double version = 0.91;
215:
216:            public double getVersion() {
217:                return (this .version);
218:            }
219:
220:            public void setVersion(double version) {
221:                this .version = version;
222:            }
223:
224:            /**
225:             * The webmaster email address (1-100 characters).
226:             */
227:            protected String webMaster = null;
228:
229:            public String getWebMaster() {
230:                return (this .webMaster);
231:            }
232:
233:            public void setWebMaster(String webMaster) {
234:                this .webMaster = webMaster;
235:            }
236:
237:            // --------------------------------------------------------- Public Methods
238:
239:            /**
240:             * Add an additional item.
241:             *
242:             * @param item The item to be added
243:             */
244:            public void addItem(Item item) {
245:                synchronized (items) {
246:                    items.add(item);
247:                }
248:            }
249:
250:            /**
251:             * Add an additional skip day name.
252:             *
253:             * @param skipDay The skip day to be added
254:             */
255:            public void addSkipDay(String skipDay) {
256:                synchronized (skipDays) {
257:                    skipDays.add(skipDay);
258:                }
259:            }
260:
261:            /**
262:             * Add an additional skip hour name.
263:             *
264:             * @param skipHour The skip hour to be added
265:             */
266:            public void addSkipHour(String skipHour) {
267:                synchronized (skipHours) {
268:                    skipHours.add(skipHour);
269:                }
270:            }
271:
272:            /**
273:             * Return the items for this channel.
274:             */
275:            public Item[] findItems() {
276:                synchronized (items) {
277:                    Item items[] = new Item[this .items.size()];
278:                    return ((Item[]) this .items.toArray(items));
279:                }
280:            }
281:
282:            /**
283:             * Return the items for this channel.
284:             */
285:            public Item[] getItems() {
286:                return findItems();
287:            }
288:
289:            /**
290:             * Return the skip days for this channel.
291:             */
292:            public String[] findSkipDays() {
293:                synchronized (skipDays) {
294:                    String skipDays[] = new String[this .skipDays.size()];
295:                    return ((String[]) this .skipDays.toArray(skipDays));
296:                }
297:            }
298:
299:            /**
300:             * Return the skip hours for this channel.
301:             */
302:            public String[] getSkipHours() {
303:                return findSkipHours();
304:            }
305:
306:            /**
307:             * Return the skip hours for this channel.
308:             */
309:            public String[] findSkipHours() {
310:                synchronized (skipHours) {
311:                    String skipHours[] = new String[this .skipHours.size()];
312:                    return ((String[]) this .skipHours.toArray(skipHours));
313:                }
314:            }
315:
316:            /**
317:             * Return the skip days for this channel.
318:             */
319:            public String[] getSkipDays() {
320:                return findSkipDays();
321:            }
322:
323:            /**
324:             * Remove an item for this channel.
325:             *
326:             * @param item The item to be removed
327:             */
328:            public void removeItem(Item item) {
329:                synchronized (items) {
330:                    items.remove(item);
331:                }
332:            }
333:
334:            /**
335:             * Remove a skip day for this channel.
336:             *
337:             * @param skipDay The skip day to be removed
338:             */
339:            public void removeSkipDay(String skipDay) {
340:                synchronized (skipDays) {
341:                    skipDays.remove(skipDay);
342:                }
343:            }
344:
345:            /**
346:             * Remove a skip hour for this channel.
347:             *
348:             * @param skipHour The skip hour to be removed
349:             */
350:            public void removeSkipHour(String skipHour) {
351:                synchronized (skipHours) {
352:                    skipHours.remove(skipHour);
353:                }
354:            }
355:
356:            /**
357:             * Render this channel as XML conforming to the RSS 0.91 specification,
358:             * to the specified output stream, with no indication of character
359:             * encoding.
360:             *
361:             * @param stream The output stream to write to
362:             */
363:            public void render(OutputStream stream) {
364:
365:                try {
366:                    render(stream, null);
367:                } catch (UnsupportedEncodingException e) {
368:                    ; // Can not happen
369:                }
370:
371:            }
372:
373:            /**
374:             * Render this channel as XML conforming to the RSS 0.91 specification,
375:             * to the specified output stream, with the specified character encoding.
376:             *
377:             * @param stream The output stream to write to
378:             * @param encoding The character encoding to declare, or <code>null</code>
379:             *  for no declaration
380:             *
381:             * @exception UnsupportedEncodingException if the named encoding
382:             *  is not supported
383:             */
384:            public void render(OutputStream stream, String encoding)
385:                    throws UnsupportedEncodingException {
386:
387:                PrintWriter pw = null;
388:                if (encoding == null) {
389:                    pw = new PrintWriter(stream);
390:                } else {
391:                    pw = new PrintWriter(new OutputStreamWriter(stream,
392:                            encoding));
393:                }
394:                render(pw, encoding);
395:                pw.flush();
396:
397:            }
398:
399:            /**
400:             * Render this channel as XML conforming to the RSS 0.91 specification,
401:             * to the specified writer, with no indication of character encoding.
402:             *
403:             * @param writer The writer to render output to
404:             */
405:            public void render(Writer writer) {
406:
407:                render(writer, null);
408:
409:            }
410:
411:            /**
412:             * Render this channel as XML conforming to the RSS 0.91 specification,
413:             * to the specified writer, indicating the specified character encoding.
414:             *
415:             * @param writer The writer to render output to
416:             * @param encoding The character encoding to declare, or <code>null</code>
417:             *  for no declaration
418:             */
419:            public void render(Writer writer, String encoding) {
420:
421:                PrintWriter pw = new PrintWriter(writer);
422:                render(pw, encoding);
423:                pw.flush();
424:
425:            }
426:
427:            /**
428:             * Render this channel as XML conforming to the RSS 0.91 specification,
429:             * to the specified writer, with no indication of character encoding.
430:             *
431:             * @param writer The writer to render output to
432:             */
433:            public void render(PrintWriter writer) {
434:
435:                render(writer, null);
436:
437:            }
438:
439:            /**
440:             * Render this channel as XML conforming to the RSS 0.91 specification,
441:             * to the specified writer, indicating the specified character encoding.
442:             *
443:             * @param writer The writer to render output to
444:             * @param encoding The character encoding to declare, or <code>null</code>
445:             *  for no declaration
446:             */
447:            public void render(PrintWriter writer, String encoding) {
448:
449:                writer.print("<?xml version=\"1.0\"");
450:                if (encoding != null) {
451:                    writer.print(" encoding=\"");
452:                    writer.print(encoding);
453:                    writer.print("\"");
454:                }
455:                writer.println("?>");
456:                writer.println();
457:
458:                writer.println("<!DOCTYPE rss PUBLIC");
459:                writer
460:                        .println("  \"-//Netscape Communications//DTD RSS 0.91//EN\"");
461:                writer
462:                        .println("  \"http://my.netscape.com/publish/formats/rss-0.91.dtd\">");
463:                writer.println();
464:
465:                writer.println("<rss version=\"0.91\">");
466:                writer.println();
467:
468:                writer.println("  <channel>");
469:                writer.println();
470:
471:                writer.print("    <title>");
472:                writer.print(title);
473:                writer.println("</title>");
474:
475:                writer.print("    <description>");
476:                writer.print(description);
477:                writer.println("</description>");
478:
479:                writer.print("    <link>");
480:                writer.print(link);
481:                writer.println("</link>");
482:
483:                writer.print("    <language>");
484:                writer.print(language);
485:                writer.println("</language>");
486:
487:                if (rating != null) {
488:                    writer.print("    <rating>");
489:                    writer.print(rating);
490:                    writer.println("</rating>");
491:                }
492:
493:                if (copyright != null) {
494:                    writer.print("    <copyright>");
495:                    writer.print(copyright);
496:                    writer.print("</copyright>");
497:                }
498:
499:                if (pubDate != null) {
500:                    writer.print("    <pubDate>");
501:                    writer.print(pubDate);
502:                    writer.println("</pubDate>");
503:                }
504:
505:                if (lastBuildDate != null) {
506:                    writer.print("    <lastBuildDate>");
507:                    writer.print(lastBuildDate);
508:                    writer.println("</lastBuildDate>");
509:                }
510:
511:                if (docs != null) {
512:                    writer.print("    <docs>");
513:                    writer.print(docs);
514:                    writer.println("</docs>");
515:                }
516:
517:                if (managingEditor != null) {
518:                    writer.print("    <managingEditor>");
519:                    writer.print(managingEditor);
520:                    writer.println("</managingEditor>");
521:                }
522:
523:                if (webMaster != null) {
524:                    writer.print("    <webMaster>");
525:                    writer.print(webMaster);
526:                    writer.println("</webMaster>");
527:                }
528:
529:                writer.println();
530:
531:                if (image != null) {
532:                    image.render(writer);
533:                    writer.println();
534:                }
535:
536:                if (textInput != null) {
537:                    textInput.render(writer);
538:                    writer.println();
539:                }
540:
541:                String skipDays[] = findSkipDays();
542:                if (skipDays.length > 0) {
543:                    writer.println("    <skipDays>");
544:                    for (int i = 0; i < skipDays.length; i++) {
545:                        writer.print("      <skipDay>");
546:                        writer.print(skipDays[i]);
547:                        writer.println("</skipDay>");
548:                    }
549:                    writer.println("    </skipDays>");
550:                }
551:
552:                String skipHours[] = findSkipHours();
553:                if (skipHours.length > 0) {
554:                    writer.println("    <skipHours>");
555:                    for (int i = 0; i < skipHours.length; i++) {
556:                        writer.print("      <skipHour>");
557:                        writer.print(skipHours[i]);
558:                        writer.println("</skipHour>");
559:                    }
560:                    writer.println("    </skipHours>");
561:                    writer.println();
562:                }
563:
564:                Item items[] = findItems();
565:                for (int i = 0; i < items.length; i++) {
566:                    items[i].render(writer);
567:                    writer.println();
568:                }
569:
570:                writer.println("  </channel>");
571:                writer.println();
572:
573:                writer.println("</rss>");
574:
575:            }
576:
577:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.