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:
26: /*
27: * Given a list as
28: * property1=value1; property2=value2; property3=value3;
29: * this class parses it and gives each propertylist on request
30: */
31:
32: /**
33: *
34: * @author Anand Rao
35: */
36: public class MultiPropertyList {
37:
38: private Vector PropertyList; // holds string of individual property
39:
40: // in the form <property name>=value
41:
42: private String stripBlanks(String s) {
43: return s.trim();
44: }
45:
46: /*
47: * input in form <property1>=value1;<property2>=value2;
48: */
49: private void parseInput(char delimiter, String input) {
50: StringBuffer line = new StringBuffer();
51: char c;
52: for (int i = 0; i < input.length(); i++) {
53: if ((c = input.charAt(i)) != delimiter)
54: line.append(c);
55: else {
56: line.append(c); // include the delimiter also
57: PropertyList.addElement(stripBlanks(line.toString()));
58: line = new StringBuffer();
59: }
60: }
61: }
62:
63: /** Creates a new instance of MultiPropertyList */
64: public MultiPropertyList(char PropertyDelimiter, String input) {
65: PropertyList = new Vector();
66: parseInput(PropertyDelimiter, input);
67: }
68:
69: public String getProperty(int index) {
70: if (index < PropertyList.size())
71: return (String) PropertyList.get(index);
72: else
73: return null;
74: }
75: }
|