KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > nava > informa > impl > castorjdo > Channel


1 //
2
// Informa -- RSS Library for Java
3
// Copyright (c) 2002 by Niko Schmuck
4
//
5
// Niko Schmuck
6
// http://sourceforge.net/projects/informa
7
// mailto:niko_schmuck@users.sourceforge.net
8
//
9
// This library is free software.
10
//
11
// You may redistribute it and/or modify it under the terms of the GNU
12
// Lesser General Public License as published by the Free Software Foundation.
13
//
14
// Version 2.1 of the license should be included with this distribution in
15
// the file LICENSE. If the license is not included with this distribution,
16
// you may find a copy at the FSF web site at 'www.gnu.org' or 'www.fsf.org',
17
// or you may write to the Free Software Foundation, 675 Mass Ave, Cambridge,
18
// MA 02139 USA.
19
//
20
// This library is distributed in the hope that it will be useful,
21
// but WITHOUT ANY WARRANTY; without even the implied waranty of
22
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23
// Lesser General Public License for more details.
24
//
25

26
27 // $Id: Channel.java,v 1.3 2004/06/28 19:14:29 niko_schmuck Exp $
28

29 package de.nava.informa.impl.castorjdo;
30
31 import java.net.URL JavaDoc;
32 import java.net.MalformedURLException JavaDoc;
33 import org.apache.commons.logging.Log;
34 import org.apache.commons.logging.LogFactory;
35
36 import org.jdom.Element;
37
38 import de.nava.informa.core.ChannelIF;
39 import de.nava.informa.core.ItemIF;
40
41 /**
42  * Implementation for Castor's JDO of the ChannelIF interface.
43  *
44  * @author Niko Schmuck (niko@nava.de)
45  */

46 public class Channel extends de.nava.informa.impl.basic.Channel
47   implements ChannelIF, java.io.Serializable JavaDoc {
48
49   private static Log logger = LogFactory.getLog(Channel.class);
50
51   public Channel() {
52     super();
53   }
54
55   public Channel(String JavaDoc title) {
56     super(title);
57   }
58
59   public Channel(Element channelElement) {
60     super(channelElement);
61   }
62   public Channel(Element channelElement, String JavaDoc title) {
63     super(channelElement, title);
64   }
65
66   // --------------------------------------------------------------
67
// additional methods needed for JDO
68
// --------------------------------------------------------------
69

70   public String JavaDoc getLocationAsString(){
71     return getLocation().toString();
72   }
73
74   public void setLocation(String JavaDoc location) {
75     try {
76       setLocation(new URL JavaDoc(location));
77     } catch (MalformedURLException JavaDoc e) {
78       try {
79         logger.info("Resetting invalid location <" + location + ">: " + e);
80         setLocation(new URL JavaDoc("http://example.org"));
81       } catch (MalformedURLException JavaDoc x) {
82         // unreachable
83
}
84     }
85   }
86
87   public String JavaDoc getSiteAsString() {
88     return getSite().toString();
89   }
90
91   public void setSiteFromString(String JavaDoc site) {
92     try {
93       logger.debug("--> site: " + site);
94       setSite(new URL JavaDoc(site));
95     } catch (MalformedURLException JavaDoc e) {
96       logger.debug("--> oops site: " + e);
97       try {
98         logger.info("Resetting invalid site <" + site + ">: " + e);
99         setSite(new URL JavaDoc("http://example.org"));
100       } catch (MalformedURLException JavaDoc x) {
101         // unreachable
102
}
103     }
104   }
105
106   public void addItem(Item item) {
107     addItem((ItemIF) item);
108   }
109
110 }
111
Popular Tags