01: /**********************************************************************************
02:
03: Feedzeo!
04: A free and open source RSS/Atom/RDF feed aggregator
05:
06: Copyright (C) 2005-2006 Anand Rao (anandrao@users.sourceforge.net)
07:
08: This library is free software; you can redistribute it and/or
09: modify it under the terms of the GNU Lesser General Public
10: License as published by the Free Software Foundation; either
11: version 2.1 of the License, or (at your option) any later version.
12:
13: This library is distributed in the hope that it will be useful,
14: but WITHOUT ANY WARRANTY; without even the implied warranty of
15: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: Lesser General Public License for more details.
17:
18: You should have received a copy of the GNU Lesser General Public
19: License along with this library; if not, write to the Free Software
20: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21:
22: ************************************************************************************/package util;
23:
24: import java.util.*;
25: import java.io.*;
26:
27: /**
28: *
29: * @author Anand Rao
30: */
31:
32: public class FeedInputFileParser extends ConfigFileParser {
33:
34: private void initFeedListCursor(String Category) {
35: initGroupCursor(Category);
36: }
37:
38: private String getNextFeedLink(String Category) throws IOException {
39: return getNextGroupItem(Category);
40: }
41:
42: ///////////// PUBLIC FUNCTIONS ///////////////////
43:
44: /** Creates a new instance of FeedInputFileParser */
45: public FeedInputFileParser(String Path)
46: throws FileNotFoundException {
47: super (Path);
48: }
49:
50: public synchronized int getNumCategories() {
51: return getNumGroups();
52: }
53:
54: public synchronized String getCategory(int index) {
55: return getGroup(index);
56: }
57:
58: public synchronized int insertFeedLink(String Category,
59: String FeedLink) {
60: return insertGroupItem(Category, FeedLink);
61: }
62:
63: public synchronized int deleteFeedLink(String Category,
64: String FeedLink) {
65: return deleteGroupItem(Category, FeedLink);
66: }
67:
68: /* return a vector containing strings of feedurls under this category */
69: public synchronized Vector getCategoryFeedsCollection(String CatName)
70: throws IOException {
71: Vector v = new Vector();
72: String url;
73:
74: initFeedListCursor(CatName);
75: while ((url = getNextFeedLink(CatName)) != null) {
76: v.add(url);
77: }
78: return v;
79: }
80:
81: public synchronized void closeParser() {
82: CloseFile();
83: }
84: }
|