svn-gvsig-desktop / tags / v1_0_2_RELEASE / applications / appgvSIG / src / com / iver / cit / gvsig / project / XMLEntityXMLHandler.java @ 11432
History | View | Annotate | Download (4.45 KB)
1 | 1103 | fjp | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | *
|
||
19 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | * Av. Blasco Ib??ez, 50
|
||
24 | * 46010 VALENCIA
|
||
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | 312 | fernando | package com.iver.cit.gvsig.project; |
42 | |||
43 | import java.util.EmptyStackException; |
||
44 | import java.util.Stack; |
||
45 | |||
46 | import org.apache.log4j.Logger; |
||
47 | import org.xml.sax.Attributes; |
||
48 | import org.xml.sax.ContentHandler; |
||
49 | import org.xml.sax.Locator; |
||
50 | import org.xml.sax.SAXException; |
||
51 | |||
52 | import com.iver.utiles.XMLEntity; |
||
53 | |||
54 | |||
55 | /**
|
||
56 | * DOCUMENT ME!
|
||
57 | *
|
||
58 | * @author Fernando Gonz?lez Cort?s
|
||
59 | */
|
||
60 | public class XMLEntityXMLHandler implements ContentHandler { |
||
61 | private static Logger logger = Logger.getLogger(XMLEntityXMLHandler.class.getName()); |
||
62 | private XMLEntity lastEntity;
|
||
63 | private Stack entities = new Stack(); |
||
64 | |||
65 | /**
|
||
66 | * @see org.xml.sax.ContentHandler#setDocumentLocator(org.xml.sax.Locator)
|
||
67 | */
|
||
68 | public void setDocumentLocator(Locator arg0) { |
||
69 | } |
||
70 | |||
71 | /**
|
||
72 | * @see org.xml.sax.ContentHandler#startDocument()
|
||
73 | */
|
||
74 | public void startDocument() throws SAXException { |
||
75 | } |
||
76 | |||
77 | /**
|
||
78 | * @see org.xml.sax.ContentHandler#endDocument()
|
||
79 | */
|
||
80 | public void endDocument() throws SAXException { |
||
81 | } |
||
82 | |||
83 | /**
|
||
84 | * @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String,
|
||
85 | * java.lang.String)
|
||
86 | */
|
||
87 | public void startPrefixMapping(String arg0, String arg1) |
||
88 | throws SAXException {
|
||
89 | } |
||
90 | |||
91 | /**
|
||
92 | * @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String)
|
||
93 | */
|
||
94 | public void endPrefixMapping(String arg0) throws SAXException { |
||
95 | } |
||
96 | |||
97 | /**
|
||
98 | * @see org.xml.sax.ContentHandler#startElement(java.lang.String,
|
||
99 | * java.lang.String, java.lang.String, org.xml.sax.Attributes)
|
||
100 | */
|
||
101 | public void startElement(String namespaceURI, String localName, |
||
102 | String qName, Attributes atts) throws SAXException { |
||
103 | |||
104 | XMLEntity aux = new XMLEntity();
|
||
105 | entities.push(aux); |
||
106 | |||
107 | for (int i = 0; i < atts.getLength(); i++) { |
||
108 | String name = atts.getLocalName(i);
|
||
109 | String value = atts.getValue(i);
|
||
110 | |||
111 | aux.putProperty(name, value); |
||
112 | } |
||
113 | } |
||
114 | |||
115 | /**
|
||
116 | * @see org.xml.sax.ContentHandler#endElement(java.lang.String,
|
||
117 | * java.lang.String, java.lang.String)
|
||
118 | */
|
||
119 | public void endElement(String namespaceURI, String localName, String qName) |
||
120 | throws SAXException {
|
||
121 | if (localName.equals("entity")){ |
||
122 | XMLEntity aux = (XMLEntity) entities.pop(); |
||
123 | try{
|
||
124 | XMLEntity last = (XMLEntity) entities.peek(); |
||
125 | last.addChild(aux); |
||
126 | }catch (EmptyStackException e) { |
||
127 | } |
||
128 | lastEntity = aux; |
||
129 | } |
||
130 | } |
||
131 | |||
132 | /**
|
||
133 | * @see org.xml.sax.ContentHandler#characters(char[], int, int)
|
||
134 | */
|
||
135 | public void characters(char[] arg0, int arg1, int arg2) |
||
136 | throws SAXException {
|
||
137 | } |
||
138 | |||
139 | /**
|
||
140 | * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
|
||
141 | */
|
||
142 | public void ignorableWhitespace(char[] arg0, int arg1, int arg2) |
||
143 | throws SAXException {
|
||
144 | } |
||
145 | |||
146 | /**
|
||
147 | * @see org.xml.sax.ContentHandler#processingInstruction(java.lang.String,
|
||
148 | * java.lang.String)
|
||
149 | */
|
||
150 | public void processingInstruction(String arg0, String arg1) |
||
151 | throws SAXException {
|
||
152 | } |
||
153 | |||
154 | /**
|
||
155 | * @see org.xml.sax.ContentHandler#skippedEntity(java.lang.String)
|
||
156 | */
|
||
157 | public void skippedEntity(String arg0) throws SAXException { |
||
158 | } |
||
159 | |||
160 | /**
|
||
161 | * DOCUMENT ME!
|
||
162 | *
|
||
163 | * @return
|
||
164 | */
|
||
165 | public XMLEntity getXMLEntity() {
|
||
166 | return lastEntity;
|
||
167 | } |
||
168 | } |