[3102] | 1 | package nu.fw.jeti.jabber.handlers; |
---|
| 2 | |
---|
| 3 | import java.util.ArrayList; |
---|
| 4 | import java.util.List; |
---|
| 5 | |
---|
| 6 | import nu.fw.jeti.jabber.elements.Extension; |
---|
| 7 | import nu.fw.jeti.jabber.elements.JetiExtensionBuilder; |
---|
| 8 | |
---|
| 9 | import org.xml.sax.Attributes; |
---|
| 10 | |
---|
| 11 | /** |
---|
| 12 | * <p>Title: im</p> |
---|
| 13 | * <p>Description: </p> |
---|
| 14 | * <p>Copyright: Copyright (c) 2001</p> |
---|
| 15 | * <p>Company: </p> |
---|
| 16 | * @author E.S. de Boer |
---|
| 17 | * @version 1.0 |
---|
| 18 | */ |
---|
| 19 | |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | |
---|
| 23 | public class JetiPrivateHandler extends ExtensionHandler |
---|
| 24 | { |
---|
| 25 | private JetiExtensionBuilder builder; |
---|
| 26 | |
---|
| 27 | private List tempList; |
---|
| 28 | |
---|
| 29 | public JetiPrivateHandler() |
---|
| 30 | { |
---|
| 31 | builder=new JetiExtensionBuilder(); |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | public void startHandling(Attributes attributes) |
---|
| 35 | { |
---|
| 36 | builder.reset(); |
---|
| 37 | tempList = new ArrayList(10); |
---|
| 38 | builder.reset(); |
---|
| 39 | //attributes. |
---|
| 40 | for (int i = 0; i < attributes.getLength(); i++) |
---|
| 41 | { |
---|
| 42 | String name = attributes.getQName(i); |
---|
| 43 | if(name.equals("xmlVersion")) builder.setXmlVersion(attributes.getValue(i)); |
---|
| 44 | else if(!name.equals("xmlns") && !attributes.getValue(i).equals("")) builder.put(name,attributes.getValue(i)); |
---|
| 45 | } |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | public void startElement(String name,Attributes attributes) |
---|
| 49 | {// in attributes in volgede tags? |
---|
| 50 | //we have no attributes, so all we do is make sure the buffer is |
---|
| 51 | //reset for reading in character data. |
---|
| 52 | if(!name.equals("status")) |
---|
| 53 | { |
---|
| 54 | tempList = new ArrayList(10); |
---|
| 55 | //System.out.println("we hebben een pref start element"); |
---|
| 56 | for (int i = 0; i < attributes.getLength(); i++) |
---|
| 57 | { |
---|
| 58 | //String name2 = attributes.getName(i); |
---|
| 59 | //System.out.println(name2 +" : " +attributes.getValue(i) ); |
---|
| 60 | tempList.add(attributes.getValue(i)); |
---|
| 61 | //if(!name.equals("xmlns")) builder.put(name,attributes.getValue(i)); |
---|
| 62 | } |
---|
| 63 | } |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | public void endElement(String name) |
---|
| 67 | {// element = tussen tags |
---|
| 68 | //System.out.println("end element name" + name); |
---|
| 69 | if(!name.equals("status")) |
---|
| 70 | { |
---|
| 71 | //Collections.reverse(tempList); |
---|
| 72 | builder.putMessages(name,tempList); |
---|
| 73 | } |
---|
| 74 | //System.out.println(new String(elementChars)); |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | public Extension build() |
---|
| 78 | { |
---|
| 79 | Extension e = builder.build(); |
---|
| 80 | builder.reset(); |
---|
| 81 | return e; |
---|
| 82 | } |
---|
| 83 | } |
---|
| 84 | /* |
---|
| 85 | * Overrides for emacs |
---|
| 86 | * Local variables: |
---|
| 87 | * tab-width: 4 |
---|
| 88 | * End: |
---|
| 89 | */ |
---|