root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / XMLEntityXMLHandler.java @ 29598
History | View | Annotate | Download (4.55 KB)
1 |
/* 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 |
package org.gvsig.app.project; |
42 |
|
43 |
import java.util.EmptyStackException; |
44 |
import java.util.Stack; |
45 |
|
46 |
import org.gvsig.app.project.documents.view.legend.gui.VectorialUniqueValue; |
47 |
import org.gvsig.utils.XMLEntity; |
48 |
import org.slf4j.Logger; |
49 |
import org.slf4j.LoggerFactory; |
50 |
|
51 |
import org.xml.sax.Attributes; |
52 |
import org.xml.sax.ContentHandler; |
53 |
import org.xml.sax.Locator; |
54 |
import org.xml.sax.SAXException; |
55 |
|
56 |
|
57 |
|
58 |
/**
|
59 |
* DOCUMENT ME!
|
60 |
*
|
61 |
* @author Fernando Gonz?lez Cort?s
|
62 |
*/
|
63 |
public class XMLEntityXMLHandler implements ContentHandler { |
64 |
private static final Logger logger = LoggerFactory |
65 |
.getLogger(XMLEntityXMLHandler.class); |
66 |
private XMLEntity lastEntity;
|
67 |
private Stack entities = new Stack(); |
68 |
|
69 |
/**
|
70 |
* @see org.xml.sax.ContentHandler#setDocumentLocator(org.xml.sax.Locator)
|
71 |
*/
|
72 |
public void setDocumentLocator(Locator arg0) { |
73 |
} |
74 |
|
75 |
/**
|
76 |
* @see org.xml.sax.ContentHandler#startDocument()
|
77 |
*/
|
78 |
public void startDocument() throws SAXException { |
79 |
} |
80 |
|
81 |
/**
|
82 |
* @see org.xml.sax.ContentHandler#endDocument()
|
83 |
*/
|
84 |
public void endDocument() throws SAXException { |
85 |
} |
86 |
|
87 |
/**
|
88 |
* @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String,
|
89 |
* java.lang.String)
|
90 |
*/
|
91 |
public void startPrefixMapping(String arg0, String arg1) |
92 |
throws SAXException {
|
93 |
} |
94 |
|
95 |
/**
|
96 |
* @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String)
|
97 |
*/
|
98 |
public void endPrefixMapping(String arg0) throws SAXException { |
99 |
} |
100 |
|
101 |
/**
|
102 |
* @see org.xml.sax.ContentHandler#startElement(java.lang.String,
|
103 |
* java.lang.String, java.lang.String, org.xml.sax.Attributes)
|
104 |
*/
|
105 |
public void startElement(String namespaceURI, String localName, |
106 |
String qName, Attributes atts) throws SAXException { |
107 |
|
108 |
XMLEntity aux = new XMLEntity();
|
109 |
entities.push(aux); |
110 |
|
111 |
for (int i = 0; i < atts.getLength(); i++) { |
112 |
String name = atts.getLocalName(i);
|
113 |
String value = atts.getValue(i);
|
114 |
|
115 |
aux.putProperty(name, value); |
116 |
} |
117 |
} |
118 |
|
119 |
/**
|
120 |
* @see org.xml.sax.ContentHandler#endElement(java.lang.String,
|
121 |
* java.lang.String, java.lang.String)
|
122 |
*/
|
123 |
public void endElement(String namespaceURI, String localName, String qName) |
124 |
throws SAXException {
|
125 |
if (localName.equals("entity")){ |
126 |
XMLEntity aux = (XMLEntity) entities.pop(); |
127 |
try{
|
128 |
XMLEntity last = (XMLEntity) entities.peek(); |
129 |
last.addChild(aux); |
130 |
}catch (EmptyStackException e) { |
131 |
} |
132 |
lastEntity = aux; |
133 |
} |
134 |
} |
135 |
|
136 |
/**
|
137 |
* @see org.xml.sax.ContentHandler#characters(char[], int, int)
|
138 |
*/
|
139 |
public void characters(char[] arg0, int arg1, int arg2) |
140 |
throws SAXException {
|
141 |
} |
142 |
|
143 |
/**
|
144 |
* @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
|
145 |
*/
|
146 |
public void ignorableWhitespace(char[] arg0, int arg1, int arg2) |
147 |
throws SAXException {
|
148 |
} |
149 |
|
150 |
/**
|
151 |
* @see org.xml.sax.ContentHandler#processingInstruction(java.lang.String,
|
152 |
* java.lang.String)
|
153 |
*/
|
154 |
public void processingInstruction(String arg0, String arg1) |
155 |
throws SAXException {
|
156 |
} |
157 |
|
158 |
/**
|
159 |
* @see org.xml.sax.ContentHandler#skippedEntity(java.lang.String)
|
160 |
*/
|
161 |
public void skippedEntity(String arg0) throws SAXException { |
162 |
} |
163 |
|
164 |
/**
|
165 |
* DOCUMENT ME!
|
166 |
*
|
167 |
* @return
|
168 |
*/
|
169 |
public XMLEntity getXMLEntity() {
|
170 |
return lastEntity;
|
171 |
} |
172 |
} |