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 |
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 |
* Genera eventos SAX relacionados con un XMLEntity
|
11 |
*
|
12 |
* @author Fernando Gonz?lez Cort?s
|
13 |
*/
|
14 |
public class GDBMSParser { |
15 |
XMLEntity xml; |
16 |
private ContentHandler handler; |
17 |
public GDBMSParser(XMLEntity xml){
|
18 |
this.xml = xml;
|
19 |
} |
20 |
|
21 |
public void setContentHandler(ContentHandler handler){ |
22 |
this.handler = handler;
|
23 |
} |
24 |
|
25 |
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 |
|
31 |
atts.addAttribute("", key, key, "string", value); |
32 |
} |
33 |
|
34 |
handler.startElement("", xml.getName(), xml.getName(), atts);
|
35 |
|
36 |
for (int i = 0; i < xml.getChildrenCount(); i++) { |
37 |
GDBMSParser p = new GDBMSParser(xml.getChild(i));
|
38 |
p.setContentHandler(handler); |
39 |
p.parse(); |
40 |
} |
41 |
|
42 |
handler.endElement("", xml.getName(), xml.getName());
|
43 |
} |
44 |
} |