1 | /* |
---|
2 | * Jeti, a Java Jabber client, Copyright (C) 2004 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 me at eric@jeti.tk |
---|
21 | */ |
---|
22 | |
---|
23 | // Created on 18-sept-2004 |
---|
24 | package nu.fw.jeti.plugins.filetransfer.ibb; |
---|
25 | |
---|
26 | import nu.fw.jeti.jabber.JID; |
---|
27 | import nu.fw.jeti.jabber.elements.Extension; |
---|
28 | import nu.fw.jeti.jabber.handlers.ExtensionHandler; |
---|
29 | import nu.fw.jeti.util.Log; |
---|
30 | |
---|
31 | import org.xml.sax.Attributes; |
---|
32 | |
---|
33 | /** |
---|
34 | * @author E.S. de Boer |
---|
35 | * |
---|
36 | */ |
---|
37 | public class IBBHandler extends ExtensionHandler |
---|
38 | { |
---|
39 | private boolean close; |
---|
40 | private boolean open; |
---|
41 | private String sid; |
---|
42 | private int sequence; |
---|
43 | private int blockSize; |
---|
44 | private String data; |
---|
45 | |
---|
46 | public void startHandling(Attributes attr) |
---|
47 | { |
---|
48 | close=open=false; |
---|
49 | open=true; |
---|
50 | sid=null; |
---|
51 | data=null; |
---|
52 | blockSize=4096; |
---|
53 | sid= attr.getValue("sid"); |
---|
54 | try{ |
---|
55 | blockSize = Integer.parseInt(attr.getValue("block-size")); |
---|
56 | open=true; |
---|
57 | } |
---|
58 | catch(NumberFormatException e) |
---|
59 | { |
---|
60 | open=false; |
---|
61 | } |
---|
62 | try{ |
---|
63 | sequence = Integer.parseInt(attr.getValue("seq")); |
---|
64 | close = false; |
---|
65 | } |
---|
66 | catch(NumberFormatException e) |
---|
67 | { |
---|
68 | if(!open)close=true; |
---|
69 | } |
---|
70 | } |
---|
71 | |
---|
72 | // public void endElement(String name) |
---|
73 | // { |
---|
74 | // System.out.println(name); |
---|
75 | // data = getText(); |
---|
76 | // clearCurrentChars(); |
---|
77 | // } |
---|
78 | |
---|
79 | public Extension build() |
---|
80 | { |
---|
81 | data = getText(); |
---|
82 | clearCurrentChars(); |
---|
83 | return new IBBExtension(open,close,sid,blockSize,sequence,data); |
---|
84 | } |
---|
85 | } |
---|
86 | /* |
---|
87 | * Overrides for emacs |
---|
88 | * Local variables: |
---|
89 | * tab-width: 4 |
---|
90 | * End: |
---|
91 | */ |
---|