svn-gvsig-desktop / tags / v1_0_2_Build_905 / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / GDBMSParser.java @ 10767
History | View | Annotate | Download (1.05 KB)
1 | 1836 | fernando | package com.iver.cit.gvsig.fmap.layers; |
---|---|---|---|
2 | |||
3 | import org.xml.sax.ContentHandler; |
||
4 | import org.xml.sax.SAXException; |
||
5 | import org.xml.sax.helpers.AttributesImpl; |
||
6 | |||
7 | import com.iver.utiles.XMLEntity; |
||
8 | |||
9 | /**
|
||
10 | 1839 | fernando | * Genera eventos SAX relacionados con un XMLEntity
|
11 | 6864 | jaume | *
|
12 | 1836 | fernando | * @author Fernando Gonz?lez Cort?s
|
13 | */
|
||
14 | public class GDBMSParser { |
||
15 | XMLEntity xml; |
||
16 | private ContentHandler handler; |
||
17 | public GDBMSParser(XMLEntity xml){
|
||
18 | 6864 | jaume | this.xml = xml;
|
19 | 1836 | fernando | } |
20 | 6864 | jaume | |
21 | 1836 | fernando | public void setContentHandler(ContentHandler handler){ |
22 | this.handler = handler;
|
||
23 | } |
||
24 | 6864 | jaume | |
25 | 1836 | fernando | public void parse() throws SAXException{ |
26 | AttributesImpl atts = new AttributesImpl();
|
||
27 | for (int i = 0; i < xml.getPropertyCount(); i++) { |
||
28 | String key = xml.getPropertyName(i);
|
||
29 | String value = xml.getPropertyValue(i);
|
||
30 | 6864 | jaume | |
31 | atts.addAttribute("", key, key, "string", value); |
||
32 | 1836 | fernando | } |
33 | 6864 | jaume | |
34 | 1836 | fernando | handler.startElement("", xml.getName(), xml.getName(), atts);
|
35 | 6864 | jaume | |
36 | for (int i = 0; i < xml.getChildrenCount(); i++) { |
||
37 | 1836 | fernando | GDBMSParser p = new GDBMSParser(xml.getChild(i));
|
38 | p.setContentHandler(handler); |
||
39 | p.parse(); |
||
40 | } |
||
41 | 6864 | jaume | |
42 | 1836 | fernando | handler.endElement("", xml.getName(), xml.getName());
|
43 | } |
||
44 | } |