source: 3thparty/jmessenger/src/nu/fw/jeti/util/PreferencesHandler.java @ 3952

Revision 3952, 3.0 KB checked in by alexandrecorreia, 13 years ago (diff)

Ticket #1710 - Adicao do codigo fonte java do componente jmessenger(jabberit_messenger)

  • Property svn:executable set to *
Line 
1/*
2 *      Jeti, a Java Jabber client, Copyright (C) 2001 E.S. de Boer 
3 *
4 *  This program is free software; you can redistribute it and/or modify
5 *  it under the terms of the GNU General Public License as published by
6 *  the Free Software Foundation; either version 2 of the License, or
7 *  (at your option) any later version.
8 *
9 *  This program is distributed in the hope that it will be useful,
10 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
11 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 *      GNU General Public License for more details.
13 *
14 *  You should have received a copy of the GNU General Public License
15 *  along with this program; if not, write to the Free Software
16 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 *
18 *      For questions, comments etc,
19 *      use the website at http://jeti.jabberstudio.org
20 *  or mail/IM me at jeti@jabber.org
21 */
22
23
24package nu.fw.jeti.util;
25
26import org.xml.sax.helpers.*;
27import org.xml.sax.*;
28import java.util.*;
29
30/**
31  * @author E.S. de Boer
32 */
33
34public class PreferencesHandler extends DefaultHandler
35{
36       
37        private Map preferences;
38        //private Map messages;
39        private StringBuffer text= new StringBuffer();
40    //private String show = "available";
41
42        public PreferencesHandler(Map preferences)
43        {
44                this.preferences = preferences;
45       // this.messages = messages;
46        }
47
48        public void startElement(String namespaceURI,
49                                                        String sName, // simple name
50                                                        String qName, // qualified name
51                                                        Attributes attrs)                                                       
52        {
53                if(qName.equals("plugin"))
54                {
55                        String type = attrs.getValue("type");
56                        String name = attrs.getValue("name");
57                        Object[] temp = new Object[6];
58                        temp[0] = name;
59                        temp[1] = Boolean.valueOf(attrs.getValue("enabled"));
60                        temp[3] = attrs.getValue("transport");
61
62            List l = Preferences.getPlugable(type);
63            for (int i=0; i<l.size(); i++) {
64                Object[] t = (Object[])l.get(i);
65                if (name.equals(t[0])) {
66                    l.remove(i--);
67                }
68            }
69                        l.add(temp);
70                }
71                else if(qName.equals("preference"))
72                {
73                        String key = attrs.getValue("key");
74                        String value = attrs.getValue("value");
75                        preferences.put(key,value);
76                }
77                /*
78                else if(qName.equals("messages"))
79                {
80                        show = attrs.getValue("show");
81            if (show == null) {
82                show = "available";
83            }
84                }
85                else if(qName.equals("message"))
86                {
87                        String text = attrs.getValue("text");
88            List list = (List)messages.get(show);
89            if (list == null) {
90                list = new ArrayList(10);
91            }
92            list.add(text);
93            messages.put(show, list);
94                }
95                */
96        }
97
98
99        public void endElement(String namespaceURI,
100                                                   String sName, // simple name
101                                                   String qName  // qualified name
102                                                        )
103        {
104        text = new StringBuffer();
105        }
106
107        public void characters(char buf[], int offset, int Len)
108        {
109                   text.append(buf, offset, Len);
110        }
111}
112/*
113 * Overrides for emacs
114 * Local variables:
115 * tab-width: 4
116 * End:
117 */
Note: See TracBrowser for help on using the repository browser.