KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > nava > informa > utils > InformaUtils


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

33 public class InformaUtils {
34
35   /**
36     * Copies all the top level properties from <code>sourceChan</code> into
37     * this <code>updChan</code>. Convience method to update basic channel
38     * properties (like title and description) in one call.
39     *
40     * <b>Important:</b> Location and Format is unchanged by this operation.
41     *
42     * @TODO: Tricky. There is a bug here that has to be fixed. Channel Properties
43     * which are actually pointers to other objects (e.g. Cloud) cannot be simply
44     * copied because during channel and item parsing, we first parse the stream
45     * into a basic (e.g. impl.basic.Cloud) object, which then gets subsequently copied
46     * by this method into a persistent (e.g. impl.hibernate.Cloud) object.
47     *
48     * I think the solution to this is to pass a ChannelBuilder into this method
49     * which is used to create the right type of duplicates of the objects instead
50     * of just copying the references. For now I will be skipping those. A similar
51     * kind of problem probably exists when copying item properties.
52     *
53     */

54    public static void copyChannelProperties(ChannelIF sourceChan, ChannelIF updChan) {
55      updChan.setTitle(sourceChan.getTitle());
56      updChan.setDescription(sourceChan.getDescription());
57      updChan.setSite(sourceChan.getSite());
58      updChan.setCreator(sourceChan.getCreator());
59      updChan.setCopyright(sourceChan.getCopyright());
60      updChan.setPublisher(sourceChan.getPublisher());
61      updChan.setLanguage(sourceChan.getLanguage());
62      updChan.setRating(sourceChan.getRating());
63      updChan.setGenerator(sourceChan.getGenerator());
64      updChan.setDocs(sourceChan.getDocs());
65      updChan.setTtl(sourceChan.getTtl());
66      updChan.setLastBuildDate(sourceChan.getLastBuildDate());
67      updChan.setUpdateBase(sourceChan.getUpdateBase());
68      updChan.setUpdateFrequency(sourceChan.getUpdateFrequency());
69      updChan.setUpdatePeriod(sourceChan.getUpdatePeriod());
70      updChan.setPubDate(sourceChan.getPubDate());
71
72 // updChan.setTextInput(sourceChan.getTextInput());
73
// updChan.setCloud(sourceChan.getCloud());
74
// updChan.setImage(sourceChan.getImage());
75
}
76
77    /**
78    * Analogous function to copy all the properties of an item to another one.
79    *
80    * @param src - Source ItemIF
81    * @param dest - Destination ItemIF
82    */

83   public static void copyItemProperties(ItemIF src, ItemIF dest)
84    {
85      dest.setTitle(src.getTitle());
86      dest.setDescription(src.getDescription());
87      dest.setLink(src.getLink());
88      dest.setCreator(src.getCreator());
89      dest.setSubject(src.getSubject());
90      dest.setDate(src.getDate());
91      dest.setFound(src.getFound());
92      dest.setUnRead(src.getUnRead());
93    }
94 }
95
Popular Tags