01: //
02: // Informa -- RSS Library for Java
03: // Copyright (c) 2002 by Niko Schmuck
04: //
05: // Niko Schmuck
06: // http://sourceforge.net/projects/informa
07: // mailto:niko_schmuck@users.sourceforge.net
08: //
09: // 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: // $Id: InformaUtils.java,v 1.10 2006/01/03 00:30:39 niko_schmuck Exp $
27:
28: package de.nava.informa.utils;
29:
30: import de.nava.informa.core.*;
31: import de.nava.informa.core.ChannelIF;
32:
33: /**
34: * InformaUtils class contain helper methods for various channel operations.
35: */
36: public final class InformaUtils {
37:
38: /**
39: * Copies all the top level properties from <code>sourceChan</code> into
40: * this <code>updChan</code>. Convience method to update basic channel
41: * properties (like title and description) in one call.
42: *
43: * <b>Important:</b> Location and Format is unchanged by this operation.
44: *
45: * TODO: Tricky. There is a bug here that has to be fixed. Channel Properties
46: * which are actually pointers to other objects (e.g. Cloud) cannot be simply
47: * copied because during channel and item parsing, we first parse the stream
48: * into a basic (e.g. impl.basic.Cloud) object, which then gets subsequently copied
49: * by this method into a persistent (e.g. impl.hibernate.Cloud) object.
50: *
51: * I think the solution to this is to pass a ChannelBuilder into this method
52: * which is used to create the right type of duplicates of the objects instead
53: * of just copying the references. For now I will be skipping those. A similar
54: * kind of problem probably exists when copying item properties.
55: *
56: */
57: public static void copyChannelProperties(ChannelIF sourceChan,
58: ChannelIF updChan) {
59: updChan.setTitle(sourceChan.getTitle());
60: updChan.setDescription(sourceChan.getDescription());
61: updChan.setSite(sourceChan.getSite());
62: updChan.setCreator(sourceChan.getCreator());
63: updChan.setCopyright(sourceChan.getCopyright());
64: updChan.setPublisher(sourceChan.getPublisher());
65: updChan.setLanguage(sourceChan.getLanguage());
66: updChan.setRating(sourceChan.getRating());
67: updChan.setGenerator(sourceChan.getGenerator());
68: updChan.setDocs(sourceChan.getDocs());
69: updChan.setTtl(sourceChan.getTtl());
70: updChan.setLastBuildDate(sourceChan.getLastBuildDate());
71: updChan.setUpdateBase(sourceChan.getUpdateBase());
72: updChan.setUpdateFrequency(sourceChan.getUpdateFrequency());
73: updChan.setUpdatePeriod(sourceChan.getUpdatePeriod());
74: updChan.setPubDate(sourceChan.getPubDate());
75: updChan.setFormat(sourceChan.getFormat());
76:
77: // updChan.setTextInput(sourceChan.getTextInput());
78: // updChan.setCloud(sourceChan.getCloud());
79: // updChan.setImage(sourceChan.getImage());
80: }
81:
82: /**
83: * Analogous function to copy all the properties of an item to another one.
84: *
85: * @param src - Source ItemIF
86: * @param dest - Destination ItemIF
87: */
88: public static void copyItemProperties(ItemIF src, ItemIF dest) {
89: dest.setTitle(src.getTitle());
90: dest.setDescription(src.getDescription());
91: dest.setLink(src.getLink());
92: dest.setCreator(src.getCreator());
93: dest.setSubject(src.getSubject());
94: dest.setDate(src.getDate());
95: dest.setFound(src.getFound());
96: dest.setUnRead(src.getUnRead());
97: }
98:
99: }
|